From 992ef5dc91be94b77e07cc39fcc8a9f9279bfe38 Mon Sep 17 00:00:00 2001 From: Ali Moghnieh Date: Wed, 6 Jul 2016 19:34:25 +0100 Subject: [PATCH] Add `npcs-in-balance-ranking` configurable option. Resolves #716. --- .../src/com/earth2me/essentials/ISettings.java | 2 ++ Essentials/src/com/earth2me/essentials/Settings.java | 12 ++++++++++++ .../essentials/commands/Commandbalancetop.java | 6 +++++- Essentials/src/config.yml | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 3d7e5918b..cc7962b6f 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -257,4 +257,6 @@ public interface ISettings extends IConf { Entry getCommandCooldownEntry(String label); boolean isCommandCooldownPersistent(String label); + + boolean isNpcsInBalanceRanking(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 8c69e5564..0528f1606 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -536,6 +536,7 @@ public class Settings implements net.ess3.api.ISettings { isCustomQuitMessage = !customQuitMessage.equals("none"); muteCommands = _getMuteCommands(); commandCooldowns = _getCommandCooldowns(); + npcsInBalanceRanking = _isNpcsInBalanceRanking(); } private List itemSpawnBl = new ArrayList(); @@ -1262,4 +1263,15 @@ public class Settings implements net.ess3.api.ISettings { // TODO: enable per command cooldown specification for persistence. return config.getBoolean("command-cooldown-persistence", true); } + + private boolean npcsInBalanceRanking = false; + + public boolean _isNpcsInBalanceRanking() { + return config.getBoolean("npcs-in-balance-ranking", false); + } + + @Override + public boolean isNpcsInBalanceRanking() { + return npcsInBalanceRanking; + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java index 9f1a3b1be..e82861caa 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java @@ -96,7 +96,11 @@ public class Commandbalancetop extends EssentialsCommand { } else { for (UUID u : ess.getUserMap().getAllUniqueUsers()) { final User user = ess.getUserMap().getUser(u); - if (user != null && !user.isNPC()) { // Don't list NPCs in output + if (user != null) { + if (!ess.getSettings().isNpcsInBalanceRanking() && user.isNPC()) { + // Don't list NPCs in output + continue; + } final BigDecimal userMoney = user.getMoney(); user.updateMoneyCache(userMoney); totalMoney = totalMoney.add(userMoney); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 92e5b8dae..7040f5dbf 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -502,6 +502,10 @@ command-cooldowns: # Whether command cooldowns should be persistent past server shutdowns command-cooldown-persistence: true +# Whether NPC balances should be listed in balance ranking features such as /balancetop. +# NPC balances can include features like factions from FactionsUUID plugin. +npcs-in-balance-ranking: false + ############################################################ # +------------------------------------------------------+ # # | EssentialsHome | #