From d2bf35dac28529ad03823c749820f064ea36720c Mon Sep 17 00:00:00 2001 From: okamosy Date: Sat, 10 Sep 2011 10:39:35 +0100 Subject: [PATCH] added a clearall option to powertools --- Essentials/src/com/earth2me/essentials/UserData.java | 6 ++++++ .../essentials/commands/Commandpowertool.java | 11 ++++++++++- Essentials/src/messages.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_nl.properties | 1 + 8 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index e5c7385b2..30bb7a2b8 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -240,6 +240,12 @@ public abstract class UserData extends PlayerExtension implements IConf } + public void clearAllPowertools() { + powertools.clear(); + config.setProperty("powertools", powertools); + config.save(); + } + public List getPowertool(ItemStack stack) { return (List)powertools.get(stack.getTypeId()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java index b4977167f..c9e8dea58 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java @@ -19,6 +19,16 @@ public class Commandpowertool extends EssentialsCommand @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { + String command = getFinalArg(args, 0); + + // check to see if this is a clear all command + if(command != null && command.equalsIgnoreCase("clearall")) + { + user.clearAllPowertools(); + user.sendMessage(Util.i18n("powerToolClearAll")); + return; + } + final ItemStack itemStack = user.getItemInHand(); if (itemStack == null || itemStack.getType() == Material.AIR) { @@ -26,7 +36,6 @@ public class Commandpowertool extends EssentialsCommand } final String itemName = itemStack.getType().toString().toLowerCase().replaceAll("_", " "); - String command = getFinalArg(args, 0); List powertools = user.getPowertool(itemStack); if (command != null && !command.isEmpty()) { diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 775113e0f..b7e215c10 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -244,6 +244,7 @@ possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}. powerToolAir = Command can''t be attached to air. powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolClearAll = All powertool commands have been cleared. powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. powerToolListEmpty = {0} has no commands assigned. powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 7c7258188..114b63f7e 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -243,6 +243,7 @@ possibleWorlds = \u00a77Mulige verdener er numrene 0 igennem {0}. powerToolAir = Kommando kan ikke blive tildelt luft. powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolClearAll = All powertool commands have been cleared. powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. powerToolListEmpty = {0} has no commands assigned. powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 047e3df51..45e6a50d2 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -243,6 +243,7 @@ possibleWorlds = \u00a77M\u00f6gliche Welten sind nummeriet von 0 bis {0}. powerToolAir = Befehl kann nicht mit Luft verbunden werden. powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolClearAll = All powertool commands have been cleared. powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. powerToolListEmpty = {0} has no commands assigned. powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 323228015..25064cbc7 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -243,6 +243,7 @@ possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}. powerToolAir = Command can''t be attached to air. powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolClearAll = All powertool commands have been cleared. powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. powerToolListEmpty = {0} has no commands assigned. powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 8934ea902..a2793cdd7 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -243,6 +243,7 @@ possibleWorlds = \u00a77Les mondes possibles sont les nombres 0 par {0}. powerToolAir = La commande ne peut pas \u00eatre attach\u00e9e \u00e0 l''air. powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolClearAll = All powertool commands have been cleared. powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. powerToolListEmpty = {0} has no commands assigned. powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 72478567f..4c96d800e 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -243,6 +243,7 @@ possibleWorlds = \u00a77Mogelijk zijn de werelden de nummer 0 tot en met {0}. powerToolAir = Command kan niet worden bevestigd aan lucht. powerToolAlreadySet = Command \u00a7c{0}\u00a7f is already assigned to {1}. powerToolAttach = \u00a7c{0}\u00a7f command assigned to {1}. +powerToolClearAll = All powertool commands have been cleared. powerToolList = {1} has the following commands: \u00a7c{0}\u00a7f. powerToolListEmpty = {0} has no commands assigned. powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}.