Added userinfo support

This commit is contained in:
Norbi Peti 2016-11-01 22:23:34 +01:00
parent 3c46385c80
commit 711e223f2a
2 changed files with 49 additions and 0 deletions

View file

@ -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());
}
}

View file

@ -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 + " <playername>" //
};
}
@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;
}
}