From 6981b222af8788e37c7de0032dc2d9bf774030f4 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 20 Nov 2017 16:05:29 +0200 Subject: [PATCH] Added some missing things to InspectPageParser --- .../com/djrapitops/plan/data/PlayerProfile.java | 13 +++++++++++++ .../systems/info/parsing/InspectPageParser.java | 14 +++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index 34de9c505..e5ce3942d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -102,6 +102,19 @@ public class PlayerProfile implements OfflinePlayer { return map; } + public UUID getFavoriteServer() { + long max = 0L; + UUID maxServer = null; + for (Map.Entry entry : getWorldTimesPerServer().entrySet()) { + long playTime = entry.getValue().getTotal(); + if (playTime < max) { + max = playTime; + maxServer = entry.getKey(); + } + } + return maxServer; + } + public long getLastSeen() { return getLastSeen(getAllSessions()); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index daca67c64..53f178c7c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -11,6 +11,7 @@ import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.exceptions.ParseException; import main.java.com.djrapitops.plan.data.Action; +import main.java.com.djrapitops.plan.data.GeoInfo; import main.java.com.djrapitops.plan.data.PlayerProfile; import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.time.WorldTimes; @@ -82,20 +83,27 @@ public class InspectPageParser extends PageParser { } Map serverNames = db.getServerTable().getServerNames(); + Map worldTimesPerServer = profile.getWorldTimesPerServer(); addValue("serverPieSeries", ServerPreferencePieCreator.createSeriesData(serverNames, worldTimesPerServer)); addValue("worldPieColors", Settings.THEME_GRAPH_WORLD_PIE.toString()); addValue("gmPieColors", Settings.THEME_GRAPH_GM_PIE.toString()); addValue("serverPieColors", Settings.THEME_GRAPH_SERVER_PREF_PIE.toString()); + String favoriteServer = serverNames.get(profile.getFavoriteServer()); + addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown"); + // TODO IP Timestamp table -// List geolocations = db.getIpsTable().getGeolocations(uuid); List nicknames = profile.getNicknames().stream() .map(HtmlUtils::swapColorsToSpan) .collect(Collectors.toList()); + List geoLocations = profile.getGeoInformation().stream() + .map(GeoInfo::getGeolocation) + .collect(Collectors.toList()); + // TODO REMOVE after 4.1.0 addValue("nicknames", HtmlStructure.createDotList(nicknames.toArray(new String[nicknames.size()]))); -// addValue("geolocations", HtmlStructure.createDotList(geolocations.toArray(new String[geolocations.size()]))); + addValue("geolocations", HtmlStructure.createDotList(geoLocations.toArray(new String[geoLocations.size()]))); Map> sessions = profile.getSessions(); Map> sessionsByServerName = sessions.entrySet().stream() @@ -173,7 +181,7 @@ public class InspectPageParser extends PageParser { addValue("tableBodyActions", ActionsTableCreator.createTable(actions)); String punchCardData = PunchCardGraphCreator.createDataSeries(allSessions); - WorldTimes worldTimes = db.getWorldTimesTable().getWorldTimesOfUser(uuid); + WorldTimes worldTimes = profile.getWorldTimes(); AnalysisUtils.addMissingWorlds(worldTimes); String[] worldPieData = WorldPieCreator.createSeriesData(worldTimes);