Changes in the Standard Config
minor code changes / bug fixes
started for cooldown
This commit is contained in:
JaTiTV 2024-06-15 02:32:10 +02:00
parent 9aede116ac
commit d25b704ff1
14 changed files with 108 additions and 339 deletions

36
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>net.t2code</groupId>
<artifactId>Alias</artifactId>
<version>1.4</version>
<version>1.5</version>
<packaging>jar</packaging>
<name>T2C-Alias</name>
@ -57,6 +57,16 @@
</build>
<repositories>
<!-- Spigot -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- Mojang authlib -->
<repository>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
<repository>
<id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url>
@ -68,10 +78,24 @@
</repositories>
<dependencies>
<!-- Spigot-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Mojang authlib -->
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>15.7</version>
<version>16.5</version>
<!--classifier>dev-3</classifier-->
<scope>provided</scope>
</dependency>
@ -87,12 +111,8 @@
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_13.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.13r1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

View File

@ -3,8 +3,6 @@ package net.t2code.alias.Spigot;
import lombok.Getter;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Spigot.system.BukkitCommandWrap;
import net.t2code.alias.Spigot.system.BukkitCommandWrap_Useless;
import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
@ -38,11 +36,11 @@ public final class Main extends JavaPlugin {
public static ArrayList<String> allSubAliases = new ArrayList<>();
public static ArrayList<String> allForSubAliases = new ArrayList<>();
private BukkitCommandWrap bukkitCommandWrap = null;
public BukkitCommandWrap getBukkitCommandWrap() {
return this.bukkitCommandWrap;
}
// private BukkitCommandWrap bukkitCommandWrap = null;
//
// public BukkitCommandWrap getBukkitCommandWrap() {
// return this.bukkitCommandWrap;
// }
@ -53,12 +51,12 @@ public final class Main extends JavaPlugin {
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
try {
Class.forName("com.mojang.brigadier.CommandDispatcher");
this.bukkitCommandWrap = new BukkitCommandWrap();
} catch (ClassNotFoundException | NoClassDefFoundError e) {
this.bukkitCommandWrap = new BukkitCommandWrap_Useless();
}
// try {
// Class.forName("com.mojang.brigadier.CommandDispatcher");
// this.bukkitCommandWrap = new BukkitCommandWrap();
// } catch (ClassNotFoundException | NoClassDefFoundError e) {
// this.bukkitCommandWrap = new BukkitCommandWrap_Useless();
// }
if (T2CmcVersion.isMc1_13()) {
guiCode = "";
} else guiCode = "§6§8§9§r";

View File

@ -70,7 +70,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {
Boolean passend = true;
boolean passend = true;
for (int i = 0; i < args[0].length(); i++) {
if (args[0].length() >= command.length()) {
passend = false;

View File

@ -8,6 +8,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -21,24 +22,27 @@ public class CreateExampleAliasConfig {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
T2Cconfig.set("Alias.Enable", true, yamlConfiguration);
T2Cconfig.set("Alias.AliasList", Arrays.asList("aliasexample1"),yamlConfiguration);
T2Cconfig.set("Alias.AliasList", Arrays.asList("aliasexample1","t2caliasexample"),yamlConfiguration);
T2Cconfig.set("Alias.Permission.Necessary", true, yamlConfiguration);
T2Cconfig.set("Alias.Permission.Permission", "t2code.alias.use.<alias>", yamlConfiguration);
T2Cconfig.set("Alias.Permission.CustomNoPermissionMSG", "", yamlConfiguration);
T2Cconfig.set("Alias.Cooldown.Global", 0, yamlConfiguration);
T2Cconfig.set("Alias.Cooldown.Player", 0, yamlConfiguration);
T2Cconfig.set("Alias.Cost.Enable", false,yamlConfiguration);
T2Cconfig.set("Alias.Cost.Confirm", true,yamlConfiguration);
T2Cconfig.set("Alias.Cost.Price", 0.0,yamlConfiguration);
T2Cconfig.set("Alias.Cost.AllowByPass", true,yamlConfiguration);
T2Cconfig.set("Alias.Command.Enable", true, yamlConfiguration);
T2Cconfig.set("Alias.Command.Enable", false, yamlConfiguration);
T2Cconfig.set("Alias.Command.CommandAsConsole", true, yamlConfiguration);
T2Cconfig.set("Alias.Command.BungeeCommand", false, yamlConfiguration);
T2Cconfig.set("Alias.Command.Commands", Arrays.asList("say hi"), yamlConfiguration);
T2Cconfig.set("Alias.Command.Commands", Arrays.asList(), yamlConfiguration);
T2Cconfig.set("Alias.Message.Enable", false, yamlConfiguration);
T2Cconfig.set("Alias.Message.Messages", Arrays.asList(), yamlConfiguration);
T2Cconfig.set("Alias.Message.Enable", true, yamlConfiguration);
T2Cconfig.set("Alias.Message.Messages", Arrays.asList("<rainbow>This is a test alias</rainbow>", "<color:#d7ff0f>With this you can use several functions such as <color:#ffd6ad>colored text</color>, <click:suggest_command:'/command'><hover:show_text:'<color:#ff745c>Use Command</color>'>clickable texts</hover></click>, <hover:show_text:'<color:#1f66ff>For example Warps</color>'><click:suggest_command:'/warp home'><color:#365eff>shorten commands of other plugins</color></click></hover> and much more.</color>", "<color:#85a0ff><click:open_url:'http://dc.t2code.net'><hover:show_text:'<color:#0887ff>http://dc.t2code.net</color>'>If you have any questions, please contact our support Discord.</hover></click></color>"), yamlConfiguration);
T2Cconfig.set("Alias.Admin.Enable", false, yamlConfiguration);
T2Cconfig.set("Alias.Admin.Permission", "t2code.alias.admin", yamlConfiguration);

View File

@ -4,14 +4,12 @@ import com.google.common.base.Preconditions;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.system.AliasRegister;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.system.BukkitCommandWrap_Useless;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.FileNotFoundException;
@ -65,6 +63,9 @@ public class SelectAlias {
}
String permissionMSG = yamlConfiguration.getString("Alias.Permission.CustomNoPermissionMSG");
Integer cooldownGlobal = yamlConfiguration.getInt("Alias.Cooldown.Global");
Integer cooldownPlayer = yamlConfiguration.getInt("Alias.Cooldown.Player");
Boolean costEnable = yamlConfiguration.getBoolean("Alias.Cost.Enable");
if (yamlConfiguration.get("Alias.Cost.Confirm") == null) {
AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, false);
@ -100,9 +101,9 @@ public class SelectAlias {
List<String> consoleMessages = yamlConfiguration.getStringList("Alias.Console.Message.Messages");
Main.allAliases.addAll(aliasList);
AliasObject alias = new AliasObject(aliasEnable, aliasList, permNecessary, permission, permissionMSG, costEnable, costConfirm, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand,
command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands,
adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
AliasObject alias = new AliasObject(aliasEnable, aliasList, permNecessary, permission, permissionMSG, cooldownGlobal, cooldownPlayer, costEnable, costConfirm, costPrice, costAllowBypass, commandEnable,
commandAsConsole, bungeeCommand, command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands, adminMessageEnable,
adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
for (String al : aliasList) {
Main.aliasHashMap.put(al, alias);
}

View File

@ -66,6 +66,9 @@ public class SelectSubAlias {
}
String permissionMSG = yamlConfiguration.getString("SubAlias.Permission.CustomNoPermissionMSG");
Integer cooldownGlobal = yamlConfiguration.getInt("Alias.Cooldown.Global");
Integer cooldownPlayer = yamlConfiguration.getInt("Alias.Cooldown.Player");
Boolean costEnable = yamlConfiguration.getBoolean("SubAlias.Cost.Enable");
if (yamlConfiguration.get("SubAlias.Cost.Confirm") == null) {
AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, true);
@ -100,9 +103,9 @@ public class SelectSubAlias {
Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable");
List<String> consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages");
SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, costEnable,costConfirm, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand,
command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands,
adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, cooldownGlobal, cooldownPlayer, costEnable, costConfirm,
costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand, command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole,
adminBungeeCommand, adminCommands, adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
for (String sal : subAliasList) {
Main.subAliasHashMap.put(sal, subAlias);
}

View File

@ -10,6 +10,9 @@ public class AliasObject {
public String permission;
public String permissionMSG;
public Integer cooldownGlobal;
public Integer cooldownPlayer;
public Boolean costEnable;
public Boolean costConfirm;
public Double costPrice;
@ -44,6 +47,9 @@ public class AliasObject {
String permission,
String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable,
Boolean costConfirm,
Double costPrice,
@ -77,6 +83,9 @@ public class AliasObject {
this.permission = permission;
this.permissionMSG = permissionMSG;
this.cooldownGlobal = cooldownGlobal;
this.cooldownPlayer = cooldownPlayer;
this.costEnable = costEnable;
this.costConfirm = costConfirm;
this.costPrice = costPrice;

View File

@ -0,0 +1,15 @@
package net.t2code.alias.Spigot.objects;
import java.util.UUID;
public class Cooldown {
public UUID player;
public Long long_;
public Cooldown(UUID player,
Long long_) {
this.player = player;
this.long_ = long_;
}
}

View File

@ -12,6 +12,9 @@ public class SubAliasObject {
public String permission;
public String permissionMSG;
public Integer cooldownGlobal;
public Integer cooldownPlayer;
public Boolean costEnable;
public Boolean costConfirm;
public Double costPrice;
@ -48,6 +51,9 @@ public class SubAliasObject {
String permission,
String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable,
Boolean costConfirm,
Double costPrice,
@ -83,6 +89,9 @@ public class SubAliasObject {
this.permission = permission;
this.permissionMSG = permissionMSG;
this.cooldownGlobal = cooldownGlobal;
this.cooldownPlayer = cooldownPlayer;
this.costEnable = costEnable;
this.costConfirm = costConfirm;
this.costPrice = costPrice;

View File

@ -30,7 +30,7 @@ public class AliasRegister {
if (!(T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12())) {
Main.getPlugin().getBukkitCommandWrap().sync();
// Main.getPlugin().getBukkitCommandWrap().sync();
if (Bukkit.getOnlinePlayers().size() >= 1)
for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
}
@ -83,8 +83,5 @@ public class AliasRegister {
} else T2Csend.warning(Main.getPlugin(), " §4AliasHashmap is null! - " + alias);
}
private static void wrap(String alias, CommandMap commandMap) {
Command cmd = commandMap.getCommand(alias);
Main.getPlugin().getBukkitCommandWrap().wrap(cmd, alias);
}
}

View File

@ -12,23 +12,23 @@ public class AliasRegisterPermissions {
for (AliasObject aliasObject : Main.aliasHashMap.values()) {
for (String alias : aliasObject.aliasList){
if (Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
for (String alias : aliasObject.aliasList) {
if (aliasObject.permission != null && Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("<alias>", alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.permission.replace("<alias>", alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
if (aliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("<alias>", alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.adminPermission.replace("<alias>", alias).toLowerCase(), Main.getPlugin());
}
}
}
for (SubAliasObject subAliasObject : Main.subAliasHashMap.values()) {
for (String alias : subAliasObject.subAliasList){
if (Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
for (String alias : subAliasObject.subAliasList) {
if (subAliasObject.permission != null && Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("<alias>", alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.permission.replace("<alias>", alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
if (subAliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("<alias>", alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.adminPermission.replace("<alias>", alias).toLowerCase(), Main.getPlugin());
}
}
}

View File

@ -1,6 +1,7 @@
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -12,31 +13,7 @@ import java.io.IOException;
public class BCommandSenderReciver {
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
if (console) {
output.writeUTF("T2Code-Console");
} else {
if (sender instanceof Player) {
output.writeUTF(sender.getName());
} else {
output.writeUTF("T2Code-Console");
}
}
output.writeUTF(information);
} catch (IOException e) {
e.printStackTrace();
}
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
}else {
for(Player player : Bukkit.getOnlinePlayers()){
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
return;
}
}
T2CbungeeCommandSenderReciver.sendToBungee(sender,information,console);
}
}

View File

@ -1,247 +0,0 @@
package net.t2code.alias.Spigot.system;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class BukkitCommandWrap {
private Field bField;
private Method removeCommandMethod;
private String nmsVersion;
private Class minecraftServerClass;
private Method aMethod;
private Method getServerMethod;
private Field vanillaCommandDispatcherField;
private Method getCommandDispatcherMethod;
private Method registerMethod;
private Method syncCommandsMethod;
private Constructor bukkitcommandWrapperConstructor;
public BukkitCommandWrap() {
try {
this.nmsVersion = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
} catch (ArrayIndexOutOfBoundsException e) {
e.printStackTrace();
this.nmsVersion = null;
}
}
public void wrap(Command command, String alias) {
if (this.nmsVersion == null) return;
if (this.minecraftServerClass == null) try {
this.minecraftServerClass = Class.forName("net.minecraft.server." + this.nmsVersion + ".MinecraftServer");
} catch (ClassNotFoundException e) {
try {
this.minecraftServerClass = Class.forName("net.minecraft.server.MinecraftServer");
} catch (ClassNotFoundException classNotFoundException) {
classNotFoundException.addSuppressed(e);
classNotFoundException.printStackTrace();
return;
}
}
if (this.getServerMethod == null) try {
this.getServerMethod = this.minecraftServerClass.getMethod("getServer");
this.getServerMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
Object minecraftServer;
try {
minecraftServer = this.getServerMethod.invoke(this.minecraftServerClass);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
if (this.vanillaCommandDispatcherField == null) try {
this.vanillaCommandDispatcherField = this.minecraftServerClass.getDeclaredField("vanillaCommandDispatcher");
this.vanillaCommandDispatcherField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
return;
}
Object commandDispatcher = null;
try {
commandDispatcher = this.vanillaCommandDispatcherField.get(minecraftServer);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.bField == null) try {
this.bField = Class.forName("net.minecraft.commands.CommandDispatcher").getDeclaredField("g");
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
com.mojang.brigadier.CommandDispatcher b;
try {
b = (com.mojang.brigadier.CommandDispatcher) this.bField.get(commandDispatcher);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.aMethod == null) try {
this.aMethod = commandDispatcher.getClass().getDeclaredMethod("a");
this.aMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
if (this.bukkitcommandWrapperConstructor == null) try {
this.bukkitcommandWrapperConstructor = Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".command.BukkitCommandWrapper").getDeclaredConstructor(Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".CraftServer"), Command.class);
this.bukkitcommandWrapperConstructor.setAccessible(true);
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
Object commandWrapper;
try {
commandWrapper = this.bukkitcommandWrapperConstructor.newInstance(Bukkit.getServer(), command);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
Object a;
try {
a = this.aMethod.invoke(commandDispatcher);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
if (this.registerMethod == null) try {
this.registerMethod = Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".command.BukkitCommandWrapper").getMethod("register", com.mojang.brigadier.CommandDispatcher.class, String.class);
this.registerMethod.setAccessible(true);
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
try {
this.registerMethod.invoke(commandWrapper, a, alias);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
public void sync() {
if (this.syncCommandsMethod == null) try {
this.syncCommandsMethod = Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".CraftServer").getDeclaredMethod("syncCommands");
this.syncCommandsMethod.setAccessible(true);
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
try {
this.syncCommandsMethod.invoke(Bukkit.getServer());
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
public void unwrap(String command) {
if (this.nmsVersion == null) return;
if (this.minecraftServerClass == null) try {
this.minecraftServerClass = Class.forName("net.minecraft.server." + this.nmsVersion + ".MinecraftServer");
} catch (ClassNotFoundException e) {
try {
this.minecraftServerClass = Class.forName("net.minecraft.server.MinecraftServer");
} catch (ClassNotFoundException classNotFoundException) {
classNotFoundException.printStackTrace();
classNotFoundException.addSuppressed(e);
return;
}
}
if (this.getServerMethod == null) try {
this.getServerMethod = this.minecraftServerClass.getMethod("getServer");
this.getServerMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
Object server;
try {
server = this.getServerMethod.invoke(this.minecraftServerClass);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
if (this.vanillaCommandDispatcherField == null) try {
this.vanillaCommandDispatcherField = this.minecraftServerClass.getDeclaredField("vanillaCommandDispatcher");
this.vanillaCommandDispatcherField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
return;
}
Object commandDispatcher = null;
try {
commandDispatcher = this.vanillaCommandDispatcherField.get(server);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.bField == null) try {
this.bField = Class.forName("net.minecraft.server." + this.nmsVersion + ".CommandDispatcher").getDeclaredField("b");
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException e) {
if (this.bField == null) try {
this.bField = Class.forName("net.minecraft.commands.CommandDispatcher").getDeclaredField("g");
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException ex) {
ex.addSuppressed(e);
e.printStackTrace();
return;
}
}
com.mojang.brigadier.CommandDispatcher b;
try {
b = (com.mojang.brigadier.CommandDispatcher) this.bField.get(commandDispatcher);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.removeCommandMethod == null) try {
try {
this.removeCommandMethod = RootCommandNode.class.getDeclaredMethod("removeCommand", String.class);
} catch (NoSuchMethodException | NoSuchMethodError ex) {
this.removeCommandMethod = CommandNode.class.getDeclaredMethod("removeCommand", String.class);
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
try {
this.removeCommandMethod.invoke(b.getRoot(), command);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
}

View File

@ -1,17 +0,0 @@
package net.t2code.alias.Spigot.system;
import org.bukkit.command.Command;
public class BukkitCommandWrap_Useless extends BukkitCommandWrap {
public BukkitCommandWrap_Useless() {
}
@Override
public void wrap(Command command, String alias) {
}
@Override
public void unwrap(String command) {
}
}