From d7530cae86b4da15d949f37f00e02de3e6451d2a Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 9 Sep 2022 20:38:37 +0200 Subject: [PATCH] Add current infos to Whois --- .../bungeecore/commands/WhoisCommand.java | 18 +++++++++++++++--- src/de/steamwar/messages/BungeeCore.properties | 4 ++++ .../steamwar/messages/BungeeCore_de.properties | 4 ++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 9e25ad2..2aea258 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; @@ -31,8 +32,10 @@ import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; +import java.net.InetSocketAddress; import java.sql.Timestamp; import java.text.DecimalFormat; +import java.time.Instant; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -78,15 +81,24 @@ public class WhoisCommand extends SWCommand { 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) + if (firstJoin == null) { Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00"); - else + } else { Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString()); - Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); + } + 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()); diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 9872dfe..394e4ea 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -574,9 +574,13 @@ WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eCopy UUID WHOIS_ID=§7ID§8: §e{0} +WHOIS_GROUP=§7Group§8: §{0}{1} WHOIS_DISCORD_ID=§7Discord-ID§8: §e{0} WHOIS_JOINED_FIRST=§7Joined on§8: §e{0} WHOIS_HOURS_PLAYED=§7Online Time§8: §e{0}h +WHOIS_CURRENT_PLAYED=§7Current Online Time§8: §e{0}m +WHOIS_CURRENT_SERVER=§7Current Server§8: §e{0} +WHOIS_CURRENT_PROTOCOL=§7Current Protocol§8: §e{0} WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2} WHOIS_TEAM_HOVER=§eShow {0} WHOIS_PUNISHMENTS=§7Punish: diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index e0341a7..aff7e1f 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -550,12 +550,16 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen. #WhoisCommand WHOIS_USAGE=§c/whois [Spieler/ID] <-a> WHOIS_USERNAME=§7Username§8: §e{0} +WHOIS_GROUP=§7Gruppe§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eUUID Kopieren WHOIS_ID=§7ID§8: §e{0} WHOIS_DISCORD_ID=§7Discord-ID§8: §e{0} WHOIS_JOINED_FIRST=§7Beigetreten am§8: §e{0} WHOIS_HOURS_PLAYED=§7Spielzeit§8: §e{0}h +WHOIS_CURRENT_PLAYED=§7Aktuell online§8: §e{0}m +WHOIS_CURRENT_SERVER=§7Aktueller Server§8: §e{0} +WHOIS_CURRENT_PROTOCOL=§7Aktuelle Version§8: §e{0} WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2} WHOIS_TEAM_HOVER=§e{0} anzeigen WHOIS_PUNISHMENTS=§7Strafen: