From 8cdbe6de25db1551cdc4ef61967ae42ed4dc278c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 1 Apr 2020 07:34:31 +0200 Subject: [PATCH] Implementing WHOIS command Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 1 + .../bungeecore/commands/WhoisCommand.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/de/steamwar/bungeecore/commands/WhoisCommand.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 7afbdea..c44cc0c 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -90,6 +90,7 @@ public class BungeeCore extends Plugin { new PollCommand(); new MuteCommand(); new BugCommand(); + new WhoisCommand(); new EventStarter(); new Broadcaster(); diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java new file mode 100644 index 0000000..cd054a0 --- /dev/null +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -0,0 +1,46 @@ +package de.steamwar.bungeecore.commands; + +import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.sql.Team; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.connection.ProxiedPlayer; + +public class WhoisCommand extends BasicCommand { + public WhoisCommand(){ + super("whois", "bungeecore.teamchat"); + } + + @Override + public void execute(CommandSender sender, String[] args) { + if(!(sender instanceof ProxiedPlayer)) + return; + ProxiedPlayer player = (ProxiedPlayer) sender; + + if(args.length == 0){ + BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c/whois [Spieler]"); + return; + } + + SteamwarUser user = SteamwarUser.get(args[0]); + if(user == null){ + BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler."); + return; + } + + BungeeCore.send(player, "§7Username§8: §e" + user.getUserName()); + BungeeCore.send(player, "§7UUID§8: §e" + user.getUuid().toString(), "", new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, user.getUuid().toString())); + BungeeCore.send(player, "§7ID§8: §e" + user.getId()); + + Team team = Team.get(user.getTeam()); + BungeeCore.send(player, "§7Team§8: §e" + team.getTeamName()); + + if(user.isBanned()){ + player.sendMessage(user.banMessage()); + } + if(user.isMuted()){ + player.sendMessage(user.muteMessage()); + } + } +}