From cd490e5769708f83e782c0639566cd83e3e30292 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 3 Nov 2016 18:22:57 +0100 Subject: [PATCH] Made command paths a bit more logical --- .../chat/commands/CommandCaller.java | 17 +++++++++++++---- .../chat/commands/ucmds/HelpCommand.java | 2 +- .../chat/commands/ucmds/UCommandBase.java | 2 +- .../commands/ucmds/admin/AdminCommandBase.java | 2 +- .../ucmds/announce/AnnounceCommandBase.java | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/buttondevteam/chat/commands/CommandCaller.java b/src/main/java/buttondevteam/chat/commands/CommandCaller.java index 6efbf5f..b7c8e55 100644 --- a/src/main/java/buttondevteam/chat/commands/CommandCaller.java +++ b/src/main/java/buttondevteam/chat/commands/CommandCaller.java @@ -1,6 +1,8 @@ package buttondevteam.chat.commands; import java.util.Arrays; +import java.util.Map.Entry; + import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -23,13 +25,20 @@ public class CommandCaller implements CommandExecutor { public static void RegisterCommands() { if (instance == null) instance = new CommandCaller(); - for (TBMCCommandBase c : TBMCChatAPI.GetCommands().values()) { - if (!c.GetCommandPath().contains("/")) // Top-level command + for (Entry entry : TBMCChatAPI.GetCommands().entrySet()) { + TBMCCommandBase c = entry.getValue(); + if (c == null) { + TBMCCoreAPI.SendException("An error occured while registering commands", + new Exception("Null command found at " + entry.getKey() + "!")); + continue; + } + if (!c.GetCommandPath().contains(" ")) // Top-level command { PluginCommand pc = ((JavaPlugin) c.getPlugin()).getCommand(c.GetCommandPath()); if (pc == null) - new Exception("Can't find top-level command: " + c.GetCommandPath() + " for plugin: " - + c.getPlugin().getName()).printStackTrace(); + TBMCCoreAPI.SendException("An error occured while registering commands", + new Exception("Can't find top-level command: " + c.GetCommandPath() + " for plugin: " + + c.getPlugin().getName())); else pc.setExecutor(instance); } diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java index d7205af..251de6f 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/HelpCommand.java @@ -33,7 +33,7 @@ public final class HelpCommand extends UCommandBase { ArrayList text = new ArrayList(); text.add("ยง6---- Command list ----"); for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) - if (!cmd.GetCommandPath().contains("/")) + if (!cmd.GetCommandPath().contains(" ")) text.add("/" + cmd.GetCommandPath()); sender.sendMessage(text.toArray(new String[text.size()])); } else if (args[0].equalsIgnoreCase("colors")) { diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/UCommandBase.java b/src/main/java/buttondevteam/chat/commands/ucmds/UCommandBase.java index 3dc0d47..2ebc393 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/UCommandBase.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/UCommandBase.java @@ -8,7 +8,7 @@ public abstract class UCommandBase extends TBMCCommandBase { @Override public String GetCommandPath() { - return "u/" + GetUCommandPath(); + return "u " + GetUCommandPath(); } public abstract String GetUCommandPath(); diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/AdminCommandBase.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/AdminCommandBase.java index 87a1a2d..97bec7b 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/AdminCommandBase.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/admin/AdminCommandBase.java @@ -8,7 +8,7 @@ public abstract class AdminCommandBase extends UCommandBase { @Override public String GetUCommandPath() { - return "admin/" + GetAdminCommandPath(); + return "admin " + GetAdminCommandPath(); } @Override diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/announce/AnnounceCommandBase.java b/src/main/java/buttondevteam/chat/commands/ucmds/announce/AnnounceCommandBase.java index d2674a9..6f76ed1 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/announce/AnnounceCommandBase.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/announce/AnnounceCommandBase.java @@ -8,7 +8,7 @@ public abstract class AnnounceCommandBase extends UCommandBase { @Override public String GetUCommandPath() { - return "announce/" + GetAnnounceCommandPath(); + return "announce " + GetAnnounceCommandPath(); } public abstract String GetAnnounceCommandPath();