2011-12-05 22:25:54 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2012-06-10 17:31:28 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
|
|
|
import org.bukkit.Material;
|
2011-12-05 22:25:54 +00:00
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2011-12-06 21:58:44 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2011-12-05 22:25:54 +00:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
|
2011-12-06 21:58:44 +00:00
|
|
|
public class Commanditemdb extends EssentialsCommand
|
2011-12-05 22:25:54 +00:00
|
|
|
{
|
2011-12-06 21:58:44 +00:00
|
|
|
public Commanditemdb()
|
2011-12-05 22:25:54 +00:00
|
|
|
{
|
2012-01-14 15:04:16 +00:00
|
|
|
super("itemdb");
|
2011-12-05 22:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
|
|
|
{
|
2011-12-06 21:58:44 +00:00
|
|
|
ItemStack itemStack = null;
|
2011-12-05 22:25:54 +00:00
|
|
|
if (args.length < 1)
|
|
|
|
{
|
2011-12-06 21:58:44 +00:00
|
|
|
if (sender instanceof Player)
|
|
|
|
{
|
|
|
|
itemStack = ((Player)sender).getItemInHand();
|
|
|
|
}
|
|
|
|
if (itemStack == null)
|
|
|
|
{
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
itemStack = ess.getItemDb().get(args[0]);
|
2011-12-05 22:25:54 +00:00
|
|
|
}
|
|
|
|
sender.sendMessage(itemStack.getType().toString() + "- " + itemStack.getTypeId() + ":" + Integer.toString(itemStack.getData().getData()));
|
2012-06-10 17:33:07 +00:00
|
|
|
|
2012-06-10 17:31:28 +00:00
|
|
|
if (itemStack.getType() != Material.AIR)
|
|
|
|
{
|
2012-06-10 17:33:07 +00:00
|
|
|
int maxuses = itemStack.getType().getMaxDurability();
|
|
|
|
int durability = ((itemStack.getType().getMaxDurability() + 1) - itemStack.getDurability());
|
2012-06-10 17:31:28 +00:00
|
|
|
if (maxuses != 0)
|
|
|
|
{
|
|
|
|
sender.sendMessage(_("durability", Integer.toString(durability)));
|
|
|
|
}
|
|
|
|
}
|
2011-12-05 22:25:54 +00:00
|
|
|
}
|
|
|
|
}
|