From 96eb9c5db70a94fba572b12026939d18ffa4c21d Mon Sep 17 00:00:00 2001 From: kukelekuuk00 Date: Wed, 30 May 2012 13:42:38 +0200 Subject: [PATCH 1/4] added /dura a durability check --- .../commands/Commanddurability.java | 42 +++++++++++++++++++ Essentials/src/messages.properties | 2 + Essentials/src/plugin.yml | 4 ++ 3 files changed, 48 insertions(+) create mode 100644 Essentials/src/com/earth2me/essentials/commands/Commanddurability.java diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java b/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java new file mode 100644 index 000000000..548499c9d --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java @@ -0,0 +1,42 @@ +package com.earth2me.essentials.commands; + +import static com.earth2me.essentials.I18n._; +import org.bukkit.Material; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class Commanddurability extends EssentialsCommand +{ + public int durability; + public int maxuses; + + public Commanddurability() + { + super("durability"); + } + + @Override + protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + { + ItemStack itemStack = ((Player)sender).getItemInHand(); + maxuses = itemStack.getType().getMaxDurability(); + durability = ((itemStack.getType().getMaxDurability() + 1) - itemStack.getDurability()); + if (itemStack.getType() != Material.AIR) + { + if (maxuses != 0) + { + sender.sendMessage(_("durability", Integer.toString(durability))); + } + else + { + sender.sendMessage(_("notATool")); + } + } + else + { + sender.sendMessage(_("nothingInHand")); + } + } +} \ No newline at end of file diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index ea765213f..d94160ba6 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -73,6 +73,7 @@ disabledToSpawnMob=Spawning this mob was disabled in the config file. dontMoveMessage=\u00a77Teleportation will commence in {0}. Don''t move. downloadingGeoIp=Downloading GeoIP database ... this might take a while (country: 0.6 MB, city: 20MB) duplicatedUserdata=Duplicated userdata: {0} and {1} +durability=\u00a77This tool has \u00a7c{0}\u00a77 uses left enableUnlimited=\u00a77Giving unlimited amount of {0} to {1}. enabled=enabled enchantmentApplied = \u00a77The enchantment {0} has been applied to your item in hand. @@ -247,6 +248,7 @@ noWarpsDefined=No warps defined none=none notAllowedToQuestion=\u00a7cYou are not authorized to use question. notAllowedToShout=\u00a7cYou are not authorized to shout. +notATool=\u00a7cThis item is not a tool. notEnoughExperience=You do not have enough experience. notEnoughMoney=You do not have sufficient funds. notRecommendedBukkit= * ! * Bukkit version is not the recommended build for Essentials. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 8cacc0c11..9a4412b07 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -79,6 +79,10 @@ commands: description: States current depth, relative to sea level. usage: /depth aliases: [edepth] + durability: + description: Shows the uses an item has left. + usage: / + aliases: [dura] eco: description: Manages the server economy. usage: / From 98de950ae2b7f218c3991414e3ba96e7b60e7d13 Mon Sep 17 00:00:00 2001 From: kukelekuuk00 Date: Sat, 2 Jun 2012 00:36:27 +0200 Subject: [PATCH 2/4] some more aliases for /durability --- Essentials/src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 9a4412b07..c1af012d4 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -82,7 +82,7 @@ commands: durability: description: Shows the uses an item has left. usage: / - aliases: [dura] + aliases: [edura,dura,edurability] eco: description: Manages the server economy. usage: / From 63680b49111ebb38ad1c8050a353f810b29e07e6 Mon Sep 17 00:00:00 2001 From: kukelekuuk00 Date: Sat, 9 Jun 2012 23:06:09 +0200 Subject: [PATCH 3/4] DERP --- .../essentials/commands/Commanddurability.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java b/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java index 548499c9d..873f6f259 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java @@ -1,10 +1,9 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.User; import org.bukkit.Material; import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class Commanddurability extends EssentialsCommand @@ -18,25 +17,25 @@ public class Commanddurability extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - ItemStack itemStack = ((Player)sender).getItemInHand(); + ItemStack itemStack = user.getItemInHand(); maxuses = itemStack.getType().getMaxDurability(); durability = ((itemStack.getType().getMaxDurability() + 1) - itemStack.getDurability()); if (itemStack.getType() != Material.AIR) { if (maxuses != 0) { - sender.sendMessage(_("durability", Integer.toString(durability))); + user.sendMessage(_("durability", Integer.toString(durability))); } else { - sender.sendMessage(_("notATool")); + user.sendMessage(_("notATool")); } } else { - sender.sendMessage(_("nothingInHand")); + user.sendMessage(_("nothingInHand")); } } } \ No newline at end of file From 62812e1e3a406b28c506fdb6aef5334f343c8b5c Mon Sep 17 00:00:00 2001 From: kukelekuuk00 Date: Sun, 10 Jun 2012 14:19:03 +0200 Subject: [PATCH 4/4] DERP #2 --- .../src/com/earth2me/essentials/commands/Commanddurability.java | 2 +- Essentials/src/messages.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java b/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java index 873f6f259..130164443 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java @@ -30,7 +30,7 @@ public class Commanddurability extends EssentialsCommand } else { - user.sendMessage(_("notATool")); + user.sendMessage(_("noDurability")); } } else diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index d94160ba6..2dbfbce87 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -229,6 +229,7 @@ noAccessCommand=\u00a7cYou do not have access to that command. noAccessPermission=\u00a7cYou do not have permission to access that {0}. noBreakBedrock=You are not allowed to destroy bedrock. noDestroyPermission=\u00a7cYou do not have permission to destroy that {0}. +noDurability=\u00a7cThis item does not have a durability. noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHelpFound=\u00a7cNo matching commands. noHomeSet=You have not set a home. @@ -248,7 +249,6 @@ noWarpsDefined=No warps defined none=none notAllowedToQuestion=\u00a7cYou are not authorized to use question. notAllowedToShout=\u00a7cYou are not authorized to shout. -notATool=\u00a7cThis item is not a tool. notEnoughExperience=You do not have enough experience. notEnoughMoney=You do not have sufficient funds. notRecommendedBukkit= * ! * Bukkit version is not the recommended build for Essentials.