From 711e223f2a705505d3ab5c443b3a17dfc8b1c820 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 1 Nov 2016 22:23:34 +0100 Subject: [PATCH] Added userinfo support --- .../buttondevteam/chat/PlayerListener.java | 14 ++++++++ .../chat/commands/ucmds/InfoCommand.java | 35 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/main/java/buttondevteam/chat/commands/ucmds/InfoCommand.java diff --git a/src/main/java/buttondevteam/chat/PlayerListener.java b/src/main/java/buttondevteam/chat/PlayerListener.java index fc0e40a..36b77c1 100644 --- a/src/main/java/buttondevteam/chat/PlayerListener.java +++ b/src/main/java/buttondevteam/chat/PlayerListener.java @@ -37,7 +37,9 @@ import au.com.mineauz.minigames.MinigamePlayer; import au.com.mineauz.minigames.Minigames; import buttondevteam.chat.commands.ucmds.KittycannonCommand; import buttondevteam.lib.TBMCPlayer; +import buttondevteam.lib.TBMCPlayer.InfoTarget; import buttondevteam.lib.TBMCPlayerAddEvent; +import buttondevteam.lib.TBMCPlayerGetInfoEvent; import buttondevteam.lib.TBMCPlayerJoinEvent; import buttondevteam.lib.TBMCPlayerLoadEvent; import buttondevteam.lib.TBMCPlayerSaveEvent; @@ -548,4 +550,16 @@ public class PlayerListener implements Listener { } } } + + @EventHandler + public void onGetInfo(TBMCPlayerGetInfoEvent e) { + ChatPlayer cp = e.getPlayer().asPluginPlayer(ChatPlayer.class); + e.addInfo("Minecraft name: " + cp.getPlayerName()); + e.addInfo("Reddit name: " + cp.getUserName()); + if (e.getTarget() == InfoTarget.MCCommand) + e.addInfo("/r/TheButton flair: " + cp.GetFormattedFlair()); + else + e.addInfo("/r/TheButton flair: (" + cp.getFlairTime() + "s)"); + e.addInfo("Respect: " + cp.getFCount() / cp.getFDeaths()); + } } diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/InfoCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/InfoCommand.java new file mode 100644 index 0000000..192b143 --- /dev/null +++ b/src/main/java/buttondevteam/chat/commands/ucmds/InfoCommand.java @@ -0,0 +1,35 @@ +package buttondevteam.chat.commands.ucmds; + +import org.bukkit.command.CommandSender; + +import buttondevteam.discordplugin.TBMCDiscordAPI; +import buttondevteam.lib.TBMCPlayer; +import buttondevteam.lib.TBMCPlayer.InfoTarget; + +public class InfoCommand extends UCommandBase { + + @Override + public String[] GetHelpText(String alias) { + return new String[] { // + "ยง6---- User information ----", // + "Get some information known about the user.", // + "Usage: /u " + alias + " " // + }; + } + + @Override + public String GetUCommandPath() { + return "info"; + } + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + if (args.length == 0) + return false; + try (TBMCPlayer p = TBMCPlayer.getFromName(args[0])) { + sender.sendMessage(p.getInfo(InfoTarget.MCCommand)); + } + return true; + } + +}