diff --git a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java index d15a86d7e..366c86cc6 100644 --- a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java +++ b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java @@ -1,7 +1,6 @@ package com.earth2me.essentials; import java.util.*; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommandYamlParser; @@ -11,20 +10,21 @@ import org.bukkit.plugin.Plugin; public class AlternativeCommandsHandler { private final transient Map> altcommands = new HashMap>(); - private final transient Set executed = new HashSet(); + private final transient Map executed = new HashMap(); private final transient IEssentials ess; - + public AlternativeCommandsHandler(final IEssentials ess) { this.ess = ess; for (Plugin plugin : ess.getServer().getPluginManager().getPlugins()) { - if (plugin.isEnabled()) { + if (plugin.isEnabled()) + { addPlugin(plugin); } } } - + public final void addPlugin(final Plugin plugin) { if (plugin.getDescription().getMain().contains("com.earth2me.essentials")) @@ -101,28 +101,30 @@ public class AlternativeCommandsHandler if (commands == null || commands.isEmpty()) { return null; - } + } if (commands.size() == 1) { return commands.get(0); } // return the first command that is not an alias - for (PluginCommand command : commands) { - if (command.getName().equalsIgnoreCase(label)) { + for (PluginCommand command : commands) + { + if (command.getName().equalsIgnoreCase(label)) + { return command; } } // return the first alias return commands.get(0); } - - public void executed(final String label) + + public void executed(final String label, final String otherlabel) { - executed.add(label); - } - - public Set disabledCommands() + executed.put(label, otherlabel); + } + + public Map disabledCommands() { - return executed; - } + return executed; + } } diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index a83db16e3..19073b1aa 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -273,7 +273,7 @@ public class Essentials extends JavaPlugin implements IEssentials final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel); if (pc != null) { - alternativeCommandsHandler.executed(commandLabel); + alternativeCommandsHandler.executed(commandLabel, pc.getLabel()); LOGGER.log(Level.FINE,"Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel()); return pc.execute(sender, commandLabel, args); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index 7701bf575..507298a0b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -45,7 +45,15 @@ public class Commandessentials extends EssentialsCommand sender.sendMessage("Essentials " + ess.getDescription().getVersion()); sender.sendMessage("/ "); sender.sendMessage("Essentials blocked the following commands, due to command conflicts:"); - sender.sendMessage(Util.joinList(ess.getAlternativeCommandsHandler().disabledCommands())); + final StringBuilder disabledCommands = new StringBuilder(); + for (Map.Entry entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet()) + { + if (disabledCommands.length() > 0) { + disabledCommands.append(", "); + } + disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue()); + } + sender.sendMessage(disabledCommands.toString()); } private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception