From 851c564e6775bbfdcfed127a7dde60ed14e5d679 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 27 May 2012 17:36:04 +1000 Subject: Don't allow armor to be used as a hat. --- .../com/earth2me/essentials/commands/Commandhat.java | 17 +++++++++++------ Essentials/src/messages.properties | 1 + Essentials/src/messages_cs.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_es.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_it.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/messages_pl.properties | 1 + Essentials/src/messages_pt.properties | 1 + 12 files changed, 22 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 { diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 84f4734e6..ea765213f 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -431,3 +431,4 @@ year=year years=years youAreHealed=\u00a77You have been healed. youHaveNewMail=\u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index dc64cb5e1..0265dab23 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -434,3 +434,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 076e5a956..380f04ced 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 6aa916542..5558ab978 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 84f4734e6..ea765213f 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -431,3 +431,4 @@ year=year years=years youAreHealed=\u00a77You have been healed. youHaveNewMail=\u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index aa735be29..56016f96e 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 9be26fa00..a101355ba 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 0bf67362e..19659a76a 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 7a6827d2f..17aa50829 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index b7740ac12..1ca936863 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 9e91d1aa3..2a6260f1c 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -431,3 +431,4 @@ vanished=\u00a7aYou have now been vanished. tps=Current TPS = {0} hatPlaced=\u00a7eEnjoy your new hat! hatFail=\u00a7cYou must have something to wear in your hand. +hatArmor=\u00a7cError, you cannot use armor as a hat! -- cgit v1.2.3