diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-06-10 10:22:42 -0700 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-06-10 10:22:42 -0700 |
commit | 2be265056735e0a16848a1b4ce41b357f37f8b5a (patch) | |
tree | c4422edcfa516caf3d96fbbb6f005fe04c69ef2c | |
parent | 2b083f7e2f646bd1f0cd46ec7d9339c6d14f82af (diff) | |
parent | b777ab58c92bc9f4eee13b41f23a9c4ad0bbbb9f (diff) | |
download | Essentials-2be265056735e0a16848a1b4ce41b357f37f8b5a.tar Essentials-2be265056735e0a16848a1b4ce41b357f37f8b5a.tar.gz Essentials-2be265056735e0a16848a1b4ce41b357f37f8b5a.tar.lz Essentials-2be265056735e0a16848a1b4ce41b357f37f8b5a.tar.xz Essentials-2be265056735e0a16848a1b4ce41b357f37f8b5a.zip |
Merge pull request #72 from kukelekuuk00/master
Durability command
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commanddurability.java | 41 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 2 | ||||
-rw-r--r-- | Essentials/src/plugin.yml | 4 |
3 files changed, 47 insertions, 0 deletions
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..130164443 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commanddurability.java @@ -0,0 +1,41 @@ +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.inventory.ItemStack;
+
+public class Commanddurability extends EssentialsCommand
+{
+ public int durability;
+ public int maxuses;
+
+ public Commanddurability()
+ {
+ super("durability");
+ }
+
+ @Override
+ protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
+ {
+ ItemStack itemStack = user.getItemInHand();
+ maxuses = itemStack.getType().getMaxDurability();
+ durability = ((itemStack.getType().getMaxDurability() + 1) - itemStack.getDurability());
+ if (itemStack.getType() != Material.AIR)
+ {
+ if (maxuses != 0)
+ {
+ user.sendMessage(_("durability", Integer.toString(durability)));
+ }
+ else
+ {
+ user.sendMessage(_("noDurability"));
+ }
+ }
+ else
+ {
+ user.sendMessage(_("nothingInHand"));
+ }
+ }
+}
\ No newline at end of file diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index ea765213f..2dbfbce87 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. @@ -228,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. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 8cacc0c11..c1af012d4 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: /<command> + aliases: [edura,dura,edurability] eco: description: Manages the server economy. usage: /<command> <give|take|reset> <player> <amount> |