diff --git a/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.java b/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.java index 96974c61..d5b87b6e 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.java +++ b/CommonCore/SQL/src/de/steamwar/sql/SteamwarUser.java @@ -73,6 +73,7 @@ public class SteamwarUser { private static final Statement getPlaytime = new Statement("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?"); private static final Statement getFirstjoin = new Statement("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?"); + private static final Statement getLastonline = new Statement("SELECT MAX(EndTime) AS LastOnline FROM Session WHERE UserID = ?"); private static final Map usersById = new HashMap<>(); private static final Map usersByUUID = new HashMap<>(); @@ -276,6 +277,14 @@ public class SteamwarUser { }, id); } + public Timestamp getLastOnline() { + return getLastonline.select(rs -> { + if (rs.next()) + return rs.getTimestamp("LastOnline"); + return null; + }, id); + } + public void punish(Punishment.PunishmentType punishment, Timestamp time, String banReason, int from, boolean perma) { initPunishments(); punishments.remove(punishment); diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index b133d99b..e8ca12bb 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -626,6 +626,7 @@ WHOIS_ID=§7ID§8: §e{0} WHOIS_PERMS=§7Perms§8: §7{0} WHOIS_DISCORD_ID=§7Discord-ID§8: §e{0} WHOIS_JOINED_FIRST=§7Joined on§8: §e{0} +WHOIS_LAST_ONLINE=§7Last 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} diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index 9299064f..db367a1f 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -602,6 +602,7 @@ 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_LAST_ONLINE=§7Zuletzt online§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} diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java index 6512c9c0..4daa5b78 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java @@ -20,15 +20,15 @@ package de.steamwar.velocitycore.commands; import com.velocitypowered.api.proxy.Player; -import de.steamwar.persistent.Storage; -import de.steamwar.velocitycore.VelocityCore; -import de.steamwar.velocitycore.mods.ModUtils; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; +import de.steamwar.persistent.Storage; import de.steamwar.sql.*; +import de.steamwar.velocitycore.VelocityCore; +import de.steamwar.velocitycore.mods.ModUtils; import lombok.AllArgsConstructor; import lombok.Getter; import net.kyori.adventure.text.event.ClickEvent; @@ -86,9 +86,12 @@ public class WhoisCommand extends SWCommand { if(firstJoin == null && target != null) { firstJoin = Storage.sessions.get(target); } + Timestamp lastOnline = user.getLastOnline(); if(firstJoin != null) sender.system("WHOIS_JOINED_FIRST", firstJoin.toString()); + if (lastOnline != null) + sender.system("WHOIS_LAST_ONLINE", lastOnline.toString()); sender.system("WHOIS_HOURS_PLAYED", new DecimalFormat("###.##").format(onlineTime / 3600d)); if(target != null) {