From 10f623b0e4ce2ad1d8dba0fb69f91c41cf7c5e26 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 17 Jan 2023 16:15:43 +0100 Subject: [PATCH 1/2] Update WhoisCommand and make it public --- .../bungeecore/commands/WhoisCommand.java | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 8507457..c252cf8 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -35,7 +35,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.sql.Timestamp; import java.text.DecimalFormat; import java.time.Instant; - import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -43,7 +42,7 @@ import java.util.stream.Stream; public class WhoisCommand extends SWCommand { public WhoisCommand() { - super("whois", "bungeecore.teamchat"); + super("whois"); } @Register(description = "WHOIS_USAGE") @@ -79,22 +78,29 @@ public class WhoisCommand extends SWCommand { } private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, EnumSet parameterTypes) { - Message.send("WHOIS_USERNAME", player, user.getUserName()); - Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString()); - Message.send("WHOIS_ID", player, user.getId()); - Message.send("WHOIS_GROUP", player, user.getUserGroup().getColorCode(), user.getUserGroup().name()); - if (user.getDiscordId() != null) { - Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId()); - } - Timestamp firstJoin = user.getFirstjoin(); - if (firstJoin == null) { - Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00"); - } else { - Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString()); - } - Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d)); + UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup(); + boolean playerIsInServerTeam = userGroup.isTeamGroup(); - if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) { + Message.send("WHOIS_USERNAME", player, user.getUserName()); + Message.send("WHOIS_GROUP", player, user.getUserGroup().getColorCode(), user.getUserGroup().name()); + if (userGroup.isAdminGroup()) { + Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString()); + Message.send("WHOIS_ID", player, user.getId()); + if (user.getDiscordId() != null) { + Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId()); + } + } + if (playerIsInServerTeam) { + Timestamp firstJoin = user.getFirstjoin(); + if (firstJoin == null) { + Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00"); + } else { + Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString()); + } + Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d)); + } + + if(playerIsInServerTeam && BungeeCord.getInstance().getPlayer(user.getUuid()) != null) { ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid()); Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d)); Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName()); @@ -103,6 +109,7 @@ public class WhoisCommand extends SWCommand { Team team = Team.get(user.getTeam()); Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); + if (!playerIsInServerTeam) return; if (Utils.playerModMap.containsKey(user.getUuid())) { Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform(); From 95686121a77a153c4abc9d14387de3579f725fb9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 17 Jan 2023 16:42:50 +0100 Subject: [PATCH 2/2] Update WhoisCommand and make it public --- .../bungeecore/commands/WhoisCommand.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index c252cf8..1b80d75 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -79,10 +79,13 @@ public class WhoisCommand extends SWCommand { private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, EnumSet parameterTypes) { UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup(); - boolean playerIsInServerTeam = userGroup.isTeamGroup(); Message.send("WHOIS_USERNAME", player, user.getUserName()); Message.send("WHOIS_GROUP", player, user.getUserGroup().getColorCode(), user.getUserGroup().name()); + Team team = Team.get(user.getTeam()); + Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); + if (!userGroup.isTeamGroup()) return; + if (userGroup.isAdminGroup()) { Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString()); Message.send("WHOIS_ID", player, user.getId()); @@ -90,27 +93,22 @@ public class WhoisCommand extends SWCommand { Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId()); } } - if (playerIsInServerTeam) { - Timestamp firstJoin = user.getFirstjoin(); - if (firstJoin == null) { - Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00"); - } else { - Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString()); - } - Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d)); - } - if(playerIsInServerTeam && BungeeCord.getInstance().getPlayer(user.getUuid()) != null) { + Timestamp firstJoin = user.getFirstjoin(); + if (firstJoin == null) { + Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00"); + } else { + Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString()); + } + Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d)); + + if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) { ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid()); Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d)); Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName()); Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion()); } - Team team = Team.get(user.getTeam()); - Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); - if (!playerIsInServerTeam) return; - if (Utils.playerModMap.containsKey(user.getUuid())) { Mod.Platform modPlatform = Utils.playerModMap.get(user.getUuid()).get(0).getPlatform(); Message.send("WHOIS_PLATFORM", player, modPlatform.toString());