From 6382bec05a1ed6967a11a0903ba288d976e44b8a Mon Sep 17 00:00:00 2001 From: NuclearW Date: Wed, 8 Feb 2012 23:17:01 -0500 Subject: [PATCH] Allow lookup of player's stats from console Quick change to test new Jenkins+GitPOST --- .../commands/general/StatsCommand.java | 24 ++++++++++++++++--- src/main/java/com/gmail/nossr50/mcMMO.java | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java index 76ffc9002..5ab82c14e 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/StatsCommand.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; @@ -16,6 +17,12 @@ import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.skills.Skills; public class StatsCommand implements CommandExecutor { + private final mcMMO plugin; + + public StatsCommand(mcMMO instance) { + this.plugin = instance; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!LoadProperties.statsEnable) { @@ -23,12 +30,23 @@ public class StatsCommand implements CommandExecutor { return true; } + Player player = (Player) sender; + if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); - return true; + if(args.length != 1) { + sender.sendMessage("Usage: stats "); + return true; + } else { + Player temp = plugin.getServer().getPlayer(args[0]); + if(temp == null) { + sender.sendMessage("Could not find player: " + args[0]); + return true; + } else { + player = temp; + } + } } - Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats")); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 92885706e..a53b2d3ec 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -304,7 +304,7 @@ public class mcMMO extends JavaPlugin if(LoadProperties.mmoeditEnable) getCommand("mmoedit").setExecutor(new MmoeditCommand(this)); getCommand("mmoupdate").setExecutor(new MmoupdateCommand()); if(LoadProperties.myspawnEnable) getCommand("myspawn").setExecutor(new MyspawnCommand()); - if(LoadProperties.statsEnable) getCommand("stats").setExecutor(new StatsCommand()); + if(LoadProperties.statsEnable) getCommand("stats").setExecutor(new StatsCommand(this)); if(LoadProperties.whoisEnable) getCommand("whois").setExecutor(new WhoisCommand(this)); if(LoadProperties.xprateEnable) getCommand("xprate").setExecutor(new XprateCommand());