TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
snowleo 528aa3d6cf [trunk] Cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1209 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-04-16 05:59:59 +00:00

47 lines
1.1 KiB
Java

package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.User;
import org.bukkit.inventory.ItemStack;
public class Commandworth extends EssentialsCommand
{
public Commandworth()
{
super("worth");
}
@Override
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
{
ItemStack is = user.getInventory().getItemInHand();
int id = is.getTypeId();
int amount = is.getAmount();
try
{
if (args.length > 0) id = Integer.parseInt(args[0]);
}
catch (NumberFormatException ex)
{
id = ItemDb.get(args[0]).getTypeId();
}
try
{
if (args.length > 1) amount = Integer.parseInt(args[1]);
}
catch (NumberFormatException ex)
{
amount = 64;
}
int worth = Essentials.getWorth().getPrice(String.valueOf(id));
user.charge(this);
user.sendMessage("§7Stack of " + id + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)");
}
}