Merge pull request #82 from kukelekuuk00/master

Allow your hat to be removed with /hat remove
This commit is contained in:
Iaccidentally 2012-06-15 13:44:51 -07:00
commit d63ad6fc0c
12 changed files with 49 additions and 14 deletions

View File

@ -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 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"));
}
}
if (args.length > 0)
{
if (args[0].contains("remove"))
{
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"));
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"));
}
}
}
else
{
user.sendMessage(_("hatFail"));
}
}
}
}

View File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -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 File

@ -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.