diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java index 1d236b70a..734d9244d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; import org.bukkit.Server; +import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; @@ -21,8 +22,34 @@ public class Commandsetworth extends EssentialsCommand throw new NotEnoughArgumentsException(); } - ItemStack stack = ess.getItemDb().get(args[0]); - ess.getWorth().setPrice(stack, Double.parseDouble(args[1])); + ItemStack stack; + String price; + + if (args.length == 1) + { + stack = user.getInventory().getItemInHand(); + price = args[0]; + } + else + { + stack = ess.getItemDb().get(args[0]); + price = args[1]; + } + + ess.getWorth().setPrice(stack, Double.parseDouble(price)); user.sendMessage(_("worthSet")); } + + @Override + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { + if (args.length < 2) + { + throw new NotEnoughArgumentsException(); + } + + ItemStack stack = ess.getItemDb().get(args[0]); + ess.getWorth().setPrice(stack, Double.parseDouble(args[1])); + sender.sendMessage(_("worthSet")); + } } diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 714abde4b..27541d782 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -295,7 +295,7 @@ commands: aliases: [createwarp,esetwarp] setworth: description: Set the sell value of an item. - usage: / + usage: / [itemname|id] aliases: [esetworth] socialspy: description: Toggles if you can see msg/mail commands in chat.