diff options
author | Iaccidentally <coryhuckaby@gmail.com> | 2012-06-15 13:44:51 -0700 |
---|---|---|
committer | Iaccidentally <coryhuckaby@gmail.com> | 2012-06-15 13:44:51 -0700 |
commit | 27028d2c0e8ba1c6a4c5771197b5aa6716912cf8 (patch) | |
tree | a94ac685ec788a4504da9c93fa298bffdbb49e7e | |
parent | 44696316eaae18f0fe2de5335535a7ef737a9366 (diff) | |
parent | 13fa4bcb5f9b979b7126a8d6d8b86c411a87388f (diff) | |
download | Essentials-27028d2c0e8ba1c6a4c5771197b5aa6716912cf8.tar Essentials-27028d2c0e8ba1c6a4c5771197b5aa6716912cf8.tar.gz Essentials-27028d2c0e8ba1c6a4c5771197b5aa6716912cf8.tar.lz Essentials-27028d2c0e8ba1c6a4c5771197b5aa6716912cf8.tar.xz Essentials-27028d2c0e8ba1c6a4c5771197b5aa6716912cf8.zip |
Merge pull request #82 from kukelekuuk00/master
Allow your hat to be removed with /hat remove
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandhat.java | 51 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_cs.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_es.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_it.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_pl.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_pt.properties | 1 |
12 files changed, 49 insertions, 14 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java index ed82fd16d..f3133c324 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhat.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhat.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.commands; 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 class Commandhat extends EssentialsCommand @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")); + } + } } } -} +}
\ No newline at end of file diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 66c789ffd..6b69f043e 100644 --- a/Essentials/src/messages.properties +++ b/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}. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index ebe064d17..5ca542f16 100644 --- a/Essentials/src/messages_cs.properties +++ b/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 diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 955e8ed4c..575b24299 100644 --- a/Essentials/src/messages_da.properties +++ b/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 diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 89298e65f..afb8b1659 100644 --- a/Essentials/src/messages_de.properties +++ b/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. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 66c789ffd..672a6955f 100644 --- a/Essentials/src/messages_en.properties +++ b/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 diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 440032de5..5aa9676c7 100644 --- a/Essentials/src/messages_es.properties +++ b/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 diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 65024c9bd..817e3561b 100644 --- a/Essentials/src/messages_fr.properties +++ b/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. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index d3a6ab46d..582aae77b 100644 --- a/Essentials/src/messages_it.properties +++ b/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. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 43164040e..4d924bace 100644 --- a/Essentials/src/messages_nl.properties +++ b/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 diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index 8293dc317..3babd8f16 100644 --- a/Essentials/src/messages_pl.properties +++ b/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. diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 94ea4dc06..7ac628868 100644 --- a/Essentials/src/messages_pt.properties +++ b/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. |