diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-06-16 14:02:13 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-06-16 14:02:13 +0100 |
commit | af7e427545ed5b173e8fc6b0490f8917d68c5e4c (patch) | |
tree | 78061101e647e769c02f6ab698aad20fb33806e3 | |
parent | 4638c5ab5585adaa344f5d92bd9e77f31c76172a (diff) | |
download | Essentials-af7e427545ed5b173e8fc6b0490f8917d68c5e4c.tar Essentials-af7e427545ed5b173e8fc6b0490f8917d68c5e4c.tar.gz Essentials-af7e427545ed5b173e8fc6b0490f8917d68c5e4c.tar.lz Essentials-af7e427545ed5b173e8fc6b0490f8917d68c5e4c.tar.xz Essentials-af7e427545ed5b173e8fc6b0490f8917d68c5e4c.zip |
Avoid silent command failures on /hat (ie typing /hat fish will no longer silently return as if broken)
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandhat.java | 43 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandvanish.java | 2 |
2 files changed, 22 insertions, 23 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java index 8642da43a..5dd0fbb74 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java @@ -17,9 +17,25 @@ public class Commandhat extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (args.length < 1) + if (args.length > 0 && (args[0].contains("rem") || args[0].contains("off") || args[0].equalsIgnoreCase("0"))) + { + final PlayerInventory inv = user.getInventory(); + final ItemStack head = inv.getHelmet(); + if (head == null || head.getType() == Material.AIR) + { + user.sendMessage(_("hatEmpty")); + } + else + { + final ItemStack air = new ItemStack(Material.AIR); + inv.setHelmet(air); + InventoryWorkaround.addItem(user.getInventory(), true, head); + user.sendMessage(_("hatRemoved")); + } + } + else { if (user.getItemInHand().getType() != Material.AIR) { @@ -32,7 +48,9 @@ public class Commandhat extends EssentialsCommand inv.setHelmet(hand); inv.setItemInHand(head); user.sendMessage(_("hatPlaced")); - } else { + } + else + { user.sendMessage(_("hatArmor")); } } @@ -41,24 +59,5 @@ public class Commandhat extends EssentialsCommand user.sendMessage(_("hatFail")); } } - else - { - if (args[0].contains("remove")) - { - final PlayerInventory inv = user.getInventory(); - final ItemStack head = inv.getHelmet(); - if (head == null) - { - user.sendMessage(_("hatEmpty")); - } - else if (head.getType() != Material.AIR) - { - final ItemStack air = new ItemStack(Material.AIR); - inv.setHelmet(air); - InventoryWorkaround.addItem(user.getInventory(), true, head); - user.sendMessage(_("hatRemoved")); - } - } - } } }
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java index c81a96912..dca489fea 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandvanish.java @@ -14,7 +14,7 @@ public class Commandvanish extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { |