package net.t2code.commandguiv2.Spigot.cmdManagement.register; import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Util; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import org.bukkit.Bukkit; import org.bukkit.command.CommandMap; import org.bukkit.plugin.Plugin; import java.lang.reflect.Field; public class AliasRegister { public static void onRegister() { Plugin plugin = Main.getPlugin(); T2Csend.debug(plugin, Bukkit.getServer().getClass().getPackage().getName()); if (Main.allAliases.toString().equals("[]")) { T2Csend.console(Util.getPrefix() + " ยง4No GUI files available"); return; } for (String alias : Main.allAliases) { if (Main.guiHashMap.get(alias) != null) { if (Main.guiHashMap.get(alias).commandAliasEnable) { try { final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); bukkitCommandMap.setAccessible(true); CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer()); commandMap.register(alias, new RegisterCommand(alias)); } catch(Exception e) { e.printStackTrace(); } } } } } }