Don't waste cpu on /baltop if eco is disabled.

This commit is contained in:
KHobbits 2013-08-28 18:00:27 +01:00
parent eca3be5cf3
commit 62b4348842
2 changed files with 18 additions and 12 deletions

View File

@ -457,10 +457,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
{ {
if (ess.getSettings().isEcoDisabled()) if (ess.getSettings().isEcoDisabled())
{ {
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Internal economy functions disabled, aborting balance sync.");
}
return; return;
} }
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value) if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)

View File

@ -109,16 +109,26 @@ public class Commandbalancetop extends EssentialsCommand
cache.getLines().clear(); cache.getLines().clear();
final Map<String, BigDecimal> balances = new HashMap<String, BigDecimal>(); final Map<String, BigDecimal> balances = new HashMap<String, BigDecimal>();
BigDecimal totalMoney = BigDecimal.ZERO; BigDecimal totalMoney = BigDecimal.ZERO;
for (String u : ess.getUserMap().getAllUniqueUsers()) if (ess.getSettings().isEcoDisabled())
{ {
final User user = ess.getUserMap().getUser(u); if (ess.getSettings().isDebug())
if (user != null)
{ {
final BigDecimal userMoney = user.getMoney(); ess.getLogger().info("Internal economy functions disabled, aborting baltop.");
user.updateMoneyCache(userMoney); }
totalMoney = totalMoney.add(userMoney); }
final String name = user.isHidden() ? user.getName() : user.getDisplayName(); else
balances.put(name, userMoney); {
for (String u : ess.getUserMap().getAllUniqueUsers())
{
final User user = ess.getUserMap().getUser(u);
if (user != null)
{
final BigDecimal userMoney = user.getMoney();
user.updateMoneyCache(userMoney);
totalMoney = totalMoney.add(userMoney);
final String name = user.isHidden() ? user.getName() : user.getDisplayName();
balances.put(name, userMoney);
}
} }
} }