summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandhat.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandhat.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandhat.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java
index 24d464275..ed82fd16d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java
@@ -21,12 +21,17 @@ public class Commandhat extends EssentialsCommand
if (user.getItemInHand().getType() != Material.AIR)
{
final ItemStack hand = user.getItemInHand();
- final PlayerInventory inv = user.getInventory();
- final ItemStack head = inv.getHelmet();
- inv.removeItem(hand);
- inv.setHelmet(hand);
- inv.setItemInHand(head);
- user.sendMessage(_("hatPlaced"));
+ if (hand.getType().getMaxDurability() == 0)
+ {
+ final PlayerInventory inv = user.getInventory();
+ final ItemStack head = inv.getHelmet();
+ inv.removeItem(hand);
+ inv.setHelmet(hand);
+ inv.setItemInHand(head);
+ user.sendMessage(_("hatPlaced"));
+ } else {
+ user.sendMessage(_("hatArmor"));
+ }
}
else
{