TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java

49 lines
1.4 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FloatUtil;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
2015-04-15 04:06:16 +00:00
import static com.earth2me.essentials.I18n.tl;
2015-04-15 04:06:16 +00:00
public class Commandsetworth extends EssentialsCommand {
public Commandsetworth() {
super("setworth");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) {
throw new NotEnoughArgumentsException();
}
ItemStack stack;
String price;
if (args.length == 1) {
stack = user.getBase().getInventory().getItemInHand();
price = args[0];
} else {
stack = ess.getItemDb().get(args[0]);
price = args[1];
}
ess.getWorth().setPrice(stack, FloatUtil.parseDouble(price));
2015-04-15 04:06:16 +00:00
user.sendMessage(tl("worthSet"));
}
@Override
public void run(final Server server, final CommandSource 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, FloatUtil.parseDouble(args[1]));
2015-04-15 04:06:16 +00:00
sender.sendMessage(tl("worthSet"));
}
}