mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-14 20:21:45 +01:00
Updated Player page parsing to use PlayerContainer, visible to user:
- Added ban, op status to Server accordion - Added server specific register dates to Server accordion - Nickname table supports last seen (Not added yet) - Actions table is being removed
This commit is contained in:
parent
7805c2e372
commit
ff143af328
@ -5,10 +5,15 @@
|
|||||||
package com.djrapitops.plan.system.webserver.pages.parsing;
|
package com.djrapitops.plan.system.webserver.pages.parsing;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||||
import com.djrapitops.plan.data.PlayerProfile;
|
import com.djrapitops.plan.data.Actions;
|
||||||
import com.djrapitops.plan.data.calculation.ActivityIndex;
|
import com.djrapitops.plan.data.calculation.ActivityIndex;
|
||||||
import com.djrapitops.plan.data.container.Action;
|
import com.djrapitops.plan.data.container.Action;
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
|
import com.djrapitops.plan.data.store.containers.PerServerData;
|
||||||
|
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||||
|
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||||
|
import com.djrapitops.plan.data.store.mutators.PerServerDataMutator;
|
||||||
|
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||||
import com.djrapitops.plan.data.time.WorldTimes;
|
import com.djrapitops.plan.data.time.WorldTimes;
|
||||||
import com.djrapitops.plan.system.cache.SessionCache;
|
import com.djrapitops.plan.system.cache.SessionCache;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
@ -19,7 +24,6 @@ import com.djrapitops.plan.system.settings.theme.Theme;
|
|||||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||||
import com.djrapitops.plan.utilities.FormatUtils;
|
import com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
|
||||||
import com.djrapitops.plan.utilities.comparators.SessionLengthComparator;
|
import com.djrapitops.plan.utilities.comparators.SessionLengthComparator;
|
||||||
import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||||
@ -61,22 +65,22 @@ public class InspectPage extends Page {
|
|||||||
}
|
}
|
||||||
Benchmark.start("Inspect Parse, Fetch");
|
Benchmark.start("Inspect Parse, Fetch");
|
||||||
Database db = Database.getActive();
|
Database db = Database.getActive();
|
||||||
PlayerProfile profile = db.fetch().getPlayerProfile(uuid);
|
PlayerContainer container = db.fetch().getPlayerContainer(uuid);
|
||||||
if (profile == null) {
|
if (!container.getValue(PlayerKeys.REGISTERED).isPresent()) {
|
||||||
throw new IllegalStateException("Player profile was null!");
|
throw new IllegalStateException("Player is not registered");
|
||||||
}
|
}
|
||||||
UUID serverUUID = ServerInfo.getServerUUID();
|
UUID serverUUID = ServerInfo.getServerUUID();
|
||||||
Map<UUID, String> serverNames = db.fetch().getServerNames();
|
Map<UUID, String> serverNames = db.fetch().getServerNames();
|
||||||
|
|
||||||
Benchmark.stop("Inspect Parse, Fetch");
|
Benchmark.stop("Inspect Parse, Fetch");
|
||||||
|
|
||||||
return parse(profile, serverUUID, serverNames);
|
return parse(container, serverUUID, serverNames);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParseException(e);
|
throw new ParseException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String parse(PlayerProfile profile, UUID serverUUID, Map<UUID, String> serverNames) throws IOException {
|
public String parse(PlayerContainer container, UUID serverUUID, Map<UUID, String> serverNames) throws IOException {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
addValue("refresh", FormatUtils.formatTimeStampClock(now));
|
addValue("refresh", FormatUtils.formatTimeStampClock(now));
|
||||||
@ -88,44 +92,49 @@ public class InspectPage extends Page {
|
|||||||
if (activeSession.isPresent()) {
|
if (activeSession.isPresent()) {
|
||||||
Session session = activeSession.get();
|
Session session = activeSession.get();
|
||||||
session.setSessionID(Integer.MAX_VALUE);
|
session.setSessionID(Integer.MAX_VALUE);
|
||||||
profile.addActiveSession(session);
|
|
||||||
online = serverNames.get(serverUUID);
|
online = serverNames.get(serverUUID);
|
||||||
|
container.putRawData(PlayerKeys.ACTIVE_SESSION, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = profile.getName();
|
String playerName = container.getValue(PlayerKeys.NAME).orElse("Unknown");
|
||||||
long registered = profile.getRegistered();
|
long registered = container.getValue(PlayerKeys.REGISTERED).orElse(-1L);
|
||||||
int timesKicked = profile.getTimesKicked();
|
int timesKicked = container.getValue(PlayerKeys.KICK_COUNT).orElse(0);
|
||||||
long lastSeen = profile.getLastSeen();
|
long lastSeen = container.getValue(PlayerKeys.LAST_SEEN).orElse(-1L);
|
||||||
|
|
||||||
addValue("registered", FormatUtils.formatTimeStampYear(registered));
|
addValue("registered", FormatUtils.formatTimeStampYear(registered));
|
||||||
addValue("playerName", playerName);
|
addValue("playerName", playerName);
|
||||||
addValue("kickCount", timesKicked);
|
addValue("kickCount", timesKicked);
|
||||||
|
|
||||||
addValue("lastSeen", lastSeen != 0 ? FormatUtils.formatTimeStampYear(lastSeen) : "-");
|
addValue("toLastSeen", lastSeen != 0 ? FormatUtils.formatTimeStampYear(lastSeen) : "-");
|
||||||
|
|
||||||
Map<UUID, WorldTimes> worldTimesPerServer = profile.getWorldTimesPerServer();
|
PerServerData perServerData = container.getValue(PlayerKeys.PER_SERVER).orElse(new PerServerData());
|
||||||
|
PerServerDataMutator perServerDataMutator = new PerServerDataMutator(perServerData);
|
||||||
|
|
||||||
|
Map<UUID, WorldTimes> worldTimesPerServer = perServerDataMutator.worldTimesPerServer();
|
||||||
addValue("serverPieSeries", new ServerPreferencePie(serverNames, worldTimesPerServer).toHighChartsSeries());
|
addValue("serverPieSeries", new ServerPreferencePie(serverNames, worldTimesPerServer).toHighChartsSeries());
|
||||||
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
||||||
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
||||||
addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
|
addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
|
||||||
|
|
||||||
String favoriteServer = serverNames.get(profile.getFavoriteServer());
|
String favoriteServer = serverNames.getOrDefault(perServerDataMutator.favoriteServer(), "Unknown");
|
||||||
addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown");
|
addValue("favoriteServer", favoriteServer);
|
||||||
|
|
||||||
addValue("tableBodyNicknames", new NicknameTable(profile.getNicknames(), serverNames).parseBody());
|
addValue("tableBodyNicknames", new NicknameTable(
|
||||||
addValue("tableBodyIPs", new GeoInfoTable(profile.getGeoInformation()).parseBody());
|
container.getValue(PlayerKeys.NICKNAMES).orElse(new ArrayList<>()), serverNames)
|
||||||
|
.parseBody());
|
||||||
|
addValue("tableBodyIPs", new GeoInfoTable(container.getValue(PlayerKeys.GEO_INFO).orElse(new ArrayList<>())).parseBody());
|
||||||
|
|
||||||
Map<UUID, List<Session>> sessions = profile.getSessions();
|
Map<UUID, List<Session>> sessions = perServerDataMutator.sessionsPerServer();
|
||||||
Map<String, List<Session>> sessionsByServerName = sessions.entrySet().stream()
|
Map<String, List<Session>> sessionsByServerName = sessions.entrySet().stream()
|
||||||
.collect(Collectors.toMap(entry -> serverNames.get(entry.getKey()), Map.Entry::getValue));
|
.collect(Collectors.toMap(entry -> serverNames.get(entry.getKey()), Map.Entry::getValue));
|
||||||
|
|
||||||
List<Session> allSessions = profile.getAllSessions()
|
List<Session> allSessions = container.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>());
|
||||||
.sorted(new SessionStartComparator())
|
SessionsMutator allSessionsMutator = new SessionsMutator(allSessions);
|
||||||
.collect(Collectors.toList());
|
allSessions.sort(new SessionStartComparator());
|
||||||
|
|
||||||
String[] sessionsAccordion = HtmlStructure.createSessionsTabContentInspectPage(sessionsByServerName, allSessions, uuid);
|
String[] sessionsAccordion = HtmlStructure.createSessionsTabContentInspectPage(sessionsByServerName, allSessions, uuid);
|
||||||
|
|
||||||
ServerAccordion serverAccordion = new ServerAccordion(profile, serverNames);
|
ServerAccordion serverAccordion = new ServerAccordion(container, worldTimesPerServer, serverNames);
|
||||||
|
|
||||||
PlayerCalendar playerCalendar = new PlayerCalendar(allSessions, registered);
|
PlayerCalendar playerCalendar = new PlayerCalendar(allSessions, registered);
|
||||||
|
|
||||||
@ -140,41 +149,41 @@ public class InspectPage extends Page {
|
|||||||
long weekAgo = now - TimeAmount.WEEK.ms();
|
long weekAgo = now - TimeAmount.WEEK.ms();
|
||||||
long monthAgo = now - TimeAmount.MONTH.ms();
|
long monthAgo = now - TimeAmount.MONTH.ms();
|
||||||
|
|
||||||
List<Session> sessionsDay = profile.getSessions(dayAgo, now).collect(Collectors.toList());
|
SessionsMutator daySessionsMutator = new SessionsMutator(allSessions).filterSessionsBetween(dayAgo, now);
|
||||||
List<Session> sessionsWeek = profile.getSessions(weekAgo, now).collect(Collectors.toList());
|
SessionsMutator weekSessionsMutator = new SessionsMutator(allSessions).filterSessionsBetween(weekAgo, now);
|
||||||
List<Session> sessionsMonth = profile.getSessions(monthAgo, now).collect(Collectors.toList());
|
SessionsMutator monthSessionsMutator = new SessionsMutator(allSessions).filterSessionsBetween(monthAgo, now);
|
||||||
|
|
||||||
long playtime = PlayerProfile.getPlaytime(allSessions.stream());
|
long playtime = allSessionsMutator.toPlaytime();
|
||||||
long playtimeDay = PlayerProfile.getPlaytime(sessionsDay.stream());
|
long playtimeDay = daySessionsMutator.toPlaytime();
|
||||||
long playtimeWeek = PlayerProfile.getPlaytime(sessionsWeek.stream());
|
long playtimeWeek = weekSessionsMutator.toPlaytime();
|
||||||
long playtimeMonth = PlayerProfile.getPlaytime(sessionsMonth.stream());
|
long playtimeMonth = monthSessionsMutator.toPlaytime();
|
||||||
|
|
||||||
long afk = PlayerProfile.getAFKTime(allSessions.stream());
|
long afk = allSessionsMutator.toAfkTime();
|
||||||
long afkDay = PlayerProfile.getAFKTime(sessionsDay.stream());
|
long afkDay = daySessionsMutator.toAfkTime();
|
||||||
long afkWeek = PlayerProfile.getAFKTime(sessionsWeek.stream());
|
long afkWeek = weekSessionsMutator.toAfkTime();
|
||||||
long afkMonth = PlayerProfile.getAFKTime(sessionsMonth.stream());
|
long afkMonth = monthSessionsMutator.toAfkTime();
|
||||||
|
|
||||||
long activeTotal = playtime - afk;
|
long activeTotal = playtime - afk;
|
||||||
|
|
||||||
long longestSession = PlayerProfile.getLongestSession(allSessions.stream());
|
long longestSession = allSessionsMutator.toLongestSessionLength();
|
||||||
long longestSessionDay = PlayerProfile.getLongestSession(sessionsDay.stream());
|
long longestSessionDay = daySessionsMutator.toLongestSessionLength();
|
||||||
long longestSessionWeek = PlayerProfile.getLongestSession(sessionsWeek.stream());
|
long longestSessionWeek = weekSessionsMutator.toLongestSessionLength();
|
||||||
long longestSessionMonth = PlayerProfile.getLongestSession(sessionsMonth.stream());
|
long longestSessionMonth = monthSessionsMutator.toLongestSessionLength();
|
||||||
|
|
||||||
long sessionMedian = PlayerProfile.getSessionMedian(allSessions.stream());
|
long sessionMedian = allSessionsMutator.toMedianSessionLength();
|
||||||
long sessionMedianDay = PlayerProfile.getSessionMedian(sessionsDay.stream());
|
long sessionMedianDay = daySessionsMutator.toMedianSessionLength();
|
||||||
long sessionMedianWeek = PlayerProfile.getSessionMedian(sessionsWeek.stream());
|
long sessionMedianWeek = weekSessionsMutator.toMedianSessionLength();
|
||||||
long sessionMedianMonth = PlayerProfile.getSessionMedian(sessionsMonth.stream());
|
long sessionMedianMonth = monthSessionsMutator.toMedianSessionLength();
|
||||||
|
|
||||||
int sessionCount = allSessions.size();
|
int sessionCount = allSessionsMutator.count();
|
||||||
int sessionCountDay = sessionsDay.size();
|
int sessionCountDay = daySessionsMutator.count();
|
||||||
int sessionCountWeek = sessionsWeek.size();
|
int sessionCountWeek = weekSessionsMutator.count();
|
||||||
int sessionCountMonth = sessionsMonth.size();
|
int sessionCountMonth = monthSessionsMutator.count();
|
||||||
|
|
||||||
long sessionAverage = MathUtils.averageLong(playtime, sessionCount);
|
long sessionAverage = allSessionsMutator.toAverageSessionLength();
|
||||||
long sessionAverageDay = MathUtils.averageLong(playtimeDay, sessionCountDay);
|
long sessionAverageDay = daySessionsMutator.toAverageSessionLength();
|
||||||
long sessionAverageWeek = MathUtils.averageLong(playtimeWeek, sessionCountWeek);
|
long sessionAverageWeek = weekSessionsMutator.toAverageSessionLength();
|
||||||
long sessionAverageMonth = MathUtils.averageLong(playtimeMonth, sessionCountMonth);
|
long sessionAverageMonth = monthSessionsMutator.toAverageSessionLength();
|
||||||
|
|
||||||
addValue("playtimeTotal", playtime > 0L ? FormatUtils.formatTimeAmount(playtime) : "-");
|
addValue("playtimeTotal", playtime > 0L ? FormatUtils.formatTimeAmount(playtime) : "-");
|
||||||
addValue("playtimeDay", playtimeDay > 0L ? FormatUtils.formatTimeAmount(playtimeDay) : "-");
|
addValue("playtimeDay", playtimeDay > 0L ? FormatUtils.formatTimeAmount(playtimeDay) : "-");
|
||||||
@ -208,11 +217,10 @@ public class InspectPage extends Page {
|
|||||||
addValue("sessionCountWeek", sessionCountWeek);
|
addValue("sessionCountWeek", sessionCountWeek);
|
||||||
addValue("sessionCountMonth", sessionCountMonth);
|
addValue("sessionCountMonth", sessionCountMonth);
|
||||||
|
|
||||||
List<Action> actions = profile.getAllActions();
|
addValue("tableBodyActions", new ActionsTable(Collections.singletonList(new Action(0, Actions.UNKNOWN, "Deprecated"))).parseBody());
|
||||||
addValue("tableBodyActions", new ActionsTable(actions).parseBody());
|
|
||||||
|
|
||||||
String punchCardData = new PunchCardGraph(allSessions).toHighChartsSeries();
|
String punchCardData = new PunchCardGraph(allSessions).toHighChartsSeries();
|
||||||
WorldTimes worldTimes = profile.getWorldTimes();
|
WorldTimes worldTimes = container.getValue(PlayerKeys.WORLD_TIMES).orElse(new WorldTimes(new HashMap<>()));
|
||||||
|
|
||||||
WorldPie worldPie = new WorldPie(worldTimes);
|
WorldPie worldPie = new WorldPie(worldTimes);
|
||||||
|
|
||||||
@ -241,13 +249,15 @@ public class InspectPage extends Page {
|
|||||||
addValue("mobKillCount", mobKillCount);
|
addValue("mobKillCount", mobKillCount);
|
||||||
addValue("deathCount", deathCount);
|
addValue("deathCount", deathCount);
|
||||||
|
|
||||||
ActivityIndex activityIndex = profile.getActivityIndex(now);
|
ActivityIndex activityIndex = new ActivityIndex(container, now);
|
||||||
|
|
||||||
addValue("activityIndexNumber", activityIndex.getFormattedValue());
|
addValue("activityIndexNumber", activityIndex.getFormattedValue());
|
||||||
addValue("activityIndexColor", activityIndex.getColor());
|
addValue("activityIndexColor", activityIndex.getColor());
|
||||||
addValue("activityIndex", activityIndex.getGroup());
|
addValue("activityIndex", activityIndex.getGroup());
|
||||||
|
|
||||||
addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp()));
|
addValue("playerStatus", HtmlStructure.playerStatus(online,
|
||||||
|
container.getValue(PlayerKeys.BANNED).orElse(false),
|
||||||
|
container.getValue(PlayerKeys.OPERATOR).orElse(false)));
|
||||||
|
|
||||||
if (!InfoSystem.getInstance().getConnectionSystem().isServerAvailable()) {
|
if (!InfoSystem.getInstance().getConnectionSystem().isServerAvailable()) {
|
||||||
addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||||
|
@ -179,7 +179,7 @@ public class HtmlStructure {
|
|||||||
"})</script>";
|
"})</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String playerStatus(String online, Set<UUID> banned, boolean op) {
|
public static String playerStatus(String online, boolean banned, boolean op) {
|
||||||
boolean offline = "offline".equalsIgnoreCase(online);
|
boolean offline = "offline".equalsIgnoreCase(online);
|
||||||
|
|
||||||
StringBuilder html = new StringBuilder("<p>");
|
StringBuilder html = new StringBuilder("<p>");
|
||||||
@ -192,9 +192,8 @@ public class HtmlStructure {
|
|||||||
if (op) {
|
if (op) {
|
||||||
html.append("<p>").append(Html.FA_COLORED_ICON.parse("blue", "superpowers")).append(" Operator</p>");
|
html.append("<p>").append(Html.FA_COLORED_ICON.parse("blue", "superpowers")).append(" Operator</p>");
|
||||||
}
|
}
|
||||||
int bannedOn = banned.size();
|
if (banned) {
|
||||||
if (bannedOn != 0) {
|
html.append("<p>").append(Html.FA_COLORED_ICON.parse("red", "gavel")).append(" Banned");
|
||||||
html.append("<p>").append(Html.FA_COLORED_ICON.parse("red", "gavel")).append(" Banned (").append(bannedOn).append(")");
|
|
||||||
}
|
}
|
||||||
return html.toString();
|
return html.toString();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,10 @@ package com.djrapitops.plan.utilities.html.structure;
|
|||||||
|
|
||||||
import com.djrapitops.plan.data.PlayerProfile;
|
import com.djrapitops.plan.data.PlayerProfile;
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
|
import com.djrapitops.plan.data.store.containers.DataContainer;
|
||||||
|
import com.djrapitops.plan.data.store.containers.PerServerData;
|
||||||
|
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||||
|
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||||
import com.djrapitops.plan.data.time.WorldTimes;
|
import com.djrapitops.plan.data.time.WorldTimes;
|
||||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||||
@ -14,9 +18,7 @@ import com.djrapitops.plan.utilities.analysis.MathUtils;
|
|||||||
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||||
import com.djrapitops.plugin.utilities.Format;
|
import com.djrapitops.plugin.utilities.Format;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML utility class for creating a Server Accordion.
|
* HTML utility class for creating a Server Accordion.
|
||||||
@ -27,31 +29,43 @@ public class ServerAccordion extends AbstractAccordion {
|
|||||||
|
|
||||||
private final StringBuilder viewScript;
|
private final StringBuilder viewScript;
|
||||||
|
|
||||||
public ServerAccordion(PlayerProfile profile, Map<UUID, String> serverNames) {
|
private final Map<UUID, String> serverNames;
|
||||||
|
private PerServerData perServer;
|
||||||
|
|
||||||
|
public ServerAccordion(PlayerContainer container, Map<UUID, WorldTimes> worldTimesPerServer, Map<UUID, String> serverNames) {
|
||||||
super("server_accordion");
|
super("server_accordion");
|
||||||
|
|
||||||
viewScript = new StringBuilder();
|
viewScript = new StringBuilder();
|
||||||
|
|
||||||
Map<UUID, WorldTimes> worldTimesPerServer = profile.getWorldTimesPerServer();
|
this.serverNames = serverNames;
|
||||||
if (worldTimesPerServer.isEmpty()) {
|
Optional<PerServerData> perServerData = container.getValue(PlayerKeys.PER_SERVER);
|
||||||
|
if (perServerData.isPresent()) {
|
||||||
|
perServer = perServerData.get();
|
||||||
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
addElements(profile, serverNames, worldTimesPerServer);
|
addElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toViewScript() {
|
public String toViewScript() {
|
||||||
return viewScript.toString();
|
return viewScript.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addElements(PlayerProfile profile, Map<UUID, String> serverNames, Map<UUID, WorldTimes> worldTimesPerServer) {
|
private void addElements() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Map.Entry<UUID, WorldTimes> entry : worldTimesPerServer.entrySet()) {
|
for (Map.Entry<UUID, DataContainer> entry : perServer.entrySet()) {
|
||||||
UUID serverUUID = entry.getKey();
|
UUID serverUUID = entry.getKey();
|
||||||
|
DataContainer container = entry.getValue();
|
||||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||||
WorldTimes worldTimes = entry.getValue();
|
WorldTimes worldTimes = container.getValue(PlayerKeys.WORLD_TIMES).orElse(new WorldTimes(new HashMap<>()));
|
||||||
|
|
||||||
|
List<Session> sessions = container.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>());
|
||||||
|
|
||||||
|
boolean banned = container.getValue(PlayerKeys.BANNED).orElse(false);
|
||||||
|
boolean opeator = container.getValue(PlayerKeys.OPERATOR).orElse(false);
|
||||||
|
long registered = container.getValue(PlayerKeys.REGISTERED).orElse(0L);
|
||||||
|
|
||||||
List<Session> sessions = profile.getSessions(serverUUID);
|
|
||||||
long playtime = PlayerProfile.getPlaytime(sessions.stream());
|
long playtime = PlayerProfile.getPlaytime(sessions.stream());
|
||||||
long afkTime = PlayerProfile.getAFKTime(sessions.stream());
|
long afkTime = PlayerProfile.getAFKTime(sessions.stream());
|
||||||
int sessionCount = sessions.size();
|
int sessionCount = sessions.size();
|
||||||
@ -81,6 +95,11 @@ public class ServerAccordion extends AbstractAccordion {
|
|||||||
String title = serverName + "<span class=\"pull-right\">" + play + "</span>";
|
String title = serverName + "<span class=\"pull-right\">" + play + "</span>";
|
||||||
|
|
||||||
String leftSide = new AccordionElementContentBuilder()
|
String leftSide = new AccordionElementContentBuilder()
|
||||||
|
.addRowBold("blue", "superpowers", "Operator", opeator ? "Yes" : "No")
|
||||||
|
.addRowBold("red", "gavel", "Banned", banned ? "Yes" : "No")
|
||||||
|
.addRowBold("light-green", "user-plus", "Registered",
|
||||||
|
registered != 0 ? FormatUtils.formatTimeStampDay(registered) : "Not registered")
|
||||||
|
.addBreak()
|
||||||
.addRowBold("teal", "calendar-check-o", "Sessions", sessionCount)
|
.addRowBold("teal", "calendar-check-o", "Sessions", sessionCount)
|
||||||
.addRowBold("green", "clock-o", "Server Playtime", play)
|
.addRowBold("green", "clock-o", "Server Playtime", play)
|
||||||
.addRowBold("grey", "clock-o", "Time AFK", afk)
|
.addRowBold("grey", "clock-o", "Time AFK", afk)
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
package com.djrapitops.plan.utilities.html.tables;
|
package com.djrapitops.plan.utilities.html.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.data.element.TableContainer;
|
import com.djrapitops.plan.data.element.TableContainer;
|
||||||
|
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||||
|
import com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -18,7 +20,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class NicknameTable extends TableContainer {
|
public class NicknameTable extends TableContainer {
|
||||||
|
|
||||||
public NicknameTable(Map<UUID, List<String>> nicknames, Map<UUID, String> serverNames) {
|
public NicknameTable(List<Nickname> nicknames, Map<UUID, String> serverNames) {
|
||||||
super("Nickname", "Server");
|
super("Nickname", "Server");
|
||||||
|
|
||||||
if (nicknames.isEmpty()) {
|
if (nicknames.isEmpty()) {
|
||||||
@ -28,15 +30,16 @@ public class NicknameTable extends TableContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addValues(Map<UUID, List<String>> nicknames, Map<UUID, String> serverNames) {
|
private void addValues(List<Nickname> nicknames, Map<UUID, String> serverNames) {
|
||||||
for (Map.Entry<UUID, List<String>> entry : nicknames.entrySet()) {
|
for (Nickname nickname : nicknames) {
|
||||||
String serverName = serverNames.getOrDefault(entry.getKey(), "Unknown");
|
UUID serverUUID = nickname.getServerUUID();
|
||||||
for (String nick : entry.getValue()) {
|
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||||
|
long lastUsed = nickname.getLastUsed();
|
||||||
addRow(
|
addRow(
|
||||||
HtmlUtils.swapColorsToSpan(HtmlUtils.removeXSS(nick)),
|
HtmlUtils.swapColorsToSpan(HtmlUtils.removeXSS(nickname.getName())),
|
||||||
serverName
|
serverName,
|
||||||
|
lastUsed != 0 ? FormatUtils.formatTimeStampDay(lastUsed) : "-"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user