Minor cleanup on /eco command.

This commit is contained in:
KHobbits 2013-01-20 01:19:52 +00:00
parent 23a15cb11a
commit 987b2ff4d5
3 changed files with 16 additions and 14 deletions

View file

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale; import java.util.Locale;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -18,10 +19,9 @@ public class Commandeco extends EssentialsCommand
@Override @Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{ {
boolean broadcast = false; Double broadcast = null;
boolean broadcastAll = false; Double broadcastAll = null;
final double startingBalance = (double)ess.getSettings().getStartingBalance(); final double startingBalance = (double)ess.getSettings().getStartingBalance();
final String start = ess.getSettings().getCurrencySymbol() + ess.getSettings().getStartingBalance();
if (args.length < 2) if (args.length < 2)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
@ -67,12 +67,13 @@ public class Commandeco extends EssentialsCommand
case RESET: case RESET:
player.setMoney(startingBalance); player.setMoney(startingBalance);
broadcastAll = true; broadcastAll = startingBalance;
break; break;
case SET: case SET:
boolean underMinimum = (player.getMoney() - amount) < minBalance; boolean underMinimum = (player.getMoney() - amount) < minBalance;
player.setMoney(underMinimum ? minBalance : amount); player.setMoney(underMinimum ? minBalance : amount);
broadcastAll = underMinimum ? minBalance : amount;
break; break;
} }
} }
@ -104,12 +105,13 @@ public class Commandeco extends EssentialsCommand
case RESET: case RESET:
player.setMoney(startingBalance); player.setMoney(startingBalance);
broadcast = true; broadcast = startingBalance;
break; break;
case SET: case SET:
boolean underMinimum = (player.getMoney() - amount) < minBalance; boolean underMinimum = (player.getMoney() - amount) < minBalance;
player.setMoney(underMinimum ? minBalance : amount); player.setMoney(underMinimum ? minBalance : amount);
broadcast = underMinimum ? minBalance : amount;
break; break;
} }
} }
@ -148,13 +150,13 @@ public class Commandeco extends EssentialsCommand
} }
} }
if(broadcast) if (broadcast != null)
{ {
server.broadcastMessage(_("resetBal", start)); server.broadcastMessage(_("resetBal", Util.formatAsCurrency(broadcast)));
} }
if(broadcastAll) if (broadcastAll != null)
{ {
server.broadcastMessage(_("resetBalAll", start)); server.broadcastMessage(_("resetBalAll", Util.formatAsCurrency(broadcastAll)));
} }
} }

View file

@ -490,5 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
holdFirework=\u00a74You must be holding a firework to add effects holdFirework=\u00a74You must be holding a firework to add effects
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1} invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1} muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players

View file

@ -490,5 +490,5 @@ fireworkColor=\u00a74You must apply a color to the firework to add an effect
holdFirework=\u00a74You must be holding a firework to add effects holdFirework=\u00a74You must be holding a firework to add effects
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1} invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1} muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online players resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online players
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players