summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-11-29 18:48:52 +0100
committersnowleo <schneeleo@gmail.com>2011-11-29 18:48:52 +0100
commit0b2a3fcf7f1a38848d941ed125470c0c547d5fa1 (patch)
treecee00ceb2e44de4bc35d23892ac66b6c339c287b
parent57a0ec9912a16261a2c2cf341eabf0b11b57a0b2 (diff)
downloadEssentials-0b2a3fcf7f1a38848d941ed125470c0c547d5fa1.tar
Essentials-0b2a3fcf7f1a38848d941ed125470c0c547d5fa1.tar.gz
Essentials-0b2a3fcf7f1a38848d941ed125470c0c547d5fa1.tar.lz
Essentials-0b2a3fcf7f1a38848d941ed125470c0c547d5fa1.tar.xz
Essentials-0b2a3fcf7f1a38848d941ed125470c0c547d5fa1.zip
Output the redirected plugin too.
-rw-r--r--Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java34
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandessentials.java10
3 files changed, 28 insertions, 18 deletions
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<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
- private final transient Set<String> executed = new HashSet<String>();
+ private final transient Map<String, String> executed = new HashMap<String, String>();
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<String> disabledCommands()
+ executed.put(label, otherlabel);
+ }
+
+ public Map<String, String> 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("/<command> <reload/debug>");
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<String, String> 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