diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/mutators/TPSMutator.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/mutators/TPSMutator.java index 776890c3d..c362877c0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/mutators/TPSMutator.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/mutators/TPSMutator.java @@ -183,6 +183,13 @@ public class TPSMutator { return spikeCount; } + public int averagePlayers() { + return (int) tpsData.stream() + .mapToInt(TPS::getPlayers) + .filter(num -> num >= 0) + .average().orElse(-1); + } + public double averageTPS() { return tpsData.stream() .mapToDouble(TPS::getTicksPerSecond) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PerformanceJSONCreator.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PerformanceJSONCreator.java index ed45f7339..3cfde9f42 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PerformanceJSONCreator.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PerformanceJSONCreator.java @@ -104,6 +104,9 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator + + Average Players + + + + Average TPS diff --git a/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/fabric/PlayerOnlineListener.java b/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/fabric/PlayerOnlineListener.java index cd03926cd..368c5cab6 100644 --- a/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/fabric/PlayerOnlineListener.java +++ b/Plan/fabric/src/main/java/net/playeranalytics/plan/gathering/listeners/fabric/PlayerOnlineListener.java @@ -206,7 +206,7 @@ public class PlayerOnlineListener implements FabricListener { session.getExtraData().put(ServerName.class, new ServerName(serverInfo.getServer().getIdentifiableName())); session.getExtraData().put(JoinAddress.class, new JoinAddress(getHostName)); sessionCache.cacheSession(playerUUID, session) - .ifPresent(previousSession -> database.executeTransaction(new SessionEndTransaction(previousSession))); + .ifPresent(previousSession -> database.executeTransaction(new StoreSessionTransaction(previousSession))); database.executeTransaction(new NicknameStoreTransaction( playerUUID, new Nickname(displayName, time, serverUUID), @@ -225,7 +225,7 @@ public class PlayerOnlineListener implements FabricListener { if (socketAddress == null) return; InetAddress address = InetAddresses.forString(socketAddress.getAddress().toString().replace("/", "")); database.executeTransaction( - new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry) + new StoreGeoInfoTransaction(playerUUID, address, time, geolocationCache::getCountry) ); } @@ -264,7 +264,7 @@ public class PlayerOnlineListener implements FabricListener { dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID, () -> server.getPlayerManager().getUserBanList().contains(player.getGameProfile()))); sessionCache.endSession(playerUUID, time) - .ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new SessionEndTransaction(endedSession))); + .ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new StoreSessionTransaction(endedSession))); if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));