2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-09-28 16:21:16 +00:00
|
|
|
import com.earth2me.essentials.ChargeException;
|
2013-10-16 19:59:39 +00:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2011-12-08 02:21:10 +00:00
|
|
|
import com.earth2me.essentials.Trade;
|
2011-03-19 22:39:51 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2014-02-02 16:07:32 +00:00
|
|
|
import net.ess3.api.MaxMoneyException;
|
2011-11-18 17:42:26 +00:00
|
|
|
import org.bukkit.Server;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandpay extends EssentialsLoopCommand {
|
|
|
|
BigDecimal amount;
|
|
|
|
|
|
|
|
public Commandpay() {
|
|
|
|
super("pay");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length < 2) {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
|
|
|
|
String stringAmount = args[1].replaceAll("[^0-9\\.]", "");
|
|
|
|
|
|
|
|
if (stringAmount.length() < 1) {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
|
|
|
|
amount = new BigDecimal(stringAmount);
|
|
|
|
loopOnlinePlayers(server, user.getSource(), false, user.isAuthorized("essentials.pay.multiple"), args[0], args);
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws ChargeException {
|
|
|
|
User user = ess.getUser(sender.getPlayer());
|
|
|
|
try {
|
|
|
|
user.payUser(player, amount);
|
|
|
|
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess);
|
|
|
|
} catch (MaxMoneyException ex) {
|
|
|
|
sender.sendMessage(tl("maxMoney"));
|
|
|
|
}
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|