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

40 lines
1.1 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
2013-09-28 16:21:16 +00:00
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
2013-05-05 03:13:17 +00:00
import java.math.BigDecimal;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
2013-09-28 16:21:16 +00:00
import org.bukkit.command.CommandSender;
2013-09-28 16:21:16 +00:00
public class Commandpay extends EssentialsLoopCommand
{
2013-09-28 16:21:16 +00:00
BigDecimal amount;
public Commandpay()
{
super("pay");
}
@Override
2013-09-28 16:21:16 +00:00
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
}
2013-03-19 23:24:06 +00:00
2013-09-28 16:21:16 +00:00
amount = new BigDecimal(args[1].replaceAll("[^0-9\\.]", ""));
2013-10-05 01:41:08 +00:00
loopOnlinePlayers(server, user.getBase(), false, args[0], args);
2013-09-28 16:21:16 +00:00
}
2013-09-28 16:21:16 +00:00
@Override
protected void updatePlayer(final Server server, final CommandSender sender, final User player, final String[] args) throws ChargeException
{
User user = ess.getUser(sender);
user.payUser(player, amount);
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess);
}
}