diff options
-rw-r--r-- | Essentials/src/net/ess3/commands/Commandbalancetop.java | 41 | ||||
-rw-r--r-- | Essentials/src/net/ess3/permissions/Permissions.java | 3 | ||||
-rw-r--r-- | Essentials/src/net/ess3/user/UserData.java | 1 | ||||
-rw-r--r-- | Essentials/src/plugin.yml | 2 |
4 files changed, 41 insertions, 6 deletions
diff --git a/Essentials/src/net/ess3/commands/Commandbalancetop.java b/Essentials/src/net/ess3/commands/Commandbalancetop.java index 5ba24db3c..c353f6cb3 100644 --- a/Essentials/src/net/ess3/commands/Commandbalancetop.java +++ b/Essentials/src/net/ess3/commands/Commandbalancetop.java @@ -6,6 +6,7 @@ import java.util.Map.Entry; import java.util.concurrent.locks.ReentrantReadWriteLock; import static net.ess3.I18n._; import net.ess3.api.IUser; +import net.ess3.permissions.Permissions; import net.ess3.utils.FormatUtil; import net.ess3.utils.textreader.ArrayListInput; import net.ess3.utils.textreader.TextPager; @@ -33,7 +34,34 @@ public class Commandbalancetop extends EssentialsCommand } catch (NumberFormatException ex) { - if (args[0].equalsIgnoreCase("force") && sender.isOp()) + if (args[0].equalsIgnoreCase("hide")) + { + if (args.length == 1 && isUser(sender) && Permissions.BALANCETOP_HIDE.isAuthorized(sender)) + { + IUser user = getUser(sender); + user.getData().setBalancetopHide(!user.getData().isBalancetopHide()); + user.queueSave(); + sender.sendMessage( + user.getData().isBalancetopHide() + ? "You are now hidden from /balancetop" + : "You are now shown in /balancetop"); //TODO:I18n + } + else if (args.length == 2 && Permissions.BALANCETOP_HIDE_OTHERS.isAuthorized(sender)) + { + IUser user = ess.getUserMap().matchUser(args[1], true); + user.getData().setBalancetopHide(!user.getData().isBalancetopHide()); + user.queueSave(); + sender.sendMessage( + user.getData().isBalancetopHide() + ? user.getName() + " is now hidden from /balancetop" + : user.getName() + " is now shown in /balancetop"); //TODO:I18n + } + else + { + throw new NotEnoughArgumentsException(); + } + } + if (args[0].equalsIgnoreCase("force") && Permissions.BALANCETOP_FORCE.isAuthorized(sender)) { force = true; } @@ -100,7 +128,7 @@ public class Commandbalancetop extends EssentialsCommand { if (force || cacheage <= System.currentTimeMillis() - CACHETIME) { - cache.getLines().clear(); + cache.getLines().clear(); final Map<String, Double> balances = new HashMap<String, Double>(); double totalMoney = 0d; for (String u : ess.getUserMap().getAllUniqueUsers()) @@ -110,8 +138,11 @@ public class Commandbalancetop extends EssentialsCommand { final double userMoney = user.getMoney(); user.updateMoneyCache(userMoney); - totalMoney += userMoney; - balances.put(user.getPlayer().getDisplayName(), userMoney); + if (!user.getData().isBalancetopHide()) + { + totalMoney += userMoney; + balances.put(user.getName(), userMoney); + } } } @@ -124,7 +155,7 @@ public class Commandbalancetop extends EssentialsCommand return -entry1.getValue().compareTo(entry2.getValue()); } }); - + cache.getLines().add(_("serverTotal", FormatUtil.displayCurrency(totalMoney, ess))); int pos = 1; for (Map.Entry<String, Double> entry : sortedEntries) diff --git a/Essentials/src/net/ess3/permissions/Permissions.java b/Essentials/src/net/ess3/permissions/Permissions.java index 3baa39678..afaf5e2b4 100644 --- a/Essentials/src/net/ess3/permissions/Permissions.java +++ b/Essentials/src/net/ess3/permissions/Permissions.java @@ -14,6 +14,9 @@ public enum Permissions implements IPermission AFK_OTHERS, BACK_ONDEATH, BALANCE_OTHERS, + BALANCETOP_FORCE, + BALANCETOP_HIDE, + BALANCETOP_HIDE_OTHERS, BAN_EXEMPT, BAN_NOTIFY, BAN_OFFLINE, diff --git a/Essentials/src/net/ess3/user/UserData.java b/Essentials/src/net/ess3/user/UserData.java index b0ed2c03b..88c4cb627 100644 --- a/Essentials/src/net/ess3/user/UserData.java +++ b/Essentials/src/net/ess3/user/UserData.java @@ -104,6 +104,7 @@ public class UserData implements StorageObject private boolean socialspy; private boolean npc; private boolean powerToolsEnabled; + private boolean balancetopHide = false; public UserData() { diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 27c9d23df..a7fa9e8dd 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -29,7 +29,7 @@ commands: aliases: [bal,money,emoney,ebalance,ebal] balancetop: description: Gets the top balance values. - usage: /<command> <page> + usage: /<command> [pagenumber|hide [player]|force] aliases: [baltop,ebaltop,ebalancetop] ban: description: Bans a player. |