2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 19:59:39 +00:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2011-03-19 22:39:51 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.NumberUtil;
|
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;
|
2017-06-11 00:17:43 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2015-04-15 04:06:16 +00:00
|
|
|
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandbalance extends EssentialsCommand {
|
|
|
|
public Commandbalance() {
|
|
|
|
super("balance");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length < 1) {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
|
|
|
|
User target = getPlayer(server, args, 0, true, true);
|
|
|
|
sender.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
|
|
|
|
final User target = getPlayer(server, args, 0, true, true);
|
|
|
|
final BigDecimal bal = target.getMoney();
|
|
|
|
user.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(bal, ess)));
|
|
|
|
} else if (args.length < 2) {
|
|
|
|
final BigDecimal bal = user.getMoney();
|
|
|
|
user.sendMessage(tl("balance", NumberUtil.displayCurrency(bal, ess)));
|
|
|
|
} else {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
}
|
2017-06-11 00:17:43 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
|
|
|
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
|
|
|
|
return getPlayers(server, user);
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(Server server, CommandSource sender, String commandLabel, String[] args) {
|
|
|
|
if (args.length == 1) {
|
|
|
|
return getPlayers(server, sender);
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|