diff options
author | okamosy <okamosy@gmail.com> | 2011-08-21 17:52:58 +0100 |
---|---|---|
committer | okamosy <okamosy@gmail.com> | 2011-08-21 17:52:58 +0100 |
commit | 43d7fb367b9d16fd7c7efc2ecf002a3bf91fb747 (patch) | |
tree | 5e8a3cfe60b3eee7026bf2ad21e46c7eb4be630e | |
parent | 6f88e7bb986229b4adfd5494f164ec009ce34116 (diff) | |
download | Essentials-43d7fb367b9d16fd7c7efc2ecf002a3bf91fb747.tar Essentials-43d7fb367b9d16fd7c7efc2ecf002a3bf91fb747.tar.gz Essentials-43d7fb367b9d16fd7c7efc2ecf002a3bf91fb747.tar.lz Essentials-43d7fb367b9d16fd7c7efc2ecf002a3bf91fb747.tar.xz Essentials-43d7fb367b9d16fd7c7efc2ecf002a3bf91fb747.zip |
converted powertool config to use lists instead of tokenized strings
Powertool update
4 files changed, 32 insertions, 12 deletions
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<String> 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<Integer, String> powertools; + private Map<Integer, Object> powertools; @SuppressWarnings("unchecked") - private Map<Integer, String> getPowertools() + private Map<Integer, Object> getPowertools() { Object o = config.getProperty("powertools"); + if (o instanceof Map) { - return (Map<Integer, String>)o; + for(Map.Entry<Integer, Object> entry : ((Map<Integer, Object>)o).entrySet()) + { + if(entry.getValue() instanceof String) + { + List<String> temp = new ArrayList<String>(); + temp.add((String)entry.getValue()); + ((Map<Integer, Object>)o).put(entry.getKey(), temp); + } + } + + return (Map<Integer, Object>)o; } else { - return new HashMap<Integer, String>(); + return new HashMap<Integer, Object>(); } } - public String getPowertool(ItemStack stack) + public List<String> getPowertool(ItemStack stack) + { + return (List<String>)powertools.get(stack.getTypeId()); + } + + public List<String> getPowertoolList(ItemStack stack) { - return powertools.get(stack.getTypeId()); + Map<String, Object> tools = (Map<String, Object>)config.getProperty("powertools"); + List<String> commands; + + commands = (List<String>)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<String> 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: /<command> [a:r:][command] <arguments> + usage: /<command> [list|a:|r:][command] <arguments> aliases: [pt,epowertool,ept] ptime: description: Adjust player's client time. Add @ prefix to fix. |