From 8dbfc3893cd922d5442d9c2a4f16fe8b2e1b4c32 Mon Sep 17 00:00:00 2001 From: Evenprime Date: Fri, 2 Dec 2011 17:42:41 +0100 Subject: [PATCH] New command to read collected player data --- plugin.yml | 3 ++ pom.xml | 2 +- .../nocheat/command/CommandHandler.java | 29 +++++++++++++++++++ .../bukkit/nocheat/config/Permissions.java | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index 0b3ea10d..3cef1a84 100644 --- a/plugin.yml +++ b/plugin.yml @@ -15,6 +15,7 @@ commands: / permlist player [permission] - to list the NoCheat relevant permissions of the player, optionally only those starting with [permission] / reload - to reload NoCheats configuration file(s), without reloading the plugin itself / performance - to show some performance data of NoCheat + / playerinfo playername - show the collected data NoCheat collected about a player permissions: nocheat: @@ -31,6 +32,8 @@ permissions: description: allow use of the "nocheat reload" command nocheat.admin.performance: description: allow use of the "nocheat performance" command + nocheat.admin.playerinfo: + description: allow use of the "nocheat playerinfo" command nocheat.checks: description: Allow the player to bypass all checks children: diff --git a/pom.xml b/pom.xml index bbefe0d7..d9acecd1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 cc.co.evenprime.bukkit NoCheat - 2.19a + 2.20 jar NoCheat diff --git a/src/cc/co/evenprime/bukkit/nocheat/command/CommandHandler.java b/src/cc/co/evenprime/bukkit/nocheat/command/CommandHandler.java index d380acd6..68dcfd04 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/command/CommandHandler.java +++ b/src/cc/co/evenprime/bukkit/nocheat/command/CommandHandler.java @@ -4,6 +4,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -39,9 +41,36 @@ public class CommandHandler { return handlePerformanceCommand(plugin, sender); } + else if(args[0].equalsIgnoreCase("playerinfo") && args.length >= 2) { + // performance command was used + return handlePlayerInfoCommand(plugin, sender, args); + } + return false; } + private static boolean handlePlayerInfoCommand(NoCheat plugin, CommandSender sender, String[] args) { + // Does the sender have permission? + if(sender instanceof Player && !sender.hasPermission(Permissions.ADMIN_PLAYERINFO)) { + return false; + } + + Map map = plugin.getPlayerData(args[1]); + String filter = ""; + + if(args.length > 2) { + filter = args[2]; + } + + sender.sendMessage("PlayerInfo for " + args[1]); + for(Entry entry : map.entrySet()) { + if(entry.getKey().contains(filter)) { + sender.sendMessage(entry.getKey() + ": " + entry.getValue()); + } + } + return true; + } + private static boolean handlePermlistCommand(NoCheat plugin, CommandSender sender, String[] args) { // Does the sender have permission to use it? if(sender instanceof Player && !sender.hasPermission(Permissions.ADMIN_PERMLIST)) { diff --git a/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java b/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java index 242b7e61..e1d6028f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java +++ b/src/cc/co/evenprime/bukkit/nocheat/config/Permissions.java @@ -43,6 +43,7 @@ public class Permissions { public static final String ADMIN_PERMLIST = ADMIN + ".permlist"; public static final String ADMIN_RELOAD = ADMIN + ".reload"; public static final String ADMIN_PERFORMANCE = ADMIN + ".performance"; + public static final String ADMIN_PLAYERINFO = ADMIN + ".playerinfo"; private Permissions() {} }