1.5.3
This commit is contained in:
parent
102711037e
commit
a7358d968d
76 changed files with 855 additions and 523 deletions
|
|
@ -20,18 +20,18 @@ public class SendMoney implements CommandExecutor {
|
|||
sender.sendMessage(ChatColor.RED + "Usage: /sendMoney <player> <amount>");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Player target = GrimmsServer.instance.getServer().getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player '" + args[0] + "' not found or not online.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (target.getName().equals(sender.getName())) {
|
||||
sender.sendMessage(ChatColor.RED + "You cannot send money to yourself.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
double amount;
|
||||
try {
|
||||
amount = Double.parseDouble(args[1]);
|
||||
|
|
@ -39,24 +39,24 @@ public class SendMoney implements CommandExecutor {
|
|||
sender.sendMessage(ChatColor.RED + "Invalid amount: '" + args[1] + "'. Must be a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (amount <= 0) {
|
||||
sender.sendMessage(ChatColor.RED + "You cannot send zero or negative money.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
PlayerStats sending = PlayerStats.getPlayerStats((Player) sender);
|
||||
double currentBalance = sending.getStat("money", Double.class);
|
||||
|
||||
|
||||
if (currentBalance < amount) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have enough money. Current balance: " + ChatColor.GOLD + Shared.formatNumber(currentBalance));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
PlayerStats receiving = PlayerStats.getPlayerStats(target);
|
||||
sending.changeStat("money", -amount);
|
||||
receiving.changeStat("money", amount);
|
||||
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "You have sent " + ChatColor.GOLD + Shared.formatNumber(amount) + ChatColor.GREEN + " to " + ChatColor.YELLOW + target.getName());
|
||||
target.sendMessage(ChatColor.GREEN + "You have received " + ChatColor.GOLD + Shared.formatNumber(amount) + ChatColor.GREEN + " from " + ChatColor.YELLOW + sender.getName());
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue