mirror of
https://github.com/AppleDash/SaneEconomy.git
synced 2024-11-26 12:05:46 +01:00
Improve /ecoadmin output and change default config.
This commit is contained in:
parent
ac956f7a87
commit
55195eb0a2
@ -53,7 +53,7 @@ public class EconomyAdminCommand extends SaneEconomyCommand {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(sTargetPlayer);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
MessageUtils.sendMessage(sender, "That player is not online!");
|
||||
MessageUtils.sendMessage(sender, "That player is not online.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -61,12 +61,11 @@ public class EconomyAdminCommand extends SaneEconomyCommand {
|
||||
|
||||
try {
|
||||
amount = Double.valueOf(sAmount);
|
||||
} catch (NumberFormatException e) {
|
||||
MessageUtils.sendMessage(sender, "%s is not a number!", sAmount);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (amount < 0) {
|
||||
if (amount < 0) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
MessageUtils.sendMessage(sender, "%s is not a positive number.", sAmount);
|
||||
return true;
|
||||
}
|
||||
@ -74,12 +73,20 @@ public class EconomyAdminCommand extends SaneEconomyCommand {
|
||||
if (subCommand.equalsIgnoreCase("give")) {
|
||||
double newAmount = SaneEconomy.getInstance().getEconomyManager().addBalance(targetPlayer, amount);
|
||||
|
||||
MessageUtils.sendMessage(sender, "New balance for %s is %s", sTargetPlayer, SaneEconomy.getInstance().getEconomyManager().getCurrency().formatAmount(newAmount));
|
||||
MessageUtils.sendMessage(sender, "Added %s to %s. Their balance is now %s.",
|
||||
SaneEconomy.getInstance().getEconomyManager().getCurrency().formatAmount(amount),
|
||||
sTargetPlayer,
|
||||
SaneEconomy.getInstance().getEconomyManager().getCurrency().formatAmount(newAmount)
|
||||
);
|
||||
return true;
|
||||
} else if (subCommand.equalsIgnoreCase("take")) {
|
||||
double newAmount = SaneEconomy.getInstance().getEconomyManager().subtractBalance(targetPlayer, amount);
|
||||
|
||||
MessageUtils.sendMessage(sender, "New balance for %s is %s", sTargetPlayer, SaneEconomy.getInstance().getEconomyManager().getCurrency().formatAmount(newAmount));
|
||||
MessageUtils.sendMessage(sender, "Took %s from %s. Their balance is now %s.",
|
||||
SaneEconomy.getInstance().getEconomyManager().getCurrency().formatAmount(amount),
|
||||
sTargetPlayer,
|
||||
SaneEconomy.getInstance().getEconomyManager().getCurrency().formatAmount(newAmount)
|
||||
);
|
||||
return true;
|
||||
} else if (subCommand.equalsIgnoreCase("set")) {
|
||||
SaneEconomy.getInstance().getEconomyManager().setBalance(targetPlayer, amount);
|
||||
|
@ -22,6 +22,7 @@ public class JoinQuitListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent evt) {
|
||||
Player player = evt.getPlayer();
|
||||
double startBalance = plugin.getConfig().getDouble("economy.start-balance", 0.0D);
|
||||
|
||||
/* A starting balance is configured AND they haven't been given it yet. */
|
||||
if (startBalance > 0 && !plugin.getEconomyManager().accountExists(player)) {
|
||||
plugin.getEconomyManager().setBalance(player, startBalance);
|
||||
|
@ -9,8 +9,15 @@ import org.bukkit.command.CommandSender;
|
||||
* Blackjack is still best pony.
|
||||
*/
|
||||
public class MessageUtils {
|
||||
public static void sendMessage(CommandSender sender, String fmt, String... args) {
|
||||
String prefix = ChatColor.translateAlternateColorCodes('&', SaneEconomy.getInstance().getConfig().getString("chat.prefix", "[SaneEcon] "));;
|
||||
sender.sendMessage(prefix + String.format(fmt, args));
|
||||
/**
|
||||
* Send a formatted chat message to the given target.
|
||||
* This message will have the prefix defined in SaneEconomy's config file.
|
||||
* @param target Target CommandSender
|
||||
* @param fmt String#format format
|
||||
* @param args String#format args
|
||||
*/
|
||||
public static void sendMessage(CommandSender target, String fmt, String... args) {
|
||||
String prefix = ChatColor.translateAlternateColorCodes('&', SaneEconomy.getInstance().getConfig().getString("chat.prefix", ""));
|
||||
target.sendMessage(prefix + String.format(fmt, args));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ currency:
|
||||
format: '0.00'
|
||||
|
||||
chat:
|
||||
prefix: '&b[&9SaneEcon&b]&r '
|
||||
prefix: '&b[&9Economy&b]&r '
|
||||
|
||||
economy:
|
||||
start-balance: 1000.0
|
Loading…
Reference in New Issue
Block a user