summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2011-11-29 17:21:18 +0000
committerKHobbits <rob@khobbits.co.uk>2011-11-29 17:21:18 +0000
commitaf7eae6201702950268758a2b993c4bdc4f7b45c (patch)
treeaf0dbb43deac6e5e6428ee87685e276699ab476d
parentcdbae1631dfd4e9cd71aa030260bbc43b75ad94e (diff)
downloadEssentials-af7eae6201702950268758a2b993c4bdc4f7b45c.tar
Essentials-af7eae6201702950268758a2b993c4bdc4f7b45c.tar.gz
Essentials-af7eae6201702950268758a2b993c4bdc4f7b45c.tar.lz
Essentials-af7eae6201702950268758a2b993c4bdc4f7b45c.tar.xz
Essentials-af7eae6201702950268758a2b993c4bdc4f7b45c.zip
Adding some debug info to /essentials
-rw-r--r--Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java13
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandessentials.java46
3 files changed, 51 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java
index a9291e629..a16f8031a 100644
--- a/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java
+++ b/Essentials/src/com/earth2me/essentials/AlternativeCommandsHandler.java
@@ -11,6 +11,7 @@ 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 IEssentials ess;
public AlternativeCommandsHandler(final IEssentials ess)
@@ -100,7 +101,7 @@ public class AlternativeCommandsHandler
if (commands == null || commands.isEmpty())
{
return null;
- }
+ }
if (commands.size() == 1)
{
return commands.get(0);
@@ -114,4 +115,14 @@ public class AlternativeCommandsHandler
// return the first alias
return commands.get(0);
}
+
+ public void executed(final String label)
+ {
+ executed.add(label);
+ }
+
+ public List<String> disabledCommands()
+ {
+ return new ArrayList<String>(executed);
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 15419b014..f82aec91a 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -273,7 +273,8 @@ public class Essentials extends JavaPlugin implements IEssentials
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
if (pc != null)
{
- LOGGER.info("Essentials: Alternative command " + commandLabel + " found, using " + pc.getLabel());
+ alternativeCommandsHandler.executed(commandLabel);
+ 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 cc541299d..7701bf575 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.Util;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
@@ -23,12 +24,44 @@ public class Commandessentials extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
- if (args.length > 0 && args[0].equalsIgnoreCase("debug"))
+ if (args.length == 0) {
+ run_disabled(server, sender, commandLabel, args);
+ }
+ else if (args[0].equalsIgnoreCase("debug"))
{
- ess.getSettings().setDebug(!ess.getSettings().isDebug());
- sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
- return;
+ run_debug(server, sender, commandLabel, args);
+ }
+ else if (args[0].equalsIgnoreCase("nya"))
+ {
+ run_nya(server, sender, commandLabel, args);
+ }
+ else {
+ run_reload(server, sender, commandLabel, args);
}
+ }
+
+ private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ {
+ 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()));
+ }
+
+ private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ {
+ ess.getSettings().setDebug(!ess.getSettings().isDebug());
+ sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
+ }
+
+ private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ {
+ ess.reload();
+ sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
+ }
+
+ private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ {
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
noteMap.put("1F#", (byte)0x0);
noteMap.put("1G", (byte)0x1);
@@ -54,8 +87,6 @@ public class Commandessentials extends EssentialsCommand
noteMap.put("2D#", (byte)(0x9 + 0xC));
noteMap.put("2E", (byte)(0xA + 0xC));
noteMap.put("2F", (byte)(0xB + 0xC));
- if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
- {
if (!noteBlocks.isEmpty())
{
return;
@@ -106,9 +137,6 @@ public class Commandessentials extends EssentialsCommand
}
}, 20, 2);
return;
- }
- ess.reload();
- sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
}
private void stopTune()