diff options
7 files changed, 56 insertions, 19 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 e33e70f18..a83db16e3 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/I18n.java b/Essentials/src/com/earth2me/essentials/I18n.java index d3ffe5f76..4e2b033e6 100644 --- a/Essentials/src/com/earth2me/essentials/I18n.java +++ b/Essentials/src/com/earth2me/essentials/I18n.java @@ -69,6 +69,9 @@ public class I18n public static String _(final String string, final Object... objects) { + if (instance == null) { + return ""; + } if (objects.length == 0) { return instance.translate(string); diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index ed76ef325..1b71f30e4 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -59,8 +59,6 @@ public interface ISettings extends IConf String getProtectString(final String configName); - boolean getReclaimSetting(); - boolean getRespawnAtHome(); List getMultipleHomes(); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index aa6bb6cef..961b0b9b6 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -244,12 +244,6 @@ public class Settings implements ISettings } @Override - public boolean getReclaimSetting() - { - return config.getBoolean("reclaim-onlogout", false); - } - - @Override public int getSpawnMobLimit() { return config.getInt("spawnmob-limit", 10); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java index 6b028a634..3ef886347 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java @@ -67,6 +67,8 @@ public class Commandenchant extends EssentialsCommand super("enchant"); } + + //TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess); @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { 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() |