Update setworth to allow /setworth <price> ingame

Allow /setworth to be used from console.
This commit is contained in:
KHobbits 2012-03-11 23:59:59 +00:00
parent a40c936bcf
commit 8dcd591beb
2 changed files with 30 additions and 3 deletions

View File

@ -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"));
}
}

View File

@ -295,7 +295,7 @@ commands:
aliases: [createwarp,esetwarp]
setworth:
description: Set the sell value of an item.
usage: /<command> <itemname|id> <price>
usage: /<command> [itemname|id] <price>
aliases: [esetworth]
socialspy:
description: Toggles if you can see msg/mail commands in chat.