Skip to content
Browse files

Allow your hat to be removed with /hat remove

  • Loading branch information...
1 parent d1a1559 commit 641a4b9dffbf86f64c6aaf1518bd14e0a342d622 kukelekuuk00 committed Jun 15, 2012
View
51 Essentials/src/com/earth2me/essentials/commands/Commandhat.java
@@ -2,6 +2,7 @@
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
+import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
@@ -18,24 +19,46 @@ public Commandhat()
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
- if (user.getItemInHand().getType() != Material.AIR)
+ if (args.length < 1)
{
- final ItemStack hand = user.getItemInHand();
- if (hand.getType().getMaxDurability() == 0)
+ if (user.getItemInHand().getType() != Material.AIR)
{
- 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"));
+ final ItemStack hand = user.getItemInHand();
+ 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
+ {
+ user.sendMessage(_("hatFail"));
}
}
- else
+ if (args.length > 0)
{
- user.sendMessage(_("hatFail"));
+ 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"));
+ }
+ }
}
}
-}
+}
View
2 Essentials/src/messages.properties
@@ -115,8 +115,10 @@ godDisabledFor=disabled for {0}
godEnabledFor=enabled for {0}
godMode=\u00a77God mode {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
+hatRemoved=\u00a7eYour hat has been removed.
haveBeenReleased=\u00a77You have been released
heal=\u00a77You have been healed.
healOther=\u00a77Healed {0}.
View
1 Essentials/src/messages_cs.properties
@@ -118,6 +118,7 @@ godDisabledFor=zakazan pro {0}
godEnabledFor=povolen pro {0}
godMode=\u00a77God mode {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77Byl jsi uvolnen
View
1 Essentials/src/messages_da.properties
@@ -115,6 +115,7 @@ godDisabledFor=deaktiveret for {0}
godEnabledFor=aktiveret for {0}
godMode=\u00a77Gud mode {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77Du er blevet l\u00f8sladt
View
1 Essentials/src/messages_de.properties
@@ -115,6 +115,7 @@ godDisabledFor=deaktiviert f\u00fcr {0}
godEnabledFor=aktiviert f\u00fcr {0}
godMode=\u00a77Unsterblichkeit {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cSie tragen keinen Hut.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77Du wurdest frei gelassen.
View
1 Essentials/src/messages_en.properties
@@ -115,6 +115,7 @@ godDisabledFor=disabled for {0}
godEnabledFor=enabled for {0}
godMode=\u00a77God mode {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77You have been released
View
1 Essentials/src/messages_es.properties
@@ -115,6 +115,7 @@ godDisabledFor=Desactivado para {0}
godEnabledFor=Activado para {0}
godMode=\u00a77Modo Dios {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77Has sido liberado
View
1 Essentials/src/messages_fr.properties
@@ -115,6 +115,7 @@ godDisabledFor=d\u00e9sactiv\u00e9 pour {0}
godEnabledFor=activ\u00e9 pour {0}
godMode=\u00a77Mode Dieu {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77Vous avez \u00e9t\u00e9 lib\u00e9r\u00e9.
View
1 Essentials/src/messages_it.properties
@@ -115,6 +115,7 @@ godDisabledFor=God disabilitato per {0}
godEnabledFor=God abilitato per {0}
godMode=\u00a77Modalita'' God {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77Sei stato scarcerato.
View
1 Essentials/src/messages_nl.properties
@@ -115,6 +115,7 @@ godDisabledFor=uitgeschakeld voor {0}
godEnabledFor=ingeschakeld voor {0}
godMode=\u00a77God mode {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cJe draagt geen hoed.
hatFail=\u00a7cYou must have something to wear in your hand.
hatPlaced=\u00a7eEnjoy your new hat!
haveBeenReleased=\u00a77Je bent bevrijdt
View
1 Essentials/src/messages_pl.properties
@@ -115,6 +115,7 @@ godDisabledFor=Godmode wylaczony dla {0}.
godEnabledFor=Godmode wlaczony dla {0}.
godMode=\u00a77Godmode {0}.
hatArmor=\u00a7cError, you cannot use this item as a hat!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cMusisz cos trzymac w dloni.
hatPlaced=\u00a7eCiesz sie nowym kapeluszem!
haveBeenReleased=\u00a77Zostales wypuszczony.
View
1 Essentials/src/messages_pt.properties
@@ -115,6 +115,7 @@ godDisabledFor=desativado para {0}
godEnabledFor=ativado para {0}
godMode=\u00a77Modo Deus {0}.
hatArmor=\u00a7cDe erro, voce nao pode usar este item como um chapeu!
+hatEmpty=\u00a7cYou are not wearing a hat.
hatFail=\u00a7cVoce deve ter algo para vestir na sua mao.
hatPlaced=\u00a7eAproveite o seu novo chapeu!
haveBeenReleased=\u00a77Voc\u00ea foi liberado.

0 comments on commit 641a4b9

Please sign in to comment.
Something went wrong with that request. Please try again.