use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ServerPageExporter method exportHtml.
private void exportHtml(Path toDirectory, Server server) throws IOException {
ServerUUID serverUUID = server.getUuid();
Path to = toDirectory.resolve(serverInfo.getServer().isProxy() ? "server/" + toFileName(server.getName()) : "server").resolve("index.html");
Page page = pageFactory.serverPage(serverUUID);
// Fixes refreshingJsonRequest ignoring old data of export
String html = StringUtils.replaceEach(page.toHtml(), new String[] { "loadOptimizedPerformanceGraph, 'performance', true);", "loadServerCalendar, 'online-activity-overview', true);", "}, 'playerlist', true);", "<head>" }, new String[] { "loadOptimizedPerformanceGraph, 'performance');", "loadServerCalendar, 'online-activity-overview');", "}, 'playerlist');", "<head><style>.refresh-element {display: none;}</style>" });
export(to, exportPaths.resolveExportPaths(html));
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PingMutator method addPingToSessions.
public void addPingToSessions(List<FinishedSession> sessions) {
if (sessions.isEmpty())
return;
Comparator<DateHolder> comparator = new DateHolderOldestComparator();
sessions.sort(comparator);
pings.sort(comparator);
Map<ServerUUID, SortedMap<Long, Ping>> pingByServer = sortByServers(pings);
Map<ServerUUID, List<FinishedSession>> sessionsByServer = SessionsMutator.sortByServers(sessions);
for (Map.Entry<ServerUUID, SortedMap<Long, Ping>> entry : pingByServer.entrySet()) {
ServerUUID serverUUID = entry.getKey();
SortedMap<Long, Ping> pingOfServer = entry.getValue();
if (pingOfServer.isEmpty())
continue;
List<FinishedSession> sessionsOfServer = sessionsByServer.getOrDefault(serverUUID, Collections.emptyList());
double pingCount = 0.0;
int pingEntries = 0;
for (FinishedSession session : sessionsOfServer) {
long start = session.getDate();
long end = session.getEnd();
if (end < start)
continue;
// Calculate average ping for each session with a section of the Ping map
SortedMap<Long, Ping> duringSession = pingOfServer.subMap(start, end);
for (Ping ping : duringSession.values()) {
pingCount += ping.getAverage();
pingEntries++;
}
if (pingEntries != 0) {
session.getExtraData().put(AveragePing.class, new AveragePing(pingCount / pingEntries));
}
pingCount = 0.0;
pingEntries = 0;
}
}
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PingMutator method sortByServers.
public static Map<ServerUUID, SortedMap<Long, Ping>> sortByServers(List<Ping> pings) {
Map<ServerUUID, SortedMap<Long, Ping>> sorted = new HashMap<>();
for (Ping ping : pings) {
ServerUUID serverUUID = ping.getServerUUID();
SortedMap<Long, Ping> serverSessions = sorted.getOrDefault(serverUUID, new TreeMap<>());
serverSessions.put(ping.getDate(), ping);
sorted.put(serverUUID, serverSessions);
}
return sorted;
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ServerAccordion method asMaps.
public List<Map<String, Object>> asMaps() {
List<Map<String, Object>> servers = new ArrayList<>();
for (Map.Entry<ServerUUID, DataContainer> entry : perServer.entrySet()) {
ServerUUID serverUUID = entry.getKey();
DataContainer ofServer = entry.getValue();
Map<String, Object> server = new HashMap<>();
String serverName = serverNames.getOrDefault(serverUUID, unknown);
WorldTimes worldTimes = ofServer.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes());
SessionsMutator sessionsMutator = SessionsMutator.forContainer(ofServer);
server.put("server_name", serverName);
server.put("banned", ofServer.getValue(PerServerKeys.BANNED).orElse(false));
server.put("operator", ofServer.getValue(PerServerKeys.OPERATOR).orElse(false));
server.put("registered", year.apply(ofServer.getValue(PerServerKeys.REGISTERED).orElse(0L)));
server.put("last_seen", year.apply(sessionsMutator.toLastSeen()));
server.put("join_address", ofServer.getValue(PerServerKeys.JOIN_ADDRESS).orElse("-"));
server.put("session_count", sessionsMutator.count());
server.put("playtime", timeAmount.apply(sessionsMutator.toPlaytime()));
server.put("afk_time", timeAmount.apply(sessionsMutator.toAfkTime()));
server.put("session_median", timeAmount.apply(sessionsMutator.toMedianSessionLength()));
server.put("longest_session_length", timeAmount.apply(sessionsMutator.toLongestSessionLength()));
server.put("mob_kills", sessionsMutator.toMobKillCount());
server.put("player_kills", sessionsMutator.toPlayerKillCount());
server.put("deaths", sessionsMutator.toDeathCount());
WorldPie worldPie = graphs.pie().worldPie(worldTimes);
server.put("world_pie_series", worldPie.getSlices());
server.put("gm_series", worldPie.toHighChartsDrillDownMaps());
servers.add(server);
}
return servers;
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PlayerOnlineListener method actOnQuitEvent.
private void actOnQuitEvent(ClientConnectionEvent.Disconnect event) {
long time = System.currentTimeMillis();
Player player = event.getTargetEntity();
String playerName = player.getName();
UUID playerUUID = player.getUniqueId();
ServerUUID serverUUID = serverInfo.getServerUUID();
SpongeAFKListener.afkTracker.loggedOut(playerUUID, time);
nicknameCache.removeDisplayName(playerUUID);
dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID, () -> isBanned(player.getProfile())));
sessionCache.endSession(playerUUID, time).ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new SessionEndTransaction(endedSession)));
if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
}
}
Aggregations