From 8e53762d3ed7fefd25a3ab16e709ae309c596518 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 8 Dec 2016 22:18:32 +0100 Subject: [PATCH] Probably fixed internal error on /u --- .../chat/commands/CommandCaller.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/buttondevteam/chat/commands/CommandCaller.java b/src/main/java/buttondevteam/chat/commands/CommandCaller.java index dfda9de..40bdfcc 100644 --- a/src/main/java/buttondevteam/chat/commands/CommandCaller.java +++ b/src/main/java/buttondevteam/chat/commands/CommandCaller.java @@ -7,6 +7,7 @@ import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -66,25 +67,21 @@ public class CommandCaller implements CommandExecutor { path += " " + arg; TBMCCommandBase cmd = TBMCChatAPI.GetCommands().get(path); int argc = 0; - boolean hadspace = false; while (cmd == null && path.contains(" ")) { - hadspace = true; path = path.substring(0, path.lastIndexOf(' ')); argc++; cmd = TBMCChatAPI.GetCommands().get(path); } if (cmd == null) { - if (hadspace) { - sender.sendMessage(TBMCChatAPI.GetSubCommands(path, sender)); - return true; + String[] subcmds = TBMCChatAPI.GetSubCommands(path, sender); + if (subcmds.length > 0) + sender.sendMessage(subcmds); + else { + final String errormsg = "§cInternal error: Command not registered to CommandCaller"; + sender.sendMessage(errormsg); + if (!(sender instanceof ConsoleCommandSender)) + Bukkit.getConsoleSender().sendMessage(errormsg); } - String[] errormsg = new String[] { // - "§cInternal error: Command not registered to CommandCaller", // - "§cCommand: " + command.getName() + " - Args: " + Arrays.toString(args) + " - Path: " + path // - }; - sender.sendMessage(errormsg); - if (sender != Bukkit.getConsoleSender()) - Bukkit.getConsoleSender().sendMessage(errormsg); return true; } if (cmd.GetModOnly() && !PluginMain.permission.has(sender, "tbmc.admin")) {