diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index ce3e83980..3c074657f 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -19,9 +19,9 @@ public class Worth implements IConf public double getPrice(ItemStack itemStack) { - double result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase()+"."+itemStack.getData().getData(), Double.NaN); + double result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getData().getData(), Double.NaN); if (Double.isNaN(result)) { - result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase(), Double.NaN); + result = config.getDouble("worth."+itemStack.getType().toString().toLowerCase().replace("_", ""), Double.NaN); } if (Double.isNaN(result)) { result = config.getDouble("worth-"+itemStack.getTypeId(), 0.0); @@ -32,9 +32,9 @@ public class Worth implements IConf public void setPrice(ItemStack itemStack, double price) { if (itemStack.getType().getData() == null) { - config.setProperty("worth." + itemStack.getType().toString().toLowerCase(), price); + config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price); } else { - config.setProperty("worth." + itemStack.getType().toString().toLowerCase()+"."+itemStack.getData().getData(), price); + config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getData().getData(), price); } config.removeProperty("worth-"+itemStack.getTypeId()); config.save(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index 66e1be715..aee5041c2 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -18,30 +18,27 @@ public class Commandworth extends EssentialsCommand 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(); + if (args.length > 0) { + is = ItemDb.get(args[0]); } try { - if (args.length > 1) amount = Integer.parseInt(args[1]); + if (args.length > 1) { + amount = Integer.parseInt(args[1]); + } } catch (NumberFormatException ex) { amount = 64; } + is.setAmount(amount); double worth = Essentials.getWorth().getPrice(is); user.charge(this); - user.sendMessage("§7Stack of " + id + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)"); + user.sendMessage("§7Stack of " + is.getType().toString().toLowerCase().replace("_", "") + " worth §c$" + (worth * amount) + "§7 (" + amount + " item(s) at $" + worth + " each)"); } }