diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 1dbc72772..7552e96db 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -430,14 +430,14 @@ public class EssentialsPlayerListener extends PlayerListener { return; } - final String command = user.getPowertool(is); - if (command == null || command.isEmpty()) + final List commands = user.getPowertool(is); + if (commands == null || commands.isEmpty()) { return; } // We need to loop through each command and execute - for (String commandPtr : command.split("\\|")) + for (String commandPtr : commands) { if (commandPtr.matches(".*\\{player\\}.*")) { diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 896339642..7cad0de93 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -173,26 +173,46 @@ public abstract class UserData extends PlayerExtension implements IConf config.setProperty("unlimited", unlimited); config.save(); } - private Map powertools; + private Map powertools; @SuppressWarnings("unchecked") - private Map getPowertools() + private Map getPowertools() { Object o = config.getProperty("powertools"); + if (o instanceof Map) { - return (Map)o; + for(Map.Entry entry : ((Map)o).entrySet()) + { + if(entry.getValue() instanceof String) + { + List temp = new ArrayList(); + temp.add((String)entry.getValue()); + ((Map)o).put(entry.getKey(), temp); + } + } + + return (Map)o; } else { - return new HashMap(); + return new HashMap(); } } - public String getPowertool(ItemStack stack) + public List getPowertool(ItemStack stack) { - return powertools.get(stack.getTypeId()); + return (List)powertools.get(stack.getTypeId()); + } + + public List getPowertoolList(ItemStack stack) + { + Map tools = (Map)config.getProperty("powertools"); + List commands; + + commands = (List)tools.get(stack.getTypeId()); + return commands; } public void setPowertool(ItemStack stack, String command) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java index 90f4803ca..3f56772f4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java @@ -30,8 +30,8 @@ public class Commandpowertool extends EssentialsCommand { if (command.equalsIgnoreCase("list")) { - String powertools = user.getPowertool(is); - if (powertools == null) + List powertools = user.getPowertool(is); + if (powertools == null || powertools.empty()) { user.sendMessage(Util.format("powerToolListEmpty", itemName)); } diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 031accc27..d8a772a3a 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -204,7 +204,7 @@ commands: aliases: [pong,eping,epong] powertool: description: Assigns a command to the item in hand, {player} will be replaced by the name of the player that you click. - usage: / [a:r:][command] + usage: / [list|a:|r:][command] aliases: [pt,epowertool,ept] ptime: description: Adjust player's client time. Add @ prefix to fix.