mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-10-03 15:24:21 +00:00
6427a93d14
We now first test, if the user could pay it, do the stuff and then charge him. If the command throws an exception, the user will not be charged.
37 lines
1,023 B
Java
37 lines
1,023 B
Java
package com.earth2me.essentials.commands;
|
|
|
|
import org.bukkit.Server;
|
|
import com.earth2me.essentials.User;
|
|
import com.earth2me.essentials.Util;
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
|
public class Commandbalance extends EssentialsCommand
|
|
{
|
|
public Commandbalance()
|
|
{
|
|
super("balance");
|
|
}
|
|
|
|
@Override
|
|
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
|
{
|
|
if (args.length < 1)
|
|
{
|
|
throw new NotEnoughArgumentsException();
|
|
}
|
|
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
|
}
|
|
|
|
@Override
|
|
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
|
{
|
|
double bal = (args.length < 1
|
|
|| !(user.isAuthorized("essentials.balance.others")
|
|
|| user.isAuthorized("essentials.balance.other"))
|
|
? user
|
|
: getPlayer(server, args, 0, true)).getMoney();
|
|
user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess)));
|
|
}
|
|
}
|