This commit is contained in:
kukelekuuk00 2012-06-09 23:06:09 +02:00
parent 98de950ae2
commit 63680b4911

View file

@ -1,10 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class Commanddurability extends EssentialsCommand
@ -18,25 +17,25 @@ public class Commanddurability extends EssentialsCommand
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
ItemStack itemStack = ((Player)sender).getItemInHand();
ItemStack itemStack = user.getItemInHand();
maxuses = itemStack.getType().getMaxDurability();
durability = ((itemStack.getType().getMaxDurability() + 1) - itemStack.getDurability());
if (itemStack.getType() != Material.AIR)
{
if (maxuses != 0)
{
sender.sendMessage(_("durability", Integer.toString(durability)));
user.sendMessage(_("durability", Integer.toString(durability)));
}
else
{
sender.sendMessage(_("notATool"));
user.sendMessage(_("notATool"));
}
}
else
{
sender.sendMessage(_("nothingInHand"));
user.sendMessage(_("nothingInHand"));
}
}
}