mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-02 14:37:46 +01:00
Cleanup /eco, fix reset broadcast
This commit is contained in:
parent
762bb65677
commit
a586edfd0b
@ -18,8 +18,10 @@ 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
|
||||||
{
|
{
|
||||||
double startingBalance = (double)ess.getSettings().getStartingBalance();
|
boolean broadcast = false;
|
||||||
String start = ess.getSettings().getCurrencySymbol() + ess.getSettings().getStartingBalance();
|
boolean broadcastAll = false;
|
||||||
|
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();
|
||||||
@ -36,11 +38,10 @@ public class Commandeco extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException(ex);
|
throw new NotEnoughArgumentsException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
double min = ess.getSettings().getMinMoney();
|
final double minBalance = ess.getSettings().getMinMoney();
|
||||||
|
|
||||||
if (args[1].contentEquals("**"))
|
if (args[1].contentEquals("**"))
|
||||||
{
|
{
|
||||||
server.broadcastMessage(_("resetBalAll", start));
|
|
||||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||||
{
|
{
|
||||||
final User player = ess.getUser(sUser);
|
final User player = ess.getUser(sUser);
|
||||||
@ -66,18 +67,18 @@ public class Commandeco extends EssentialsCommand
|
|||||||
|
|
||||||
case RESET:
|
case RESET:
|
||||||
player.setMoney(startingBalance);
|
player.setMoney(startingBalance);
|
||||||
|
broadcastAll = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SET:
|
case SET:
|
||||||
boolean underMinimum = (player.getMoney() - amount) < min;
|
boolean underMinimum = (player.getMoney() - amount) < minBalance;
|
||||||
player.setMoney(underMinimum ? min : amount);
|
player.setMoney(underMinimum ? minBalance : amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args[1].contentEquals("*"))
|
else if (args[1].contentEquals("*"))
|
||||||
{
|
{
|
||||||
server.broadcastMessage(_("resetBal", start));
|
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final User player = ess.getUser(onlinePlayer);
|
final User player = ess.getUser(onlinePlayer);
|
||||||
@ -103,11 +104,12 @@ public class Commandeco extends EssentialsCommand
|
|||||||
|
|
||||||
case RESET:
|
case RESET:
|
||||||
player.setMoney(startingBalance);
|
player.setMoney(startingBalance);
|
||||||
|
broadcast = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SET:
|
case SET:
|
||||||
boolean underMinimum = (player.getMoney() - amount) < min;
|
boolean underMinimum = (player.getMoney() - amount) < minBalance;
|
||||||
player.setMoney(underMinimum ? min : amount);
|
player.setMoney(underMinimum ? minBalance : amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,11 +142,20 @@ public class Commandeco extends EssentialsCommand
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SET:
|
case SET:
|
||||||
boolean underMinimum = (player.getMoney() - amount) < min;
|
boolean underMinimum = (player.getMoney() - amount) < minBalance;
|
||||||
player.setMoney(underMinimum ? min : amount);
|
player.setMoney(underMinimum ? minBalance : amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(broadcast)
|
||||||
|
{
|
||||||
|
server.broadcastMessage(_("resetBal", start));
|
||||||
|
}
|
||||||
|
if(broadcastAll)
|
||||||
|
{
|
||||||
|
server.broadcastMessage(_("resetBalAll", start));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user