From 4561641d2b98a7c6cc415f32c2d03aff072e618f Mon Sep 17 00:00:00 2001 From: Nathan Curran <30569566+Focusvity@users.noreply.github.com> Date: Tue, 4 Aug 2020 18:14:42 +1000 Subject: [PATCH] Plugin-specific registration fix --- .../command/FreedomCommand.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java index 9077b369..a5f6594b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java @@ -82,10 +82,19 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter public void register() { FCommand cmd = new FCommand(this.name); - if (this.aliases != null) cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ","))); - if (this.description != null) cmd.setDescription(this.description); - if (this.usage != null) cmd.setUsage(this.usage); - getCommandMap().register("", cmd); + if (this.aliases != null) + { + cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ","))); + } + if (this.description != null) + { + cmd.setDescription(this.description); + } + if (this.usage != null) + { + cmd.setUsage(this.usage); + } + getCommandMap().register("totalfreedommod", cmd); cmd.setExecutor(this); } @@ -97,7 +106,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter { final Field f = Bukkit.getServer().getPluginManager().getClass().getDeclaredField("commandMap"); f.setAccessible(true); - commandMap = (CommandMap) f.get(Bukkit.getServer().getPluginManager()); + commandMap = (CommandMap)f.get(Bukkit.getServer().getPluginManager()); } catch (Exception e) { @@ -110,10 +119,12 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter private final class FCommand extends Command { private FreedomCommand cmd = null; + private FCommand(String command) { super(command); } + public void setExecutor(FreedomCommand cmd) { this.cmd = cmd;