mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-02 21:41:28 +01:00
Refactoring: ActiveSession, FinishedSession and ServerUUID
- Split Session into ActiveSession and FinishedSession, replaced their usage - Replaced UUID with ServerUUID when the data type Affects issues: - Close #1746
This commit is contained in:
parent
009ac2ad57
commit
8f85c23c2f
@ -23,6 +23,7 @@ import com.djrapitops.plan.gathering.importing.data.BukkitUserImportRefiner;
|
||||
import com.djrapitops.plan.gathering.importing.data.ServerImportData;
|
||||
import com.djrapitops.plan.gathering.importing.data.UserImportData;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.LargeStoreQueries;
|
||||
@ -43,7 +44,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public abstract class BukkitImporter implements Importer {
|
||||
|
||||
protected final Supplier<UUID> serverUUID;
|
||||
protected final Supplier<ServerUUID> serverUUID;
|
||||
private final GeolocationCache geolocationCache;
|
||||
private final DBSystem dbSystem;
|
||||
private final String name;
|
||||
@ -115,7 +116,7 @@ public abstract class BukkitImporter implements Importer {
|
||||
Map<UUID, BaseUser> users = new HashMap<>();
|
||||
List<UserInfo> userInfo = new ArrayList<>();
|
||||
Map<UUID, List<Nickname>> nickNames = new HashMap<>();
|
||||
List<Session> sessions = new ArrayList<>();
|
||||
List<FinishedSession> sessions = new ArrayList<>();
|
||||
Map<UUID, List<GeoInfo>> geoInfo = new HashMap<>();
|
||||
|
||||
userImportData.parallelStream().forEach(data -> {
|
||||
@ -139,7 +140,7 @@ public abstract class BukkitImporter implements Importer {
|
||||
protected void performOperations() {
|
||||
execute(LargeStoreQueries.storeAllCommonUserInformation(users.values()));
|
||||
execute(LargeStoreQueries.storeAllSessionsWithKillAndWorldData(sessions));
|
||||
Map<UUID, List<UserInfo>> userInformation = Collections.singletonMap(serverUUID.get(), userInfo);
|
||||
Map<ServerUUID, List<UserInfo>> userInformation = Collections.singletonMap(serverUUID.get(), userInfo);
|
||||
execute(LargeStoreQueries.storePerServerUserInformation(userInformation));
|
||||
execute(LargeStoreQueries.storeAllNicknameData(Collections.singletonMap(serverUUID.get(), nickNames)));
|
||||
execute(LargeStoreQueries.storeAllGeoInformation(geoInfo));
|
||||
@ -177,16 +178,17 @@ public abstract class BukkitImporter implements Importer {
|
||||
return new UserInfo(uuid, serverUUID.get(), registered, op, hostname, banned);
|
||||
}
|
||||
|
||||
private Session toSession(UserImportData userImportData) {
|
||||
private FinishedSession toSession(UserImportData userImportData) {
|
||||
int mobKills = userImportData.getMobKills();
|
||||
int deaths = userImportData.getDeaths();
|
||||
|
||||
Session session = new Session(0, userImportData.getUuid(), serverUUID.get(), 0L, 0L, mobKills, deaths, 0);
|
||||
DataMap extraData = new DataMap();
|
||||
extraData.put(MobKillCounter.class, new MobKillCounter(mobKills));
|
||||
extraData.put(DeathCounter.class, new DeathCounter(deaths));
|
||||
extraData.put(WorldTimes.class, new WorldTimes(userImportData.getWorldTimes()));
|
||||
extraData.put(PlayerKills.class, new PlayerKills(userImportData.getKills()));
|
||||
|
||||
session.setPlayerKills(userImportData.getKills());
|
||||
session.setWorldTimes(new WorldTimes(userImportData.getWorldTimes()));
|
||||
|
||||
return session;
|
||||
return new FinishedSession(userImportData.getUuid(), serverUUID.get(), 0L, 0L, 0, extraData);
|
||||
}
|
||||
|
||||
private List<GeoInfo> convertGeoInfo(UserImportData userImportData) {
|
||||
|
@ -19,7 +19,7 @@ package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
import com.djrapitops.plan.delivery.formatting.EntityNameFormatter;
|
||||
import com.djrapitops.plan.delivery.formatting.ItemNameFormatter;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
||||
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
||||
@ -64,7 +64,7 @@ public class DeathEventListener implements Listener {
|
||||
|
||||
if (dead instanceof Player) {
|
||||
// Process Death
|
||||
SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(Session::died);
|
||||
SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(ActiveSession::addDeath);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -17,7 +17,7 @@
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
@ -81,7 +81,7 @@ public class GameModeChangeListener implements Listener {
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<Session> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
|
||||
}
|
||||
}
|
||||
|
@ -17,16 +17,18 @@
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.Nickname;
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.domain.PlayerName;
|
||||
import com.djrapitops.plan.delivery.domain.ServerName;
|
||||
import com.djrapitops.plan.delivery.export.Exporter;
|
||||
import com.djrapitops.plan.extension.CallEvents;
|
||||
import com.djrapitops.plan.extension.ExtensionSvc;
|
||||
import com.djrapitops.plan.gathering.cache.NicknameCache;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.gathering.geolocation.GeolocationCache;
|
||||
import com.djrapitops.plan.gathering.listeners.Status;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||
@ -147,7 +149,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
ServerUUID serverUUID = serverInfo.getServerUUID();
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
BukkitAFKListener.AFK_TRACKER.performedAction(playerUUID, time);
|
||||
@ -174,9 +176,9 @@ public class PlayerOnlineListener implements Listener {
|
||||
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID,
|
||||
player::getFirstPlayed, playerName, serverUUID, hostname));
|
||||
|
||||
Session session = new Session(playerUUID, serverUUID, time, world, gm);
|
||||
session.putRawData(SessionKeys.NAME, playerName);
|
||||
session.putRawData(SessionKeys.SERVER_NAME, serverInfo.getServer().getIdentifiableName());
|
||||
ActiveSession session = new ActiveSession(playerUUID, serverUUID, time, world, gm);
|
||||
session.getExtraData().put(PlayerName.class, new PlayerName(playerName));
|
||||
session.getExtraData().put(ServerName.class, new ServerName(serverInfo.getServer().getIdentifiableName()));
|
||||
sessionCache.cacheSession(playerUUID, session)
|
||||
.ifPresent(previousSession -> database.executeTransaction(new SessionEndTransaction(previousSession)));
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
package com.djrapitops.plan.gathering.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
@ -75,7 +75,7 @@ public class WorldChangeListener implements Listener {
|
||||
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
|
||||
worldAliasSettings.addWorld(worldName);
|
||||
|
||||
Optional<Session> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
Optional<ActiveSession> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,13 @@
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.listeners.bungee;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.domain.PlayerName;
|
||||
import com.djrapitops.plan.delivery.domain.ServerName;
|
||||
import com.djrapitops.plan.delivery.export.Exporter;
|
||||
import com.djrapitops.plan.extension.CallEvents;
|
||||
import com.djrapitops.plan.extension.ExtensionSvc;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.gathering.geolocation.GeolocationCache;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
@ -101,9 +102,9 @@ public class PlayerOnlineListener implements Listener {
|
||||
InetAddress address = player.getAddress().getAddress();
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
Session session = new Session(playerUUID, serverInfo.getServerUUID(), time, null, null);
|
||||
session.putRawData(SessionKeys.NAME, playerName);
|
||||
session.putRawData(SessionKeys.SERVER_NAME, "Proxy Server");
|
||||
ActiveSession session = new ActiveSession(playerUUID, serverInfo.getServerUUID(), time, null, null);
|
||||
session.getExtraData().put(PlayerName.class, new PlayerName(playerName));
|
||||
session.getExtraData().put(ServerName.class, new ServerName("Proxy Server"));
|
||||
sessionCache.cacheSession(playerUUID, session);
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
@ -165,9 +166,9 @@ public class PlayerOnlineListener implements Listener {
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
// Replaces the current session in the cache.
|
||||
Session session = new Session(playerUUID, serverInfo.getServerUUID(), time, null, null);
|
||||
session.putRawData(SessionKeys.NAME, playerName);
|
||||
session.putRawData(SessionKeys.SERVER_NAME, "Proxy Server");
|
||||
ActiveSession session = new ActiveSession(playerUUID, serverInfo.getServerUUID(), time, null, null);
|
||||
session.getExtraData().put(PlayerName.class, new PlayerName(playerName));
|
||||
session.getExtraData().put(ServerName.class, new ServerName("Proxy Server"));
|
||||
sessionCache.cacheSession(playerUUID, session);
|
||||
if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
|
||||
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
|
||||
|
@ -27,7 +27,6 @@ import net.playeranalytics.plugin.server.PluginLogger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Manages Server information on the Bungee instance.
|
||||
@ -112,7 +111,7 @@ public class BungeeServerInfo extends ServerInfo {
|
||||
* @throws EnableException
|
||||
*/
|
||||
private Server createServerObject() {
|
||||
UUID serverUUID = generateNewUUID();
|
||||
ServerUUID serverUUID = generateNewUUID();
|
||||
String accessAddress = addresses.getAccessAddress().orElseThrow(() -> new EnableException("Velocity can not have '0.0.0.0' or '' as an address. Set up 'Server.IP' setting."));
|
||||
return new Server(-1, serverUUID, "BungeeCord", accessAddress, true);
|
||||
}
|
||||
|
@ -77,4 +77,8 @@ public interface DataService {
|
||||
|
||||
<P, S> DataService registerDBSupplier(Class<S> type, Class<P> parameterType, Function<P, Query<S>> supplierWithParameter);
|
||||
|
||||
interface Mapping {
|
||||
void register(DataService service);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.api.data.ServerContainer;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.identification.UUIDUtility;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
@ -36,6 +37,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PlanAPI extension for all implementations.
|
||||
@ -110,7 +112,8 @@ public class CommonAPI implements PlanAPI {
|
||||
|
||||
@Override
|
||||
public Collection<UUID> fetchServerUUIDs() {
|
||||
return queryDB(ServerQueries.fetchPlanServerInformation()).keySet();
|
||||
return queryDB(ServerQueries.fetchPlanServerInformation()).keySet()
|
||||
.stream().map(ServerUUID::asUUID).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.commands;
|
||||
import com.djrapitops.plan.SubSystem;
|
||||
import com.djrapitops.plan.delivery.domain.auth.User;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries;
|
||||
@ -73,8 +74,8 @@ public class TabCompleteCache implements SubSystem {
|
||||
}
|
||||
|
||||
private void refreshServerIdentifiers() {
|
||||
Map<UUID, Server> serverNames = dbSystem.getDatabase().query(ServerQueries.fetchPlanServerInformation());
|
||||
for (Map.Entry<UUID, Server> server : serverNames.entrySet()) {
|
||||
Map<ServerUUID, Server> serverNames = dbSystem.getDatabase().query(ServerQueries.fetchPlanServerInformation());
|
||||
for (Map.Entry<ServerUUID, Server> server : serverNames.entrySet()) {
|
||||
serverIdentifiers.add(server.getKey().toString());
|
||||
serverIdentifiers.add(server.getValue().getIdentifiableName());
|
||||
server.getValue().getId().ifPresent(id -> serverIdentifiers.add(Integer.toString(id)));
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain;
|
||||
|
||||
public class AveragePing {
|
||||
private final double value;
|
||||
|
||||
public AveragePing(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -16,8 +16,9 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Object storing nickname information.
|
||||
@ -28,9 +29,9 @@ public class Nickname implements DateHolder {
|
||||
|
||||
private final String name;
|
||||
private final long date;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public Nickname(String name, long date, UUID serverUUID) {
|
||||
public Nickname(String name, long date, ServerUUID serverUUID) {
|
||||
this.name = name;
|
||||
this.date = date;
|
||||
this.serverUUID = serverUUID;
|
||||
@ -45,7 +46,7 @@ public class Nickname implements DateHolder {
|
||||
return date;
|
||||
}
|
||||
|
||||
public UUID getServerUUID() {
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlayerName {
|
||||
private final String name;
|
||||
|
||||
public PlayerName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String get() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PlayerName that = (PlayerName) o;
|
||||
return Objects.equals(name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlayerName{" +
|
||||
"name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ServerName {
|
||||
private final String name;
|
||||
|
||||
public ServerName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String get() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ServerName that = (ServerName) o;
|
||||
return Objects.equals(name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerName{" +
|
||||
"name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -18,30 +18,33 @@ package com.djrapitops.plan.delivery.domain.container;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.keys.Key;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PerServerKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.Ping;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.UserInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Container for data about a player linked to a single server.
|
||||
* Container for data about a player linked.
|
||||
*
|
||||
* @author AuroraLS3
|
||||
* @see com.djrapitops.plan.delivery.domain.keys.PerServerKeys For Key objects.
|
||||
*/
|
||||
public class PerServerContainer extends HashMap<UUID, DataContainer> {
|
||||
public class PerServerContainer extends HashMap<ServerUUID, DataContainer> {
|
||||
|
||||
public <T> void putToContainerOfServer(UUID serverUUID, Key<T> key, T value) {
|
||||
public <T> void putToContainerOfServer(ServerUUID serverUUID, Key<T> key, T value) {
|
||||
DataContainer container = getOrDefault(serverUUID, new DynamicDataContainer());
|
||||
container.putRawData(key, value);
|
||||
put(serverUUID, container);
|
||||
}
|
||||
|
||||
public void putUserInfo(UserInfo userInfo) {
|
||||
UUID serverUUID = userInfo.getServerUUID();
|
||||
ServerUUID serverUUID = userInfo.getServerUUID();
|
||||
putToContainerOfServer(serverUUID, PerServerKeys.REGISTERED, userInfo.getRegistered());
|
||||
putToContainerOfServer(serverUUID, PerServerKeys.BANNED, userInfo.isBanned());
|
||||
putToContainerOfServer(serverUUID, PerServerKeys.OPERATOR, userInfo.isOperator());
|
||||
@ -64,22 +67,22 @@ public class PerServerContainer extends HashMap<UUID, DataContainer> {
|
||||
}
|
||||
}
|
||||
|
||||
public void putSessions(Collection<Session> sessions) {
|
||||
public void putSessions(Collection<FinishedSession> sessions) {
|
||||
if (sessions == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Session session : sessions) {
|
||||
for (FinishedSession session : sessions) {
|
||||
putSession(session);
|
||||
}
|
||||
}
|
||||
|
||||
private void putSession(Session session) {
|
||||
private void putSession(FinishedSession session) {
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UUID serverUUID = session.getUnsafe(SessionKeys.SERVER_UUID);
|
||||
ServerUUID serverUUID = session.getServerUUID();
|
||||
DataContainer container = getOrDefault(serverUUID, new DynamicDataContainer());
|
||||
if (!container.supports(PerServerKeys.SESSIONS)) {
|
||||
container.putRawData(PerServerKeys.SESSIONS, new ArrayList<>());
|
||||
@ -103,7 +106,7 @@ public class PerServerContainer extends HashMap<UUID, DataContainer> {
|
||||
return;
|
||||
}
|
||||
|
||||
UUID serverUUID = ping.getServerUUID();
|
||||
ServerUUID serverUUID = ping.getServerUUID();
|
||||
DataContainer container = getOrDefault(serverUUID, new DynamicDataContainer());
|
||||
if (!container.supports(PerServerKeys.PING)) {
|
||||
container.putRawData(PerServerKeys.PING, new ArrayList<>());
|
||||
|
@ -40,7 +40,7 @@ public class CommonKeys {
|
||||
public static final PlaceholderKey<Long> REGISTERED = new PlaceholderKey<>(Long.class, "registered");
|
||||
public static final Key<List<Ping>> PING = new Key<>(new Type<List<Ping>>() {}, "ping");
|
||||
|
||||
public static final Key<List<Session>> SESSIONS = new Key<>(new Type<List<Session>>() {}, "sessions");
|
||||
public static final Key<List<FinishedSession>> SESSIONS = new Key<>(new Type<List<FinishedSession>>() {}, "sessions");
|
||||
public static final Key<WorldTimes> WORLD_TIMES = new Key<>(WorldTimes.class, "world_times");
|
||||
public static final PlaceholderKey<Long> LAST_SEEN = new PlaceholderKey<>(Long.class, "lastSeen");
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class PerServerKeys {
|
||||
public static final Key<Long> REGISTERED = CommonKeys.REGISTERED;
|
||||
public static final Key<List<Ping>> PING = CommonKeys.PING;
|
||||
|
||||
public static final Key<List<Session>> SESSIONS = CommonKeys.SESSIONS;
|
||||
public static final Key<List<FinishedSession>> SESSIONS = CommonKeys.SESSIONS;
|
||||
public static final Key<WorldTimes> WORLD_TIMES = CommonKeys.WORLD_TIMES;
|
||||
|
||||
@Deprecated
|
||||
|
@ -46,8 +46,8 @@ public class PlayerKeys {
|
||||
public static final Key<List<GeoInfo>> GEO_INFO = new Key<>(new Type<List<GeoInfo>>() {}, "geo_info");
|
||||
public static final Key<List<Ping>> PING = CommonKeys.PING;
|
||||
|
||||
public static final Key<Session> ACTIVE_SESSION = new Key<>(Session.class, "active_session");
|
||||
public static final Key<List<Session>> SESSIONS = CommonKeys.SESSIONS;
|
||||
public static final Key<ActiveSession> ACTIVE_SESSION = new Key<>(ActiveSession.class, "active_session");
|
||||
public static final Key<List<FinishedSession>> SESSIONS = CommonKeys.SESSIONS;
|
||||
public static final Key<WorldTimes> WORLD_TIMES = CommonKeys.WORLD_TIMES;
|
||||
|
||||
public static final Key<List<PlayerKill>> PLAYER_KILLS = CommonKeys.PLAYER_KILLS;
|
||||
|
@ -45,7 +45,7 @@ public class ServerKeys {
|
||||
public static final Key<List<PlayerContainer>> OPERATORS = new Key<>(new Type<List<PlayerContainer>>() {}, "operators");
|
||||
public static final Key<Integer> PLAYER_COUNT = new Key<>(Integer.class, "player_count");
|
||||
|
||||
public static final Key<List<Session>> SESSIONS = CommonKeys.SESSIONS;
|
||||
public static final Key<List<FinishedSession>> SESSIONS = CommonKeys.SESSIONS;
|
||||
public static final Key<List<Ping>> PING = CommonKeys.PING;
|
||||
public static final Key<WorldTimes> WORLD_TIMES = CommonKeys.WORLD_TIMES;
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain.keys;
|
||||
|
||||
import com.djrapitops.plan.gathering.domain.PlayerDeath;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKill;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Class holding Key objects for Session (DataContainer).
|
||||
*
|
||||
* @author AuroraLS3
|
||||
* @see Session for DataContainer.
|
||||
*/
|
||||
public class SessionKeys {
|
||||
|
||||
public static final Key<Integer> DB_ID = new Key<>(Integer.class, "db_id");
|
||||
public static final Key<UUID> UUID = CommonKeys.UUID;
|
||||
public static final Key<UUID> SERVER_UUID = CommonKeys.SERVER_UUID;
|
||||
public static final Key<String> NAME = CommonKeys.NAME;
|
||||
public static final Key<String> SERVER_NAME = new Key<>(String.class, "server_name");
|
||||
|
||||
public static final Key<Long> START = new Key<>(Long.class, "start");
|
||||
public static final Key<Long> END = new Key<>(Long.class, "end");
|
||||
public static final Key<Long> LENGTH = new Key<>(Long.class, "length");
|
||||
public static final Key<Long> AFK_TIME = new Key<>(Long.class, "afk_time");
|
||||
public static final Key<Long> ACTIVE_TIME = new Key<>(Long.class, "active_time");
|
||||
public static final Key<WorldTimes> WORLD_TIMES = CommonKeys.WORLD_TIMES;
|
||||
public static final Key<List<PlayerKill>> PLAYER_KILLS = CommonKeys.PLAYER_KILLS;
|
||||
public static final Key<Integer> PLAYER_KILL_COUNT = CommonKeys.PLAYER_KILL_COUNT;
|
||||
public static final Key<Integer> MOB_KILL_COUNT = CommonKeys.MOB_KILL_COUNT;
|
||||
public static final Key<Integer> DEATH_COUNT = CommonKeys.DEATH_COUNT;
|
||||
public static final Key<Boolean> FIRST_SESSION = new Key<>(Boolean.class, "first_session");
|
||||
@Deprecated
|
||||
public static final Key<List<PlayerDeath>> PLAYER_DEATHS = CommonKeys.PLAYER_DEATHS;
|
||||
|
||||
/**
|
||||
* @deprecated use WorldAliasSettings#getLongestWorldPlayed(Session) instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Key<String> LONGEST_WORLD_PLAYED = new Key<>(String.class, "longest_world_played");
|
||||
public static final Key<Double> AVERAGE_PING = new Key<>(Double.class, "averagePing");
|
||||
|
||||
private SessionKeys() {
|
||||
/* Static variable class */
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ package com.djrapitops.plan.delivery.domain.mutators;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
|
||||
@ -74,7 +74,7 @@ public class ActivityIndex {
|
||||
value = calculate(container);
|
||||
}
|
||||
|
||||
public ActivityIndex(List<Session> sessions, long date, long playtimeMsThreshold) {
|
||||
public ActivityIndex(List<FinishedSession> sessions, long date, long playtimeMsThreshold) {
|
||||
this.playtimeMsThreshold = playtimeMsThreshold;
|
||||
|
||||
this.date = date;
|
||||
|
@ -20,8 +20,9 @@ import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.domain.container.PerServerContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PerServerKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -43,7 +44,7 @@ public class PerServerMutator {
|
||||
return new PerServerMutator(container.getValue(PlayerKeys.PER_SERVER).orElse(new PerServerContainer()));
|
||||
}
|
||||
|
||||
public List<Session> flatMapSessions() {
|
||||
public List<FinishedSession> flatMapSessions() {
|
||||
return data.values().stream()
|
||||
.filter(container -> container.supports(PerServerKeys.SESSIONS))
|
||||
.map(container -> container.getValue(PerServerKeys.SESSIONS).orElse(Collections.emptyList()))
|
||||
@ -64,20 +65,20 @@ public class PerServerMutator {
|
||||
return total;
|
||||
}
|
||||
|
||||
public Map<UUID, WorldTimes> worldTimesPerServer() {
|
||||
Map<UUID, WorldTimes> timesMap = new HashMap<>();
|
||||
for (Map.Entry<UUID, DataContainer> entry : data.entrySet()) {
|
||||
public Map<ServerUUID, WorldTimes> worldTimesPerServer() {
|
||||
Map<ServerUUID, WorldTimes> timesMap = new HashMap<>();
|
||||
for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
|
||||
DataContainer container = entry.getValue();
|
||||
timesMap.put(entry.getKey(), container.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes()));
|
||||
}
|
||||
return timesMap;
|
||||
}
|
||||
|
||||
public Optional<UUID> favoriteServer() {
|
||||
public Optional<ServerUUID> favoriteServer() {
|
||||
long max = 0;
|
||||
UUID maxServer = null;
|
||||
ServerUUID maxServer = null;
|
||||
|
||||
for (Map.Entry<UUID, DataContainer> entry : data.entrySet()) {
|
||||
for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
|
||||
long total = SessionsMutator.forContainer(entry.getValue()).toPlaytime();
|
||||
if (total > max) {
|
||||
max = total;
|
||||
@ -88,9 +89,9 @@ public class PerServerMutator {
|
||||
return Optional.ofNullable(maxServer);
|
||||
}
|
||||
|
||||
public Map<UUID, List<Session>> sessionsPerServer() {
|
||||
Map<UUID, List<Session>> sessionMap = new HashMap<>();
|
||||
for (Map.Entry<UUID, DataContainer> entry : data.entrySet()) {
|
||||
public Map<ServerUUID, List<FinishedSession>> sessionsPerServer() {
|
||||
Map<ServerUUID, List<FinishedSession>> sessionMap = new HashMap<>();
|
||||
for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
|
||||
sessionMap.put(entry.getKey(), entry.getValue().getValue(PerServerKeys.SESSIONS).orElse(new ArrayList<>()));
|
||||
}
|
||||
return sessionMap;
|
||||
|
@ -16,12 +16,13 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain.mutators;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.AveragePing;
|
||||
import com.djrapitops.plan.delivery.domain.DateHolder;
|
||||
import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.CommonKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.Ping;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.utilities.Predicates;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderOldestComparator;
|
||||
import com.djrapitops.plan.utilities.java.Lists;
|
||||
@ -45,8 +46,15 @@ public class PingMutator {
|
||||
return new PingMutator(Lists.filter(pings, predicate));
|
||||
}
|
||||
|
||||
public PingMutator filterByServer(UUID serverUUID) {
|
||||
return filterBy(ping -> serverUUID.equals(ping.getServerUUID()));
|
||||
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;
|
||||
}
|
||||
|
||||
public PingMutator mutateToByMinutePings() {
|
||||
@ -61,37 +69,30 @@ public class PingMutator {
|
||||
}));
|
||||
}
|
||||
|
||||
public static Map<UUID, SortedMap<Long, Ping>> sortByServers(List<Ping> pings) {
|
||||
Map<UUID, SortedMap<Long, Ping>> sorted = new HashMap<>();
|
||||
for (Ping ping : pings) {
|
||||
UUID serverUUID = ping.getServerUUID();
|
||||
SortedMap<Long, Ping> serverSessions = sorted.getOrDefault(serverUUID, new TreeMap<>());
|
||||
serverSessions.put(ping.getDate(), ping);
|
||||
sorted.put(serverUUID, serverSessions);
|
||||
}
|
||||
return sorted;
|
||||
public PingMutator filterByServer(ServerUUID serverUUID) {
|
||||
return filterBy(ping -> serverUUID.equals(ping.getServerUUID()));
|
||||
}
|
||||
|
||||
public void addPingToSessions(List<Session> sessions) {
|
||||
public void addPingToSessions(List<FinishedSession> sessions) {
|
||||
if (sessions.isEmpty()) return;
|
||||
|
||||
Comparator<DateHolder> comparator = new DateHolderOldestComparator();
|
||||
sessions.sort(comparator);
|
||||
pings.sort(comparator);
|
||||
Map<UUID, SortedMap<Long, Ping>> pingByServer = sortByServers(pings);
|
||||
Map<UUID, List<Session>> sessionsByServer = SessionsMutator.sortByServers(sessions);
|
||||
for (Map.Entry<UUID, SortedMap<Long, Ping>> entry : pingByServer.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
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<Session> sessionsOfServer = sessionsByServer.getOrDefault(serverUUID, Collections.emptyList());
|
||||
List<FinishedSession> sessionsOfServer = sessionsByServer.getOrDefault(serverUUID, Collections.emptyList());
|
||||
double pingCount = 0.0;
|
||||
int pingEntries = 0;
|
||||
|
||||
for (Session session : sessionsOfServer) {
|
||||
for (FinishedSession session : sessionsOfServer) {
|
||||
long start = session.getDate();
|
||||
Long end = session.getValue(SessionKeys.END).orElseGet(System::currentTimeMillis);
|
||||
long end = session.getEnd();
|
||||
if (end < start) continue;
|
||||
// Calculate average ping for each session with a Ping submap
|
||||
SortedMap<Long, Ping> duringSession = pingOfServer.subMap(start, end);
|
||||
@ -100,7 +101,7 @@ public class PingMutator {
|
||||
pingEntries++;
|
||||
}
|
||||
if (pingEntries != 0) {
|
||||
session.putRawData(SessionKeys.AVERAGE_PING, pingCount / pingEntries);
|
||||
session.getExtraData().put(AveragePing.class, new AveragePing(pingCount / pingEntries));
|
||||
}
|
||||
pingCount = 0.0;
|
||||
pingEntries = 0;
|
||||
|
@ -21,10 +21,10 @@ import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.domain.container.PlayerContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.ServerKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.GeoInfo;
|
||||
import com.djrapitops.plan.gathering.domain.Ping;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.utilities.java.Lists;
|
||||
import com.djrapitops.plan.utilities.java.Maps;
|
||||
import net.playeranalytics.plugin.scheduling.TimeAmount;
|
||||
@ -63,8 +63,8 @@ public class PlayersMutator {
|
||||
return filterBy(
|
||||
player -> player.getValue(PlayerKeys.SESSIONS)
|
||||
.map(sessions -> sessions.stream().anyMatch(session -> {
|
||||
long start = session.getValue(SessionKeys.START).orElse(-1L);
|
||||
long end = session.getValue(SessionKeys.END).orElse(-1L);
|
||||
long start = session.getStart();
|
||||
long end = session.getEnd();
|
||||
return (after <= start && start <= before) || (after <= end && end <= before);
|
||||
})).orElse(false)
|
||||
);
|
||||
@ -93,7 +93,7 @@ public class PlayersMutator {
|
||||
return filterBy(player -> player.getActivityIndex(date, msThreshold).getValue() >= limit);
|
||||
}
|
||||
|
||||
public PlayersMutator filterPlayedOnServer(UUID serverUUID) {
|
||||
public PlayersMutator filterPlayedOnServer(ServerUUID serverUUID) {
|
||||
return filterBy(player -> !SessionsMutator.forContainer(player)
|
||||
.filterPlayedOnServer(serverUUID)
|
||||
.all().isEmpty()
|
||||
@ -123,7 +123,7 @@ public class PlayersMutator {
|
||||
return geolocations;
|
||||
}
|
||||
|
||||
public Map<String, List<Ping>> getPingPerCountry(UUID serverUUID) {
|
||||
public Map<String, List<Ping>> getPingPerCountry(ServerUUID serverUUID) {
|
||||
Map<String, List<Ping>> pingPerCountry = new HashMap<>();
|
||||
for (PlayerContainer player : players) {
|
||||
Optional<GeoInfo> mostRecent = GeoInfoMutator.forContainer(player).mostRecent();
|
||||
@ -240,7 +240,7 @@ public class PlayersMutator {
|
||||
return new PlayersMutator(toBeRetained);
|
||||
}
|
||||
|
||||
public List<Session> getSessions() {
|
||||
public List<FinishedSession> getSessions() {
|
||||
return players.stream()
|
||||
.map(player -> player.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>()))
|
||||
.flatMap(Collection::stream)
|
||||
|
@ -16,17 +16,18 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain.mutators;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.AveragePing;
|
||||
import com.djrapitops.plan.delivery.domain.DateHolder;
|
||||
import com.djrapitops.plan.delivery.domain.PlayerName;
|
||||
import com.djrapitops.plan.delivery.domain.ServerName;
|
||||
import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.CommonKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.delivery.rendering.html.Html;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.Graphs;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKill;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.gathering.domain.*;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.utilities.analysis.Median;
|
||||
import com.djrapitops.plan.utilities.java.Lists;
|
||||
@ -45,18 +46,25 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class SessionsMutator {
|
||||
|
||||
private final List<Session> sessions;
|
||||
private final List<FinishedSession> sessions;
|
||||
|
||||
public static SessionsMutator forContainer(DataContainer container) {
|
||||
return new SessionsMutator(container.getValue(CommonKeys.SESSIONS).orElse(new ArrayList<>()));
|
||||
}
|
||||
|
||||
public SessionsMutator(List<Session> sessions) {
|
||||
public SessionsMutator(List<FinishedSession> sessions) {
|
||||
this.sessions = sessions;
|
||||
}
|
||||
|
||||
public List<Session> all() {
|
||||
return sessions;
|
||||
public static Map<UUID, List<FinishedSession>> sortByPlayers(List<FinishedSession> sessions) {
|
||||
Map<UUID, List<FinishedSession>> sorted = new HashMap<>();
|
||||
for (FinishedSession session : sessions) {
|
||||
UUID playerUUID = session.getPlayerUUID();
|
||||
List<FinishedSession> playerSessions = sorted.computeIfAbsent(playerUUID, Lists::create);
|
||||
playerSessions.add(session);
|
||||
sorted.put(playerUUID, playerSessions);
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
public SessionsMutator sort(Comparator<DateHolder> sessionComparator) {
|
||||
@ -64,13 +72,12 @@ public class SessionsMutator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Map<UUID, List<Session>> sortByPlayers(List<Session> sessions) {
|
||||
Map<UUID, List<Session>> sorted = new HashMap<>();
|
||||
for (Session session : sessions) {
|
||||
UUID playerUUID = session.getUnsafe(SessionKeys.UUID);
|
||||
List<Session> playerSessions = sorted.computeIfAbsent(playerUUID, Lists::create);
|
||||
playerSessions.add(session);
|
||||
sorted.put(playerUUID, playerSessions);
|
||||
public static Map<ServerUUID, List<FinishedSession>> sortByServers(List<FinishedSession> sessions) {
|
||||
Map<ServerUUID, List<FinishedSession>> sorted = new HashMap<>();
|
||||
for (FinishedSession session : sessions) {
|
||||
ServerUUID serverUUID = session.getServerUUID();
|
||||
List<FinishedSession> serverSessions = sorted.computeIfAbsent(serverUUID, Lists::create);
|
||||
serverSessions.add(session);
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
@ -79,23 +86,36 @@ public class SessionsMutator {
|
||||
return filterBy(getBetweenPredicate(after, before));
|
||||
}
|
||||
|
||||
public SessionsMutator filterPlayedOnServer(UUID serverUUID) {
|
||||
public static Map<ServerUUID, TreeMap<Long, FinishedSession>> sortByServersToMaps(List<FinishedSession> sessions) {
|
||||
Map<ServerUUID, TreeMap<Long, FinishedSession>> sorted = new HashMap<>();
|
||||
for (FinishedSession session : sessions) {
|
||||
ServerUUID serverUUID = session.getServerUUID();
|
||||
TreeMap<Long, FinishedSession> serverSessions = sorted.getOrDefault(serverUUID, new TreeMap<>());
|
||||
serverSessions.put(session.getDate(), session);
|
||||
sorted.put(serverUUID, serverSessions);
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
public List<FinishedSession> all() {
|
||||
return sessions;
|
||||
}
|
||||
|
||||
public SessionsMutator filterPlayedOnServer(ServerUUID serverUUID) {
|
||||
return filterBy(session ->
|
||||
session.getValue(SessionKeys.SERVER_UUID)
|
||||
.map(uuid -> uuid.equals(serverUUID))
|
||||
.orElse(false)
|
||||
session.getServerUUID().equals(serverUUID)
|
||||
);
|
||||
}
|
||||
|
||||
public DateHoldersMutator<Session> toDateHoldersMutator() {
|
||||
public DateHoldersMutator<FinishedSession> toDateHoldersMutator() {
|
||||
return new DateHoldersMutator<>(sessions);
|
||||
}
|
||||
|
||||
public WorldTimes toTotalWorldTimes() {
|
||||
WorldTimes total = new WorldTimes();
|
||||
|
||||
for (Session session : sessions) {
|
||||
session.getValue(SessionKeys.WORLD_TIMES).ifPresent(total::add);
|
||||
for (FinishedSession session : sessions) {
|
||||
session.getExtraData(WorldTimes.class).ifPresent(total::add);
|
||||
}
|
||||
|
||||
return total;
|
||||
@ -103,51 +123,49 @@ public class SessionsMutator {
|
||||
|
||||
public List<PlayerKill> toPlayerKillList() {
|
||||
return sessions.stream()
|
||||
.map(session -> session.getValue(SessionKeys.PLAYER_KILLS).orElse(new ArrayList<>()))
|
||||
.map(session -> session.getExtraData(PlayerKills.class).map(PlayerKills::asList).orElseGet(ArrayList::new))
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public int toMobKillCount() {
|
||||
return sessions.stream()
|
||||
.mapToInt(session -> session.getValue(SessionKeys.MOB_KILL_COUNT).orElse(0))
|
||||
.mapToInt(FinishedSession::getMobKillCount)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public int toDeathCount() {
|
||||
return sessions.stream()
|
||||
.mapToInt(session -> session.getValue(SessionKeys.DEATH_COUNT).orElse(0))
|
||||
.mapToInt(FinishedSession::getDeathCount)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public long toPlaytime() {
|
||||
return sessions.stream()
|
||||
.mapToLong(Session::getLength)
|
||||
.mapToLong(FinishedSession::getLength)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public long toAfkTime() {
|
||||
return sessions.stream()
|
||||
.mapToLong(session -> session.getValue(SessionKeys.AFK_TIME).orElse(0L))
|
||||
.mapToLong(FinishedSession::getAfkTime)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public long toActivePlaytime() {
|
||||
return sessions.stream()
|
||||
.mapToLong(session -> session.getValue(SessionKeys.ACTIVE_TIME).orElse(0L))
|
||||
.mapToLong(FinishedSession::getActiveTime)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public long toLastSeen() {
|
||||
return sessions.stream()
|
||||
.mapToLong(session -> Math.max(session.getUnsafe(
|
||||
SessionKeys.START),
|
||||
session.getValue(SessionKeys.END).orElse(System.currentTimeMillis()))
|
||||
).max().orElse(-1);
|
||||
.mapToLong(session -> Math.max(session.getStart(), session.getEnd())).max()
|
||||
.orElse(-1);
|
||||
}
|
||||
|
||||
public long toLongestSessionLength() {
|
||||
OptionalLong longestSession = sessions.stream().mapToLong(Session::getLength).max();
|
||||
OptionalLong longestSession = sessions.stream().mapToLong(FinishedSession::getLength).max();
|
||||
if (longestSession.isPresent()) {
|
||||
return longestSession.getAsLong();
|
||||
}
|
||||
@ -155,7 +173,7 @@ public class SessionsMutator {
|
||||
}
|
||||
|
||||
public long toAverageSessionLength() {
|
||||
OptionalDouble average = sessions.stream().map(Session::getLength)
|
||||
OptionalDouble average = sessions.stream().map(FinishedSession::getLength)
|
||||
.mapToLong(i -> i)
|
||||
.average();
|
||||
if (average.isPresent()) {
|
||||
@ -164,23 +182,6 @@ public class SessionsMutator {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static Map<UUID, List<Session>> sortByServers(List<Session> sessions) {
|
||||
Map<UUID, List<Session>> sorted = new HashMap<>();
|
||||
for (Session session : sessions) {
|
||||
UUID serverUUID = session.getUnsafe(SessionKeys.SERVER_UUID);
|
||||
List<Session> serverSessions = sorted.computeIfAbsent(serverUUID, Lists::create);
|
||||
serverSessions.add(session);
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
public int toUniquePlayers() {
|
||||
return (int) sessions.stream()
|
||||
.map(session -> session.getUnsafe(SessionKeys.UUID))
|
||||
.distinct()
|
||||
.count();
|
||||
}
|
||||
|
||||
public int count() {
|
||||
return sessions.size();
|
||||
}
|
||||
@ -193,41 +194,37 @@ public class SessionsMutator {
|
||||
return sessions.stream().anyMatch(getBetweenPredicate(after, before));
|
||||
}
|
||||
|
||||
private Predicate<Session> getBetweenPredicate(long after, long before) {
|
||||
public int toUniquePlayers() {
|
||||
return (int) sessions.stream()
|
||||
.map(FinishedSession::getPlayerUUID)
|
||||
.distinct()
|
||||
.count();
|
||||
}
|
||||
|
||||
private Predicate<FinishedSession> getBetweenPredicate(long after, long before) {
|
||||
return session -> {
|
||||
Long start = session.getUnsafe(SessionKeys.START);
|
||||
long end = session.getValue(SessionKeys.END).orElse(System.currentTimeMillis());
|
||||
long start = session.getStart();
|
||||
long end = session.getEnd();
|
||||
return after <= end && start <= before;
|
||||
};
|
||||
}
|
||||
|
||||
public SessionsMutator filterBy(Predicate<Session> predicate) {
|
||||
public SessionsMutator filterBy(Predicate<FinishedSession> predicate) {
|
||||
return new SessionsMutator(Lists.filter(sessions, predicate));
|
||||
}
|
||||
|
||||
public long toMedianSessionLength() {
|
||||
List<Long> sessionLengths = Lists.map(sessions, Session::getLength);
|
||||
List<Long> sessionLengths = Lists.map(sessions, FinishedSession::getLength);
|
||||
return (long) Median.forList(sessionLengths).calculate();
|
||||
}
|
||||
|
||||
public static Map<UUID, TreeMap<Long, Session>> sortByServersToMaps(List<Session> sessions) {
|
||||
Map<UUID, TreeMap<Long, Session>> sorted = new HashMap<>();
|
||||
for (Session session : sessions) {
|
||||
UUID serverUUID = session.getUnsafe(SessionKeys.SERVER_UUID);
|
||||
TreeMap<Long, Session> serverSessions = sorted.getOrDefault(serverUUID, new TreeMap<>());
|
||||
serverSessions.put(session.getDate(), session);
|
||||
sorted.put(serverUUID, serverSessions);
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
public int toPlayerDeathCount() {
|
||||
return sessions.stream().mapToInt(session -> session.getValue(SessionKeys.DEATH_COUNT).orElse(0)).sum();
|
||||
return sessions.stream().mapToInt(FinishedSession::getDeathCount).sum();
|
||||
}
|
||||
|
||||
public List<Long> toSessionStarts() {
|
||||
return sessions.stream()
|
||||
.map(Session::getDate)
|
||||
.map(FinishedSession::getStart)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@ -265,10 +262,10 @@ public class SessionsMutator {
|
||||
) {
|
||||
return Lists.map(sessions, session -> {
|
||||
Map<String, Object> sessionMap = new HashMap<>();
|
||||
String playerUUID = session.getUnsafe(SessionKeys.UUID).toString();
|
||||
String serverUUID = session.getUnsafe(SessionKeys.SERVER_UUID).toString();
|
||||
String playerName = session.getValue(SessionKeys.NAME).orElse(playerUUID);
|
||||
String serverName = session.getValue(SessionKeys.SERVER_NAME).orElse(serverUUID);
|
||||
String playerUUID = session.getPlayerUUID().toString();
|
||||
String serverUUID = session.getServerUUID().toString();
|
||||
String playerName = session.getExtraData(PlayerName.class).map(PlayerName::get).orElse(playerUUID);
|
||||
String serverName = session.getExtraData(ServerName.class).map(ServerName::get).orElse(serverUUID);
|
||||
sessionMap.put("player_name", playerName);
|
||||
sessionMap.put("player_url_name", Html.encodeToURL(playerName));
|
||||
sessionMap.put("player_uuid", playerUUID);
|
||||
@ -276,31 +273,32 @@ public class SessionsMutator {
|
||||
sessionMap.put("server_url_name", Html.encodeToURL(serverName));
|
||||
sessionMap.put("server_uuid", serverUUID);
|
||||
sessionMap.put("name", nameFunction.apply(sessionMap));
|
||||
sessionMap.put("start", session.getValue(SessionKeys.START).map(formatters.yearLong()).orElse("-") +
|
||||
(session.supports(SessionKeys.END) ? "" : " (Online)"));
|
||||
sessionMap.put("end", session.getValue(SessionKeys.END).map(formatters.yearLong()).orElse("Online"));
|
||||
sessionMap.put("start", formatters.yearLong().apply(session.getStart()) +
|
||||
(session.getExtraData(ActiveSession.class).isPresent() ? " (Online)" : ""));
|
||||
sessionMap.put("end", formatters.yearLong().apply(session.getEnd()));
|
||||
sessionMap.put("most_used_world", worldAliasSettings.getLongestWorldPlayed(session));
|
||||
sessionMap.put("length", session.getValue(SessionKeys.LENGTH).map(formatters.timeAmount()).orElse("-"));
|
||||
sessionMap.put("afk_time", session.getValue(SessionKeys.AFK_TIME).map(formatters.timeAmount()).orElse("-"));
|
||||
sessionMap.put("mob_kills", session.getValue(SessionKeys.MOB_KILL_COUNT).orElse(0));
|
||||
sessionMap.put("deaths", session.getValue(SessionKeys.DEATH_COUNT).orElse(0));
|
||||
sessionMap.put("player_kills", session.getPlayerKills().stream().map(
|
||||
kill -> {
|
||||
Map<String, Object> killMap = new HashMap<>();
|
||||
killMap.put("date", formatters.secondLong().apply(kill.getDate()));
|
||||
killMap.put("victim", kill.getVictimName().orElse(kill.getVictim().toString()));
|
||||
killMap.put("killer", playerName);
|
||||
killMap.put("weapon", kill.getWeapon());
|
||||
return killMap;
|
||||
}
|
||||
).collect(Collectors.toList()));
|
||||
sessionMap.put("first_session", session.getValue(SessionKeys.FIRST_SESSION).orElse(false));
|
||||
WorldPie worldPie = graphs.pie().worldPie(session.getValue(SessionKeys.WORLD_TIMES).orElse(new WorldTimes()));
|
||||
sessionMap.put("length", formatters.timeAmount().apply(session.getLength()));
|
||||
sessionMap.put("afk_time", formatters.timeAmount().apply(session.getAfkTime()));
|
||||
sessionMap.put("mob_kills", session.getMobKillCount());
|
||||
sessionMap.put("deaths", session.getDeathCount());
|
||||
sessionMap.put("player_kills", session.getExtraData(PlayerKills.class)
|
||||
.map(PlayerKills::asList).map(kills -> kills.stream().map(
|
||||
kill -> {
|
||||
Map<String, Object> killMap = new HashMap<>();
|
||||
killMap.put("date", formatters.secondLong().apply(kill.getDate()));
|
||||
killMap.put("victim", kill.getVictimName().orElse(kill.getVictim().toString()));
|
||||
killMap.put("killer", playerName);
|
||||
killMap.put("weapon", kill.getWeapon());
|
||||
return killMap;
|
||||
}).collect(Collectors.toList())
|
||||
).orElseGet(ArrayList::new));
|
||||
sessionMap.put("first_session", session.isFirstSession());
|
||||
WorldPie worldPie = graphs.pie().worldPie(session.getExtraData(WorldTimes.class).orElseGet(WorldTimes::new));
|
||||
sessionMap.put("world_series", worldPie.getSlices());
|
||||
sessionMap.put("gm_series", worldPie.toHighChartsDrillDownMaps());
|
||||
|
||||
session.getValue(SessionKeys.AVERAGE_PING).ifPresent(averagePing ->
|
||||
sessionMap.put("avg_ping", formatters.decimals().apply(averagePing) + " ms")
|
||||
session.getExtraData(AveragePing.class).ifPresent(averagePing ->
|
||||
sessionMap.put("avg_ping", formatters.decimals().apply(averagePing.getValue()) + " ms")
|
||||
);
|
||||
return sessionMap;
|
||||
});
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.delivery.export;
|
||||
import com.djrapitops.plan.delivery.web.resolver.exception.NotFoundException;
|
||||
import com.djrapitops.plan.exceptions.ExportException;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.ExportSettings;
|
||||
|
||||
@ -45,7 +46,7 @@ public class Exporter extends FileExporter {
|
||||
private final ServerPageExporter serverPageExporter;
|
||||
private final NetworkPageExporter networkPageExporter;
|
||||
|
||||
private final Set<UUID> failedServers;
|
||||
private final Set<ServerUUID> failedServers;
|
||||
|
||||
@Inject
|
||||
public Exporter(
|
||||
@ -74,7 +75,7 @@ public class Exporter extends FileExporter {
|
||||
* @throws ExportException If the export failed due to IO, NotFound or GenerationException.
|
||||
*/
|
||||
public boolean exportServerPage(Server server) throws ExportException {
|
||||
UUID serverUUID = server.getUuid();
|
||||
ServerUUID serverUUID = server.getUuid();
|
||||
if (failedServers.contains(serverUUID) || config.isFalse(ExportSettings.SERVER_PAGE)) return false;
|
||||
|
||||
try {
|
||||
@ -92,7 +93,7 @@ public class Exporter extends FileExporter {
|
||||
}
|
||||
|
||||
public boolean exportServerJSON(Server server) throws ExportException {
|
||||
UUID serverUUID = server.getUuid();
|
||||
ServerUUID serverUUID = server.getUuid();
|
||||
if (failedServers.contains(serverUUID) || config.isFalse(ExportSettings.SERVER_JSON)) return false;
|
||||
|
||||
try {
|
||||
|
@ -27,6 +27,7 @@ import com.djrapitops.plan.delivery.webserver.resolver.json.RootJSONResolver;
|
||||
import com.djrapitops.plan.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
@ -41,7 +42,6 @@ import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Handles exporting of /server page html, data and resources.
|
||||
@ -99,7 +99,7 @@ public class ServerPageExporter extends FileExporter {
|
||||
}
|
||||
|
||||
private void exportHtml(Path toDirectory, Server server) throws IOException {
|
||||
UUID serverUUID = server.getUuid();
|
||||
ServerUUID serverUUID = server.getUuid();
|
||||
Path to = toDirectory
|
||||
.resolve(serverInfo.getServer().isProxy() ? "server/" + toFileName(server.getName()) : "server")
|
||||
.resolve("index.html");
|
||||
|
@ -26,12 +26,10 @@ import com.djrapitops.plan.delivery.rendering.json.graphs.Graphs;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
|
||||
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerTableDataQuery;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Ping;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKill;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.gathering.domain.*;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
@ -83,7 +81,7 @@ public class JSONFactory {
|
||||
this.formatters = formatters;
|
||||
}
|
||||
|
||||
public Map<String, Object> serverPlayersTableJSON(UUID serverUUID) {
|
||||
public Map<String, Object> serverPlayersTableJSON(ServerUUID serverUUID) {
|
||||
Integer xMostRecentPlayers = config.get(DisplaySettings.PLAYERS_PER_SERVER_PAGE);
|
||||
Long playtimeThreshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
|
||||
boolean openPlayerLinksInNewTab = config.isTrue(DisplaySettings.OPEN_PLAYER_LINKS_IN_NEW_TAB);
|
||||
@ -105,7 +103,7 @@ public class JSONFactory {
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
UUID mainServerUUID = database.query(ServerQueries.fetchProxyServerInformation()).map(Server::getUuid).orElse(serverInfo.getServerUUID());
|
||||
ServerUUID mainServerUUID = database.query(ServerQueries.fetchProxyServerInformation()).map(Server::getUuid).orElse(serverInfo.getServerUUID());
|
||||
Map<UUID, ExtensionTabData> pluginData = database.query(new ExtensionServerTableDataQuery(mainServerUUID, xMostRecentPlayers));
|
||||
|
||||
return new PlayersTableJSONCreator(
|
||||
@ -116,14 +114,14 @@ public class JSONFactory {
|
||||
).toJSONMap();
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> serverSessionsAsJSONMap(UUID serverUUID) {
|
||||
public List<Map<String, Object>> serverSessionsAsJSONMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
|
||||
Integer perPageLimit = config.get(DisplaySettings.SESSIONS_PER_PAGE);
|
||||
List<Session> sessions = db.query(SessionQueries.fetchLatestSessionsOfServer(serverUUID, perPageLimit));
|
||||
List<FinishedSession> sessions = db.query(SessionQueries.fetchLatestSessionsOfServer(serverUUID, perPageLimit));
|
||||
// Add online sessions
|
||||
if (serverUUID.equals(serverInfo.getServerUUID())) {
|
||||
sessions.addAll(SessionCache.getActiveSessions().values());
|
||||
addActiveSessions(sessions);
|
||||
sessions.sort(new SessionStartComparator());
|
||||
while (true) {
|
||||
int size = sessions.size();
|
||||
@ -139,10 +137,10 @@ public class JSONFactory {
|
||||
Database db = dbSystem.getDatabase();
|
||||
Integer perPageLimit = config.get(DisplaySettings.SESSIONS_PER_PAGE);
|
||||
|
||||
List<Session> sessions = db.query(SessionQueries.fetchLatestSessions(perPageLimit));
|
||||
List<FinishedSession> sessions = db.query(SessionQueries.fetchLatestSessions(perPageLimit));
|
||||
// Add online sessions
|
||||
if (serverInfo.getServer().isProxy()) {
|
||||
sessions.addAll(SessionCache.getActiveSessions().values());
|
||||
addActiveSessions(sessions);
|
||||
sessions.sort(new SessionStartComparator());
|
||||
while (true) {
|
||||
int size = sessions.size();
|
||||
@ -157,7 +155,13 @@ public class JSONFactory {
|
||||
return sessionMaps;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> serverPlayerKillsAsJSONMap(UUID serverUUID) {
|
||||
public void addActiveSessions(List<FinishedSession> sessions) {
|
||||
for (ActiveSession activeSession : SessionCache.getActiveSessions()) {
|
||||
sessions.add(activeSession.toFinishedSessionFromStillActive());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> serverPlayerKillsAsJSONMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
List<PlayerKill> kills = db.query(KillQueries.fetchPlayerKillsOnServer(serverUUID, 100));
|
||||
return new PlayerKillMutator(kills).toJSONAsMap(formatters);
|
||||
@ -172,18 +176,18 @@ public class JSONFactory {
|
||||
Formatter<Double> decimals = formatters.decimals();
|
||||
Formatter<Long> timeAmount = formatters.timeAmount();
|
||||
|
||||
Map<UUID, Server> serverInformation = db.query(ServerQueries.fetchPlanServerInformation());
|
||||
UUID proxyUUID = serverInformation.values().stream()
|
||||
Map<ServerUUID, Server> serverInformation = db.query(ServerQueries.fetchPlanServerInformation());
|
||||
ServerUUID proxyUUID = serverInformation.values().stream()
|
||||
.filter(Server::isProxy)
|
||||
.findFirst()
|
||||
.map(Server::getUuid).orElse(null);
|
||||
|
||||
Map<UUID, List<TPS>> tpsData = db.query(
|
||||
Map<ServerUUID, List<TPS>> tpsData = db.query(
|
||||
TPSQueries.fetchTPSDataOfAllServersBut(weekAgo, now, proxyUUID)
|
||||
);
|
||||
Map<UUID, Integer> totalPlayerCounts = db.query(PlayerCountQueries.newPlayerCounts(0, now));
|
||||
Map<UUID, Integer> newPlayerCounts = db.query(PlayerCountQueries.newPlayerCounts(weekAgo, now));
|
||||
Map<UUID, Integer> uniquePlayerCounts = db.query(PlayerCountQueries.uniquePlayerCounts(weekAgo, now));
|
||||
Map<ServerUUID, Integer> totalPlayerCounts = db.query(PlayerCountQueries.newPlayerCounts(0, now));
|
||||
Map<ServerUUID, Integer> newPlayerCounts = db.query(PlayerCountQueries.newPlayerCounts(weekAgo, now));
|
||||
Map<ServerUUID, Integer> uniquePlayerCounts = db.query(PlayerCountQueries.uniquePlayerCounts(weekAgo, now));
|
||||
|
||||
List<Map<String, Object>> servers = new ArrayList<>();
|
||||
serverInformation.entrySet()
|
||||
@ -191,7 +195,7 @@ public class JSONFactory {
|
||||
.sorted(Comparator.comparing(entry -> entry.getValue().getIdentifiableName().toLowerCase()))
|
||||
.filter(entry -> entry.getValue().isNotProxy())
|
||||
.forEach(entry -> {
|
||||
UUID serverUUID = entry.getKey();
|
||||
ServerUUID serverUUID = entry.getKey();
|
||||
Map<String, Object> server = new HashMap<>();
|
||||
server.put("name", entry.getValue().getIdentifiableName());
|
||||
|
||||
@ -223,7 +227,7 @@ public class JSONFactory {
|
||||
return Collections.singletonMap("servers", servers);
|
||||
}
|
||||
|
||||
public Map<String, Object> pingPerGeolocation(UUID serverUUID) {
|
||||
public Map<String, Object> pingPerGeolocation(ServerUUID serverUUID) {
|
||||
Map<String, Ping> pingByGeolocation = dbSystem.getDatabase().query(PingQueries.fetchPingDataOfServerByGeolocation(serverUUID));
|
||||
return Maps.builder(String.class, Object.class)
|
||||
.put("table", turnToTableEntries(pingByGeolocation))
|
||||
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PlayersOnlineResolver;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.RetentionData;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
@ -24,6 +23,7 @@ import com.djrapitops.plan.delivery.domain.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
@ -72,14 +72,14 @@ public class OnlineActivityOverviewJSONCreator implements ServerTabJSONCreator<M
|
||||
percentageFormatter = formatters.percentage();
|
||||
}
|
||||
|
||||
public Map<String, Object> createJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> createJSONAsMap(ServerUUID serverUUID) {
|
||||
Map<String, Object> serverOverview = new HashMap<>();
|
||||
serverOverview.put("numbers", createNumbersMap(serverUUID));
|
||||
serverOverview.put("insights", createInsightsMap(serverUUID));
|
||||
return serverOverview;
|
||||
}
|
||||
|
||||
private Map<String, Object> createNumbersMap(UUID serverUUID) {
|
||||
private Map<String, Object> createNumbersMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long dayAgo = now - TimeUnit.DAYS.toMillis(1L);
|
||||
@ -199,7 +199,7 @@ public class OnlineActivityOverviewJSONCreator implements ServerTabJSONCreator<M
|
||||
return numbers;
|
||||
}
|
||||
|
||||
private Map<String, Object> createInsightsMap(UUID serverUUID) {
|
||||
private Map<String, Object> createInsightsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long halfMonthAgo = now - TimeUnit.DAYS.toMillis(15L);
|
||||
@ -213,7 +213,7 @@ public class OnlineActivityOverviewJSONCreator implements ServerTabJSONCreator<M
|
||||
|
||||
PlayersOnlineResolver playersOnlineResolver = new PlayersOnlineResolver(new TPSMutator(tpsData));
|
||||
SessionsMutator firstSessions = sessions.filterBy(session -> {
|
||||
long registered = registerDates.getOrDefault(session.getValue(SessionKeys.UUID).orElse(null), -501L);
|
||||
long registered = registerDates.getOrDefault(session.getPlayerUUID(), -501L);
|
||||
long start = session.getDate();
|
||||
return Math.abs(registered - start) < 500L;
|
||||
});
|
||||
|
@ -20,6 +20,7 @@ import com.djrapitops.plan.delivery.domain.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
@ -34,7 +35,6 @@ import javax.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -71,7 +71,8 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String,
|
||||
byteSize = formatters.byteSize();
|
||||
}
|
||||
|
||||
public Map<String, Object> createJSONAsMap(UUID serverUUID) {
|
||||
@Override
|
||||
public Map<String, Object> createJSONAsMap(ServerUUID serverUUID) {
|
||||
Map<String, Object> serverOverview = new HashMap<>();
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.delivery.rendering.json;
|
||||
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
@ -30,7 +31,6 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -60,14 +60,14 @@ public class PlayerBaseOverviewJSONCreator implements ServerTabJSONCreator<Map<S
|
||||
percentage = formatters.percentage();
|
||||
}
|
||||
|
||||
public Map<String, Object> createJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> createJSONAsMap(ServerUUID serverUUID) {
|
||||
Map<String, Object> serverOverview = new HashMap<>();
|
||||
serverOverview.put("trends", createTrendsMap(serverUUID));
|
||||
serverOverview.put("insights", createInsightsMap(serverUUID));
|
||||
return serverOverview;
|
||||
}
|
||||
|
||||
private Map<String, Object> createTrendsMap(UUID serverUUID) {
|
||||
private Map<String, Object> createTrendsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long monthAgo = now - TimeUnit.DAYS.toMillis(30L);
|
||||
@ -125,7 +125,7 @@ public class PlayerBaseOverviewJSONCreator implements ServerTabJSONCreator<Map<S
|
||||
return trends;
|
||||
}
|
||||
|
||||
private Map<String, Object> createInsightsMap(UUID serverUUID) {
|
||||
private Map<String, Object> createInsightsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long halfMonthAgo = now - TimeUnit.DAYS.toMillis(15L);
|
||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.GeoInfo;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKill;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
@ -86,12 +87,12 @@ public class PlayerJSONCreator {
|
||||
public Map<String, Object> createJSONAsMap(UUID playerUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
|
||||
Map<UUID, String> serverNames = db.query(ServerQueries.fetchServerNames());
|
||||
Map<ServerUUID, String> serverNames = db.query(ServerQueries.fetchServerNames());
|
||||
String[] pieColors = theme.getPieColors(ThemeVal.GRAPH_WORLD_PIE);
|
||||
|
||||
PlayerContainer player = db.query(new PlayerContainerQuery(playerUUID));
|
||||
SessionsMutator sessionsMutator = SessionsMutator.forContainer(player);
|
||||
Map<UUID, WorldTimes> worldTimesPerServer = PerServerMutator.forContainer(player).worldTimesPerServer();
|
||||
Map<ServerUUID, WorldTimes> worldTimesPerServer = PerServerMutator.forContainer(player).worldTimesPerServer();
|
||||
List<Map<String, Object>> serverAccordion = new ServerAccordion(player, serverNames, graphs, year, timeAmount, locale.getString(GenericLang.UNKNOWN)).asMaps();
|
||||
List<PlayerKill> kills = player.getValue(PlayerKeys.PLAYER_KILLS).orElse(Collections.emptyList());
|
||||
List<PlayerKill> deaths = player.getValue(PlayerKeys.PLAYER_DEATHS_KILLS).orElse(Collections.emptyList());
|
||||
@ -157,7 +158,7 @@ public class PlayerJSONCreator {
|
||||
return onlineActivity;
|
||||
}
|
||||
|
||||
private Map<String, Object> createInfoJSONMap(PlayerContainer player, Map<UUID, String> serverNames) {
|
||||
private Map<String, Object> createInfoJSONMap(PlayerContainer player, Map<ServerUUID, String> serverNames) {
|
||||
SessionsMutator sessions = SessionsMutator.forContainer(player);
|
||||
ActivityIndex activityIndex = player.getActivityIndex(System.currentTimeMillis(), config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD));
|
||||
PerServerMutator perServer = PerServerMutator.forContainer(player);
|
||||
@ -280,7 +281,7 @@ public class PlayerJSONCreator {
|
||||
|
||||
public static List<Nickname> fromDataNicknames(
|
||||
List<com.djrapitops.plan.delivery.domain.Nickname> nicknames,
|
||||
Map<UUID, String> serverNames,
|
||||
Map<ServerUUID, String> serverNames,
|
||||
Formatter<Long> dateFormatter
|
||||
) {
|
||||
nicknames.sort(new DateHolderRecentComparator());
|
||||
|
@ -18,13 +18,17 @@ package com.djrapitops.plan.delivery.rendering.json;
|
||||
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.KillQueries;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -49,14 +53,14 @@ public class PvPPvEJSONCreator implements ServerTabJSONCreator<Map<String, Objec
|
||||
decimals = formatters.decimals();
|
||||
}
|
||||
|
||||
public Map<String, Object> createJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> createJSONAsMap(ServerUUID serverUUID) {
|
||||
Map<String, Object> serverOverview = new HashMap<>();
|
||||
serverOverview.put("numbers", createNumbersMap(serverUUID));
|
||||
serverOverview.put("insights", createInsightsMap(serverUUID));
|
||||
return serverOverview;
|
||||
}
|
||||
|
||||
private Map<String, Object> createNumbersMap(UUID serverUUID) {
|
||||
private Map<String, Object> createNumbersMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long weekAgo = now - TimeUnit.DAYS.toMillis(7L);
|
||||
@ -106,7 +110,7 @@ public class PvPPvEJSONCreator implements ServerTabJSONCreator<Map<String, Objec
|
||||
return numbers;
|
||||
}
|
||||
|
||||
private Map<String, Object> createInsightsMap(UUID serverUUID) {
|
||||
private Map<String, Object> createInsightsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long monthAgo = now - TimeUnit.DAYS.toMillis(30L);
|
||||
|
@ -26,8 +26,12 @@ import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.Graphs;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility for creating JSON for Server Accordion
|
||||
@ -36,7 +40,7 @@ import java.util.*;
|
||||
*/
|
||||
public class ServerAccordion {
|
||||
|
||||
private final Map<UUID, String> serverNames;
|
||||
private final Map<ServerUUID, String> serverNames;
|
||||
private final PerServerContainer perServer;
|
||||
private final String unknown;
|
||||
|
||||
@ -45,7 +49,7 @@ public class ServerAccordion {
|
||||
private final Formatter<Long> timeAmount;
|
||||
|
||||
public ServerAccordion(
|
||||
PlayerContainer container, Map<UUID, String> serverNames,
|
||||
PlayerContainer container, Map<ServerUUID, String> serverNames,
|
||||
Graphs graphs,
|
||||
Formatter<Long> year,
|
||||
Formatter<Long> timeAmount,
|
||||
@ -64,8 +68,8 @@ public class ServerAccordion {
|
||||
public List<Map<String, Object>> asMaps() {
|
||||
List<Map<String, Object>> servers = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<UUID, DataContainer> entry : perServer.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
for (Map.Entry<ServerUUID, DataContainer> entry : perServer.entrySet()) {
|
||||
ServerUUID serverUUID = entry.getKey();
|
||||
DataContainer ofServer = entry.getValue();
|
||||
Map<String, Object> server = new HashMap<>();
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.gathering.ServerSensor;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
@ -43,7 +44,6 @@ import javax.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -88,7 +88,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
percentage = formatters.percentage();
|
||||
}
|
||||
|
||||
public Map<String, Object> createJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> createJSONAsMap(ServerUUID serverUUID) {
|
||||
Map<String, Object> serverOverview = new HashMap<>();
|
||||
serverOverview.put("last_7_days", createLast7DaysMap(serverUUID));
|
||||
serverOverview.put("numbers", createNumbersMap(serverUUID));
|
||||
@ -96,7 +96,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
return serverOverview;
|
||||
}
|
||||
|
||||
private Map<String, Object> createLast7DaysMap(UUID serverUUID) {
|
||||
private Map<String, Object> createLast7DaysMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long weekAgo = now - TimeUnit.DAYS.toMillis(7L);
|
||||
@ -122,7 +122,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
return sevenDays;
|
||||
}
|
||||
|
||||
private Map<String, Object> createNumbersMap(UUID serverUUID) {
|
||||
private Map<String, Object> createNumbersMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long twoDaysAgo = now - TimeUnit.DAYS.toMillis(2L);
|
||||
@ -151,7 +151,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
return numbers;
|
||||
}
|
||||
|
||||
private Object getOnlinePlayers(UUID serverUUID, Database db) {
|
||||
private Object getOnlinePlayers(ServerUUID serverUUID, Database db) {
|
||||
return serverUUID.equals(serverInfo.getServerUUID())
|
||||
? serverSensor.getOnlinePlayerCount()
|
||||
: db.query(TPSQueries.fetchLatestTPSEntryForServer(serverUUID))
|
||||
@ -159,7 +159,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
.orElse(locale.get(GenericLang.UNKNOWN).toString());
|
||||
}
|
||||
|
||||
private Map<String, Object> createWeeksMap(UUID serverUUID) {
|
||||
private Map<String, Object> createWeeksMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long oneWeekAgo = now - TimeUnit.DAYS.toMillis(7L);
|
||||
|
@ -16,7 +16,8 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
@ -24,12 +25,12 @@ import java.util.function.Function;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public interface ServerTabJSONCreator<T> extends Function<UUID, T> {
|
||||
public interface ServerTabJSONCreator<T> extends Function<ServerUUID, T> {
|
||||
|
||||
T createJSONAsMap(UUID serverUUID);
|
||||
T createJSONAsMap(ServerUUID serverUUID);
|
||||
|
||||
@Override
|
||||
default T apply(UUID uuid) {
|
||||
default T apply(ServerUUID uuid) {
|
||||
return createJSONAsMap(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.gathering.domain.GMTimes;
|
||||
import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.SessionQueries;
|
||||
@ -57,11 +58,11 @@ public class SessionsOverviewJSONCreator implements ServerTabJSONCreator<Map<Str
|
||||
percentage = formatters.percentage();
|
||||
}
|
||||
|
||||
public Map<String, Object> createJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> createJSONAsMap(ServerUUID serverUUID) {
|
||||
return Collections.singletonMap("insights", createInsightsMap(serverUUID));
|
||||
}
|
||||
|
||||
private Map<String, Object> createInsightsMap(UUID serverUUID) {
|
||||
private Map<String, Object> createInsightsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long monthAgo = now - TimeUnit.DAYS.toMillis(30L);
|
||||
|
@ -29,9 +29,10 @@ import com.djrapitops.plan.delivery.rendering.json.graphs.pie.Pie;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.special.WorldMap;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.stack.StackGraph;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.Ping;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
@ -50,7 +51,10 @@ import net.playeranalytics.plugin.scheduling.TimeAmount;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -79,7 +83,7 @@ public class GraphJSONCreator {
|
||||
this.graphs = graphs;
|
||||
}
|
||||
|
||||
public String performanceGraphJSON(UUID serverUUID) {
|
||||
public String performanceGraphJSON(ServerUUID serverUUID) {
|
||||
long now = System.currentTimeMillis();
|
||||
Database db = dbSystem.getDatabase();
|
||||
LineGraphFactory lineGraphs = graphs.line();
|
||||
@ -110,7 +114,7 @@ public class GraphJSONCreator {
|
||||
"}}";
|
||||
}
|
||||
|
||||
public Map<String, Object> optimizedPerformanceGraphJSON(UUID serverUUID) {
|
||||
public Map<String, Object> optimizedPerformanceGraphJSON(ServerUUID serverUUID) {
|
||||
long now = System.currentTimeMillis();
|
||||
long twoMonthsAgo = now - TimeUnit.DAYS.toMillis(60);
|
||||
long monthAgo = now - TimeUnit.DAYS.toMillis(30);
|
||||
@ -166,7 +170,7 @@ public class GraphJSONCreator {
|
||||
.build();
|
||||
}
|
||||
|
||||
public String playersOnlineGraph(UUID serverUUID) {
|
||||
public String playersOnlineGraph(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long halfYearAgo = now - TimeUnit.DAYS.toMillis(180L);
|
||||
@ -179,7 +183,7 @@ public class GraphJSONCreator {
|
||||
",\"color\":\"" + theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE) + "\"}";
|
||||
}
|
||||
|
||||
public String uniqueAndNewGraphJSON(UUID serverUUID) {
|
||||
public String uniqueAndNewGraphJSON(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
LineGraphFactory lineGraphs = graphs.line();
|
||||
long now = System.currentTimeMillis();
|
||||
@ -195,7 +199,7 @@ public class GraphJSONCreator {
|
||||
return createUniqueAndNewJSON(lineGraphs, uniquePerDay, newPerDay, TimeUnit.DAYS.toMillis(1L));
|
||||
}
|
||||
|
||||
public String hourlyUniqueAndNewGraphJSON(UUID serverUUID) {
|
||||
public String hourlyUniqueAndNewGraphJSON(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
LineGraphFactory lineGraphs = graphs.line();
|
||||
long now = System.currentTimeMillis();
|
||||
@ -259,7 +263,7 @@ public class GraphJSONCreator {
|
||||
return createUniqueAndNewJSON(lineGraphs, uniquePerDay, newPerDay, TimeUnit.HOURS.toMillis(1L));
|
||||
}
|
||||
|
||||
public String serverCalendarJSON(UUID serverUUID) {
|
||||
public String serverCalendarJSON(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long twoYearsAgo = now - TimeUnit.DAYS.toMillis(730L);
|
||||
@ -286,7 +290,7 @@ public class GraphJSONCreator {
|
||||
",\"firstDay\":" + 1 + '}';
|
||||
}
|
||||
|
||||
public Map<String, Object> serverWorldPieJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> serverWorldPieJSONAsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
WorldTimes worldTimes = db.query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID));
|
||||
WorldPie worldPie = graphs.pie().worldPie(worldTimes);
|
||||
@ -297,7 +301,7 @@ public class GraphJSONCreator {
|
||||
.build();
|
||||
}
|
||||
|
||||
public Map<String, Object> activityGraphsJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> activityGraphsJSONAsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long date = System.currentTimeMillis();
|
||||
Long threshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
|
||||
@ -335,7 +339,7 @@ public class GraphJSONCreator {
|
||||
return createActivityGraphJSON(activityData);
|
||||
}
|
||||
|
||||
public Map<String, Object> geolocationGraphsJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> geolocationGraphsJSONAsMap(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
Map<String, Integer> geolocationCounts = db.query(GeoInfoQueries.serverGeolocationCounts(serverUUID));
|
||||
|
||||
@ -365,7 +369,7 @@ public class GraphJSONCreator {
|
||||
return createGeolocationJSON(geolocationCounts);
|
||||
}
|
||||
|
||||
public String pingGraphsJSON(UUID serverUUID) {
|
||||
public String pingGraphsJSON(ServerUUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
List<Ping> pings = db.query(PingQueries.fetchPingDataOfServer(now - TimeUnit.DAYS.toMillis(180L), now, serverUUID));
|
||||
@ -382,10 +386,10 @@ public class GraphJSONCreator {
|
||||
"}}";
|
||||
}
|
||||
|
||||
public Map<String, Object> punchCardJSONAsMap(UUID serverUUID) {
|
||||
public Map<String, Object> punchCardJSONAsMap(ServerUUID serverUUID) {
|
||||
long now = System.currentTimeMillis();
|
||||
long monthAgo = now - TimeUnit.DAYS.toMillis(30L);
|
||||
List<Session> sessions = dbSystem.getDatabase().query(
|
||||
List<FinishedSession> sessions = dbSystem.getDatabase().query(
|
||||
SessionQueries.fetchServerSessionsWithoutKillOrWorldData(monthAgo, now, serverUUID)
|
||||
);
|
||||
return Maps.builder(String.class, Object.class)
|
||||
|
@ -18,10 +18,10 @@ package com.djrapitops.plan.delivery.rendering.json.graphs.calendar;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.container.PlayerContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKill;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKills;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
@ -45,7 +45,7 @@ public class PlayerCalendar {
|
||||
private final Locale locale;
|
||||
private final TimeZone timeZone;
|
||||
|
||||
private final List<Session> allSessions;
|
||||
private final List<FinishedSession> allSessions;
|
||||
private final long registered;
|
||||
|
||||
PlayerCalendar(
|
||||
@ -77,14 +77,14 @@ public class PlayerCalendar {
|
||||
).withColor(theme.getValue(ThemeVal.LIGHT_GREEN))
|
||||
);
|
||||
|
||||
Map<String, List<Session>> sessionsByDay = getSessionsByDay();
|
||||
Map<String, List<FinishedSession>> sessionsByDay = getSessionsByDay();
|
||||
|
||||
for (Map.Entry<String, List<Session>> entry : sessionsByDay.entrySet()) {
|
||||
for (Map.Entry<String, List<FinishedSession>> entry : sessionsByDay.entrySet()) {
|
||||
String day = entry.getKey();
|
||||
|
||||
List<Session> sessions = entry.getValue();
|
||||
List<FinishedSession> sessions = entry.getValue();
|
||||
int sessionCount = sessions.size();
|
||||
long playtime = sessions.stream().mapToLong(Session::getLength).sum();
|
||||
long playtime = sessions.stream().mapToLong(FinishedSession::getLength).sum();
|
||||
|
||||
entries.add(CalendarEntry
|
||||
.of(locale.getString(HtmlLang.LABEL_PLAYTIME) + ": " + timeAmount.apply(playtime), day)
|
||||
@ -95,10 +95,10 @@ public class PlayerCalendar {
|
||||
|
||||
long fiveMinutes = TimeUnit.MINUTES.toMillis(5L);
|
||||
|
||||
for (Session session : allSessions) {
|
||||
for (FinishedSession session : allSessions) {
|
||||
String length = timeAmount.apply(session.getLength());
|
||||
Long start = session.getUnsafe(SessionKeys.START);
|
||||
Long end = session.getValue(SessionKeys.END).orElse(System.currentTimeMillis());
|
||||
long start = session.getStart();
|
||||
long end = session.getEnd();
|
||||
|
||||
entries.add(CalendarEntry
|
||||
.of(locale.getString(HtmlLang.SESSION) + ": " + length,
|
||||
@ -106,7 +106,7 @@ public class PlayerCalendar {
|
||||
.withEnd(end + timeZone.getOffset(end))
|
||||
);
|
||||
|
||||
for (PlayerKill kill : session.getPlayerKills()) {
|
||||
for (PlayerKill kill : session.getExtraData(PlayerKills.class).map(PlayerKills::asList).orElseGet(ArrayList::new)) {
|
||||
long time = kill.getDate();
|
||||
String victim = kill.getVictimName().orElse(kill.getVictim().toString());
|
||||
entries.add(CalendarEntry
|
||||
@ -120,12 +120,12 @@ public class PlayerCalendar {
|
||||
return entries;
|
||||
}
|
||||
|
||||
private Map<String, List<Session>> getSessionsByDay() {
|
||||
Map<String, List<Session>> sessionsByDay = new HashMap<>();
|
||||
for (Session session : allSessions) {
|
||||
private Map<String, List<FinishedSession>> getSessionsByDay() {
|
||||
Map<String, List<FinishedSession>> sessionsByDay = new HashMap<>();
|
||||
for (FinishedSession session : allSessions) {
|
||||
String day = iso8601Formatter.apply(session.getDate());
|
||||
|
||||
List<Session> sessionsOfDay = sessionsByDay.computeIfAbsent(day, Lists::create);
|
||||
List<FinishedSession> sessionsOfDay = sessionsByDay.computeIfAbsent(day, Lists::create);
|
||||
sessionsOfDay.add(session);
|
||||
}
|
||||
return sessionsByDay;
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.delivery.rendering.json.graphs.pie;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.gathering.domain.GMTimes;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.WorldAliasSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
@ -30,7 +31,6 @@ import com.djrapitops.plan.settings.theme.ThemeVal;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Factory class for different objects representing HTML pie graphs.
|
||||
@ -60,7 +60,7 @@ public class PieGraphFactory {
|
||||
return new ActivityPie(activityData, colors, ActivityIndex.getGroups(locale));
|
||||
}
|
||||
|
||||
public Pie serverPreferencePie(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes) {
|
||||
public Pie serverPreferencePie(Map<ServerUUID, String> serverNames, Map<ServerUUID, WorldTimes> serverWorldTimes) {
|
||||
return new ServerPreferencePie(serverNames, serverWorldTimes, locale.get(GenericLang.UNKNOWN).toString());
|
||||
}
|
||||
|
||||
|
@ -17,15 +17,15 @@
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.pie;
|
||||
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ServerPreferencePie extends Pie {
|
||||
|
||||
ServerPreferencePie(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes, String unknown) {
|
||||
ServerPreferencePie(Map<ServerUUID, String> serverNames, Map<ServerUUID, WorldTimes> serverWorldTimes, String unknown) {
|
||||
super(turnToSlices(serverNames, serverWorldTimes, unknown));
|
||||
}
|
||||
|
||||
@ -33,11 +33,11 @@ public class ServerPreferencePie extends Pie {
|
||||
super(turnToSlices(serverPlaytimes));
|
||||
}
|
||||
|
||||
private static List<PieSlice> turnToSlices(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes, String unknown) {
|
||||
private static List<PieSlice> turnToSlices(Map<ServerUUID, String> serverNames, Map<ServerUUID, WorldTimes> serverWorldTimes, String unknown) {
|
||||
List<PieSlice> slices = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<UUID, WorldTimes> server : serverWorldTimes.entrySet()) {
|
||||
UUID serverUUID = server.getKey();
|
||||
for (Map.Entry<ServerUUID, WorldTimes> server : serverWorldTimes.entrySet()) {
|
||||
ServerUUID serverUUID = server.getKey();
|
||||
WorldTimes worldTimes = server.getValue();
|
||||
|
||||
String serverName = serverNames.getOrDefault(serverUUID, unknown);
|
||||
|
@ -17,7 +17,7 @@
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.special;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -41,7 +41,7 @@ public class SpecialGraphFactory {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public PunchCard punchCard(List<Session> sessions) {
|
||||
public PunchCard punchCard(List<FinishedSession> sessions) {
|
||||
return punchCard(new SessionsMutator(sessions));
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.delivery.rendering.json.Trend;
|
||||
import com.djrapitops.plan.gathering.ServerSensor;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
@ -37,7 +38,6 @@ import javax.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -114,7 +114,7 @@ public class NetworkOverviewJSONCreator implements NetworkTabJSONCreator<Map<Str
|
||||
numbers.put("total_players", userCount);
|
||||
numbers.put("regular_players", db.query(NetworkActivityIndexQueries.fetchRegularPlayerCount(now, playtimeThreshold)));
|
||||
numbers.put("online_players", serverSensor.getOnlinePlayerCount());
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
ServerUUID serverUUID = serverInfo.getServerUUID();
|
||||
Optional<DateObj<Integer>> lastPeak = db.query(TPSQueries.fetchPeakPlayerCount(serverUUID, twoDaysAgo));
|
||||
Optional<DateObj<Integer>> allTimePeak = db.query(TPSQueries.fetchAllTimePeakPlayerCount(serverUUID));
|
||||
numbers.put("last_peak_date", lastPeak.map(year).orElse("-"));
|
||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.delivery.webserver.cache.JSONStorage;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.ProxySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
@ -37,7 +38,6 @@ import com.djrapitops.plan.version.VersionChecker;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Html String generator for /network page.
|
||||
@ -84,7 +84,7 @@ public class NetworkPage implements Page {
|
||||
public String toHtml() {
|
||||
PlaceholderReplacer placeholders = new PlaceholderReplacer();
|
||||
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
ServerUUID serverUUID = serverInfo.getServerUUID();
|
||||
placeholders.put("networkDisplayName", config.get(ProxySettings.NETWORK_NAME));
|
||||
placeholders.put("serverName", config.get(ProxySettings.NETWORK_NAME));
|
||||
placeholders.put("serverUUID", serverUUID.toString());
|
||||
|
@ -26,6 +26,7 @@ import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
@ -97,7 +98,7 @@ public class PageFactory {
|
||||
* @throws NotFoundException If the server can not be found in the database.
|
||||
* @throws IOException If the template files can not be read.
|
||||
*/
|
||||
public Page serverPage(UUID serverUUID) throws IOException {
|
||||
public Page serverPage(ServerUUID serverUUID) throws IOException {
|
||||
Server server = dbSystem.get().getDatabase().query(ServerQueries.fetchServerMatchingIdentifier(serverUUID))
|
||||
.orElseThrow(() -> new NotFoundException("Server not found in the database"));
|
||||
return new ServerPage(
|
||||
@ -128,15 +129,15 @@ public class PageFactory {
|
||||
public PlayerPluginTab inspectPluginTabs(UUID playerUUID) {
|
||||
Database database = dbSystem.get().getDatabase();
|
||||
|
||||
Map<UUID, List<ExtensionData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
|
||||
Map<ServerUUID, List<ExtensionData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
|
||||
|
||||
if (extensionPlayerData.isEmpty()) {
|
||||
return new PlayerPluginTab("", Collections.emptyList(), formatters.get());
|
||||
}
|
||||
|
||||
List<PlayerPluginTab> playerPluginTabs = new ArrayList<>();
|
||||
for (Map.Entry<UUID, Server> entry : database.query(ServerQueries.fetchPlanServerInformation()).entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
for (Map.Entry<ServerUUID, Server> entry : database.query(ServerQueries.fetchPlanServerInformation()).entrySet()) {
|
||||
ServerUUID serverUUID = entry.getKey();
|
||||
String serverName = entry.getValue().getIdentifiableName();
|
||||
|
||||
List<ExtensionData> ofServer = extensionPlayerData.get(serverUUID);
|
||||
|
@ -27,6 +27,7 @@ import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
@ -37,7 +38,6 @@ import com.djrapitops.plan.utilities.java.UnaryChain;
|
||||
import com.djrapitops.plan.version.VersionChecker;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Html String generator for /server page.
|
||||
@ -84,7 +84,7 @@ public class ServerPage implements Page {
|
||||
public String toHtml() {
|
||||
PlaceholderReplacer placeholders = new PlaceholderReplacer();
|
||||
|
||||
UUID serverUUID = server.getUuid();
|
||||
ServerUUID serverUUID = server.getUuid();
|
||||
placeholders.put("serverUUID", serverUUID.toString());
|
||||
placeholders.put("serverName", server.getIdentifiableName());
|
||||
placeholders.put("serverDisplayName", server.getName());
|
||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.delivery.web.resolver.exception.NotFoundException;
|
||||
import com.djrapitops.plan.delivery.web.resource.WebResource;
|
||||
import com.djrapitops.plan.delivery.webserver.auth.FailReason;
|
||||
import com.djrapitops.plan.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.ErrorPageLang;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
@ -143,7 +144,7 @@ public class ResponseFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public Response serverPageResponse(UUID serverUUID) {
|
||||
public Response serverPageResponse(ServerUUID serverUUID) {
|
||||
Optional<Response> error = checkDbClosedError();
|
||||
if (error.isPresent()) return error.get();
|
||||
try {
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.webserver.cache;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
@ -24,7 +25,6 @@ import com.djrapitops.plan.utilities.UnitSemaphoreAccessLock;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
@ -62,7 +62,7 @@ public class AsyncJSONResolverService {
|
||||
}
|
||||
|
||||
public <T> JSONStorage.StoredJSON resolve(
|
||||
long newerThanTimestamp, DataID dataID, UUID serverUUID, Function<UUID, T> creator
|
||||
long newerThanTimestamp, DataID dataID, ServerUUID serverUUID, Function<ServerUUID, T> creator
|
||||
) {
|
||||
String identifier = dataID.of(serverUUID);
|
||||
Supplier<T> jsonCreator = () -> creator.apply(serverUUID);
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.webserver.cache;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
/**
|
||||
* Enum for different JSON data entries that can be stored in cache.
|
||||
@ -52,8 +52,7 @@ public enum DataID {
|
||||
EXTENSION_TABS
|
||||
;
|
||||
|
||||
public String of(UUID serverUUID) {
|
||||
public String of(ServerUUID serverUUID) {
|
||||
return name() + '-' + serverUUID;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ import com.djrapitops.plan.delivery.web.resolver.request.WebUser;
|
||||
import com.djrapitops.plan.delivery.webserver.ResponseFactory;
|
||||
import com.djrapitops.plan.identification.Server;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Resolves /network, /server and /server/${name/uuid} URLs.
|
||||
@ -79,7 +79,7 @@ public class ServerPageResolver implements Resolver {
|
||||
return Optional.of(responseFactory.redirectResponse(directTo));
|
||||
}
|
||||
|
||||
private Optional<Response> getServerPage(UUID serverUUID, Request request) {
|
||||
private Optional<Response> getServerPage(ServerUUID serverUUID, Request request) {
|
||||
boolean toNetworkPage = serverInfo.getServer().isProxy() && serverInfo.getServerUUID().equals(serverUUID);
|
||||
if (toNetworkPage) {
|
||||
if (request.getPath().getPart(0).map("network"::equals).orElse(false)) {
|
||||
@ -92,7 +92,7 @@ public class ServerPageResolver implements Resolver {
|
||||
return Optional.of(responseFactory.serverPageResponse(serverUUID));
|
||||
}
|
||||
|
||||
private Optional<UUID> getServerUUID(URIPath path) {
|
||||
private Optional<ServerUUID> getServerUUID(URIPath path) {
|
||||
if (serverInfo.getServer().isProxy()
|
||||
&& path.getPart(0).map("network"::equals).orElse(false)
|
||||
&& !path.getPart(1).isPresent() // No slash at the end.
|
||||
|
@ -27,12 +27,12 @@ import com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONStorage;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Resolves /v1/graph JSON requests.
|
||||
@ -91,7 +91,7 @@ public class GraphsJSONResolver implements Resolver {
|
||||
|
||||
JSONStorage.StoredJSON storedJSON;
|
||||
if (request.getQuery().get("server").isPresent()) {
|
||||
UUID serverUUID = identifiers.getServerUUID(request); // Can throw BadRequestException
|
||||
ServerUUID serverUUID = identifiers.getServerUUID(request); // Can throw BadRequestException
|
||||
storedJSON = jsonResolverService.resolve(
|
||||
timestamp, dataID, serverUUID,
|
||||
theServerUUID -> generateGraphDataJSONOfType(dataID, theServerUUID)
|
||||
@ -138,7 +138,7 @@ public class GraphsJSONResolver implements Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
private Object generateGraphDataJSONOfType(DataID id, UUID serverUUID) {
|
||||
private Object generateGraphDataJSONOfType(DataID id, ServerUUID serverUUID) {
|
||||
switch (id) {
|
||||
case GRAPH_PERFORMANCE:
|
||||
return graphJSON.performanceGraphJSON(serverUUID);
|
||||
|
@ -26,12 +26,12 @@ import com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONStorage;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Resolves /v1/kills JSON requests.
|
||||
@ -67,7 +67,7 @@ public class PlayerKillsJSONResolver implements Resolver {
|
||||
}
|
||||
|
||||
private Response getResponse(Request request) {
|
||||
UUID serverUUID = identifiers.getServerUUID(request);
|
||||
ServerUUID serverUUID = identifiers.getServerUUID(request);
|
||||
long timestamp = Identifiers.getTimestamp(request);
|
||||
JSONStorage.StoredJSON storedJSON = jsonResolverService.resolve(timestamp, DataID.KILLS, serverUUID,
|
||||
theUUID -> Collections.singletonMap("player_kills", jsonFactory.serverPlayerKillsAsJSONMap(theUUID))
|
||||
|
@ -26,11 +26,11 @@ import com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONStorage;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Resolves /v1/players JSON requests.
|
||||
@ -81,7 +81,7 @@ public class PlayersTableJSONResolver implements Resolver {
|
||||
long timestamp = Identifiers.getTimestamp(request);
|
||||
JSONStorage.StoredJSON storedJSON;
|
||||
if (request.getQuery().get("server").isPresent()) {
|
||||
UUID serverUUID = identifiers.getServerUUID(request); // Can throw BadRequestException
|
||||
ServerUUID serverUUID = identifiers.getServerUUID(request); // Can throw BadRequestException
|
||||
storedJSON = jsonResolverService.resolve(timestamp, DataID.PLAYERS, serverUUID, jsonFactory::serverPlayersTableJSON);
|
||||
} else {
|
||||
// Assume players page
|
||||
|
@ -25,9 +25,9 @@ import com.djrapitops.plan.delivery.web.resolver.request.WebUser;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
@ -39,7 +39,7 @@ public class ServerTabJSONResolver<T> implements Resolver {
|
||||
|
||||
private final DataID dataID;
|
||||
private final Identifiers identifiers;
|
||||
private final Function<UUID, T> jsonCreator;
|
||||
private final Function<ServerUUID, T> jsonCreator;
|
||||
private final AsyncJSONResolverService asyncJSONResolverService;
|
||||
|
||||
public ServerTabJSONResolver(
|
||||
@ -63,7 +63,7 @@ public class ServerTabJSONResolver<T> implements Resolver {
|
||||
}
|
||||
|
||||
private Response getResponse(Request request) {
|
||||
UUID serverUUID = identifiers.getServerUUID(request); // Can throw BadRequestException
|
||||
ServerUUID serverUUID = identifiers.getServerUUID(request); // Can throw BadRequestException
|
||||
return Response.builder()
|
||||
.setMimeType(MimeType.JSON)
|
||||
.setJSONContent(asyncJSONResolverService.resolve(Identifiers.getTimestamp(request), dataID, serverUUID, jsonCreator).json)
|
||||
|
@ -26,12 +26,12 @@ import com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONStorage;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Resolves /v1/sessions JSON requests.
|
||||
@ -76,7 +76,7 @@ public class SessionsJSONResolver implements Resolver {
|
||||
private JSONStorage.StoredJSON getStoredJSON(Request request) {
|
||||
long timestamp = Identifiers.getTimestamp(request);
|
||||
if (request.getQuery().get("server").isPresent()) {
|
||||
UUID serverUUID = identifiers.getServerUUID(request);
|
||||
ServerUUID serverUUID = identifiers.getServerUUID(request);
|
||||
return jsonResolverService.resolve(timestamp, DataID.SESSIONS, serverUUID,
|
||||
theUUID -> Collections.singletonMap("sessions", jsonFactory.serverSessionsAsJSONMap(theUUID))
|
||||
);
|
||||
|
@ -19,21 +19,22 @@ package com.djrapitops.plan.extension.implementation.providers;
|
||||
import com.djrapitops.plan.extension.DataExtension;
|
||||
import com.djrapitops.plan.extension.Group;
|
||||
import com.djrapitops.plan.extension.implementation.MethodType;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Parameters {
|
||||
static Parameters player(UUID serverUUID, UUID playerUUID, String playerName) {
|
||||
static Parameters player(ServerUUID serverUUID, UUID playerUUID, String playerName) {
|
||||
return new PlayerParameters(serverUUID, playerUUID, playerName);
|
||||
}
|
||||
|
||||
static Parameters server(UUID serverUUID) {
|
||||
static Parameters server(ServerUUID serverUUID) {
|
||||
return new ServerParameters(serverUUID);
|
||||
}
|
||||
|
||||
static Parameters group(UUID serverUUID, String groupName) {
|
||||
static Parameters group(ServerUUID serverUUID, String groupName) {
|
||||
return new GroupParameters(serverUUID, groupName);
|
||||
}
|
||||
|
||||
@ -41,20 +42,20 @@ public interface Parameters {
|
||||
|
||||
MethodType getMethodType();
|
||||
|
||||
UUID getServerUUID();
|
||||
ServerUUID getServerUUID();
|
||||
|
||||
default UUID getPlayerUUID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
class ServerParameters implements Parameters {
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
private ServerParameters(UUID serverUUID) {
|
||||
private ServerParameters(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
public UUID getServerUUID() {
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
@ -70,17 +71,17 @@ public interface Parameters {
|
||||
}
|
||||
|
||||
class PlayerParameters implements Parameters {
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final UUID playerUUID;
|
||||
private final String playerName;
|
||||
|
||||
private PlayerParameters(UUID serverUUID, UUID playerUUID, String playerName) {
|
||||
private PlayerParameters(ServerUUID serverUUID, UUID playerUUID, String playerName) {
|
||||
this.serverUUID = serverUUID;
|
||||
this.playerUUID = playerUUID;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public UUID getServerUUID() {
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
@ -106,15 +107,15 @@ public interface Parameters {
|
||||
}
|
||||
|
||||
class GroupParameters implements Parameters {
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String groupName;
|
||||
|
||||
private GroupParameters(UUID serverUUID, String groupName) {
|
||||
private GroupParameters(ServerUUID serverUUID, String groupName) {
|
||||
this.serverUUID = serverUUID;
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
public UUID getServerUUID() {
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
|
@ -16,17 +16,18 @@
|
||||
*/
|
||||
package com.djrapitops.plan.extension.implementation.providers;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProviderIdentifier {
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String pluginName;
|
||||
private final String providerName;
|
||||
private String serverName;
|
||||
|
||||
public ProviderIdentifier(UUID serverUUID, String pluginName, String providerName) {
|
||||
public ProviderIdentifier(ServerUUID serverUUID, String pluginName, String providerName) {
|
||||
this.serverUUID = serverUUID;
|
||||
this.pluginName = pluginName;
|
||||
this.providerName = providerName;
|
||||
@ -40,7 +41,7 @@ public class ProviderIdentifier {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public UUID getServerUUID() {
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.extension.implementation.storage.transactions.StoreIc
|
||||
import com.djrapitops.plan.extension.implementation.storage.transactions.providers.StoreProviderTransaction;
|
||||
import com.djrapitops.plan.extension.implementation.storage.transactions.results.StorePlayerBooleanResultTransaction;
|
||||
import com.djrapitops.plan.extension.implementation.storage.transactions.results.StoreServerBooleanResultTransaction;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.Transaction;
|
||||
|
||||
@ -45,14 +46,14 @@ class BooleanProviderValueGatherer {
|
||||
|
||||
private final String pluginName;
|
||||
private final DataExtension extension;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
private final Database database;
|
||||
private final DataProviders dataProviders;
|
||||
|
||||
BooleanProviderValueGatherer(
|
||||
String pluginName,
|
||||
UUID serverUUID, Database database,
|
||||
ServerUUID serverUUID, Database database,
|
||||
ExtensionWrapper extensionWrapper
|
||||
) {
|
||||
this.pluginName = pluginName;
|
||||
|
@ -31,6 +31,7 @@ import com.djrapitops.plan.extension.implementation.storage.transactions.StoreTa
|
||||
import com.djrapitops.plan.extension.implementation.storage.transactions.providers.StoreProviderTransaction;
|
||||
import com.djrapitops.plan.extension.implementation.storage.transactions.results.*;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.Transaction;
|
||||
@ -71,7 +72,7 @@ public class ProviderValueGatherer {
|
||||
this.serverInfo = serverInfo;
|
||||
|
||||
String pluginName = extension.getPluginName();
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
ServerUUID serverUUID = serverInfo.getServerUUID();
|
||||
Database database = dbSystem.getDatabase();
|
||||
dataProviders = extension.getProviders();
|
||||
booleanGatherer = new BooleanProviderValueGatherer(
|
||||
@ -130,7 +131,7 @@ public class ProviderValueGatherer {
|
||||
Icon pluginIcon = extensionWrapper.getPluginIcon();
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
UUID serverUUID = serverInfo.getServerUUID();
|
||||
ServerUUID serverUUID = serverInfo.getServerUUID();
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
database.executeTransaction(new StoreIconTransaction(pluginIcon));
|
||||
|
@ -30,6 +30,7 @@ import com.djrapitops.plan.extension.implementation.storage.transactions.provide
|
||||
import com.djrapitops.plan.extension.implementation.storage.transactions.results.StorePlayerTableResultTransaction;
|
||||
import com.djrapitops.plan.extension.implementation.storage.transactions.results.StoreServerTableResultTransaction;
|
||||
import com.djrapitops.plan.extension.table.Table;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.transactions.Transaction;
|
||||
|
||||
@ -48,14 +49,14 @@ class TableProviderValueGatherer {
|
||||
|
||||
private final String pluginName;
|
||||
private final DataExtension extension;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
private final Database database;
|
||||
private final DataProviders dataProviders;
|
||||
|
||||
TableProviderValueGatherer(
|
||||
String pluginName,
|
||||
UUID serverUUID, Database database,
|
||||
ServerUUID serverUUID, Database database,
|
||||
ExtensionWrapper extensionWrapper
|
||||
) {
|
||||
this.pluginName = pluginName;
|
||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionDoubleData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -35,7 +36,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -54,9 +54,9 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public ExtensionAggregateBooleansQuery(UUID serverUUID) {
|
||||
public ExtensionAggregateBooleansQuery(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionDoubleData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -35,7 +36,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -53,9 +53,9 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public ExtensionAggregateDoublesQuery(UUID serverUUID) {
|
||||
public ExtensionAggregateDoublesQuery(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.table.Table;
|
||||
import com.djrapitops.plan.extension.table.TableAccessor;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -33,7 +34,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -51,9 +51,9 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionAggregateGroupsQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public ExtensionAggregateGroupsQuery(UUID serverUUID) {
|
||||
public ExtensionAggregateGroupsQuery(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionNumberData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -36,7 +37,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -54,9 +54,9 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public ExtensionAggregateNumbersQuery(UUID serverUUID) {
|
||||
public ExtensionAggregateNumbersQuery(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionDoubleData;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionTabData;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -35,7 +36,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -53,9 +53,9 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public ExtensionAggregatePercentagesQuery(UUID serverUUID) {
|
||||
public ExtensionAggregatePercentagesQuery(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.icon.Family;
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionInformation;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryAllStatement;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -30,7 +31,10 @@ import com.djrapitops.plan.utilities.java.Lists;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -45,7 +49,7 @@ public class ExtensionInformationQueries {
|
||||
/* Static method class */
|
||||
}
|
||||
|
||||
public static Query<List<ExtensionInformation>> extensionsOfServer(UUID serverUUID) {
|
||||
public static Query<List<ExtensionInformation>> extensionsOfServer(ServerUUID serverUUID) {
|
||||
String sql = SELECT +
|
||||
ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.ID + " as id," +
|
||||
ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.PLUGIN_NAME + " as plugin_name," +
|
||||
@ -86,7 +90,7 @@ public class ExtensionInformationQueries {
|
||||
return new ExtensionInformation(id, pluginName, icon);
|
||||
}
|
||||
|
||||
public static Query<Map<UUID, List<ExtensionInformation>>> allExtensions() {
|
||||
public static Query<Map<ServerUUID, List<ExtensionInformation>>> allExtensions() {
|
||||
String sql = SELECT +
|
||||
ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.ID + " as id," +
|
||||
ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.PLUGIN_NAME + " as plugin_name," +
|
||||
@ -98,12 +102,12 @@ public class ExtensionInformationQueries {
|
||||
INNER_JOIN + ExtensionIconTable.TABLE_NAME + " on " +
|
||||
ExtensionPluginTable.ICON_ID + "=" + ExtensionIconTable.TABLE_NAME + '.' + ExtensionIconTable.ID;
|
||||
|
||||
return new QueryAllStatement<Map<UUID, List<ExtensionInformation>>>(sql, 100) {
|
||||
return new QueryAllStatement<Map<ServerUUID, List<ExtensionInformation>>>(sql, 100) {
|
||||
@Override
|
||||
public Map<UUID, List<ExtensionInformation>> processResults(ResultSet set) throws SQLException {
|
||||
Map<UUID, List<ExtensionInformation>> byServerUUID = new HashMap<>();
|
||||
public Map<ServerUUID, List<ExtensionInformation>> processResults(ResultSet set) throws SQLException {
|
||||
Map<ServerUUID, List<ExtensionInformation>> byServerUUID = new HashMap<>();
|
||||
while (set.next()) {
|
||||
UUID serverUUID = UUID.fromString(set.getString(ExtensionPluginTable.SERVER_UUID));
|
||||
ServerUUID serverUUID = ServerUUID.fromString(set.getString(ExtensionPluginTable.SERVER_UUID));
|
||||
List<ExtensionInformation> information = byServerUUID.computeIfAbsent(serverUUID, Lists::create);
|
||||
information.add(extractExtensionInformationFromQuery(set));
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.extension.icon.Family;
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.TabInformation;
|
||||
import com.djrapitops.plan.extension.implementation.results.*;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -52,7 +53,7 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionData>>> {
|
||||
public class ExtensionPlayerDataQuery implements Query<Map<ServerUUID, List<ExtensionData>>> {
|
||||
|
||||
private final UUID playerUUID;
|
||||
|
||||
@ -61,8 +62,8 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, List<ExtensionData>> executeQuery(SQLDB db) {
|
||||
Map<UUID, List<ExtensionInformation>> extensionsByServerUUID = db.query(ExtensionInformationQueries.allExtensions());
|
||||
public Map<ServerUUID, List<ExtensionData>> executeQuery(SQLDB db) {
|
||||
Map<ServerUUID, List<ExtensionInformation>> extensionsByServerUUID = db.query(ExtensionInformationQueries.allExtensions());
|
||||
Map<Integer, ExtensionData.Builder> extensionDataByPluginID = db.query(fetchIncompletePlayerDataByPluginID());
|
||||
|
||||
combine(extensionDataByPluginID, db.query(new ExtensionPlayerTablesQuery(playerUUID)));
|
||||
@ -88,11 +89,11 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
}
|
||||
}
|
||||
|
||||
private Map<UUID, List<ExtensionData>> flatMapByServerUUID(Map<UUID, List<ExtensionInformation>> extensionsByServerUUID, Map<Integer, ExtensionData.Builder> extensionDataByPluginID) {
|
||||
Map<UUID, List<ExtensionData>> extensionDataByServerUUID = new HashMap<>();
|
||||
private Map<ServerUUID, List<ExtensionData>> flatMapByServerUUID(Map<ServerUUID, List<ExtensionInformation>> extensionsByServerUUID, Map<Integer, ExtensionData.Builder> extensionDataByPluginID) {
|
||||
Map<ServerUUID, List<ExtensionData>> extensionDataByServerUUID = new HashMap<>();
|
||||
|
||||
for (Map.Entry<UUID, List<ExtensionInformation>> entry : extensionsByServerUUID.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
for (Map.Entry<ServerUUID, List<ExtensionInformation>> entry : extensionsByServerUUID.entrySet()) {
|
||||
ServerUUID serverUUID = entry.getKey();
|
||||
for (ExtensionInformation extensionInformation : entry.getValue()) {
|
||||
ExtensionData.Builder data = extensionDataByPluginID.get(extensionInformation.getId());
|
||||
if (data == null) {
|
||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.icon.Family;
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.results.*;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -47,10 +48,10 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionQueryResultTableDataQuery implements Query<Map<UUID, ExtensionTabData>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final Collection<UUID> playerUUIDs;
|
||||
|
||||
public ExtensionQueryResultTableDataQuery(UUID serverUUID, Collection<UUID> playerUUIDs) {
|
||||
public ExtensionQueryResultTableDataQuery(ServerUUID serverUUID, Collection<UUID> playerUUIDs) {
|
||||
this.serverUUID = serverUUID;
|
||||
this.playerUUIDs = playerUUIDs;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.extension.icon.Family;
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.TabInformation;
|
||||
import com.djrapitops.plan.extension.implementation.results.*;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -31,7 +32,10 @@ import com.djrapitops.plan.storage.database.sql.tables.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -50,9 +54,9 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public ExtensionServerDataQuery(UUID serverUUID) {
|
||||
public ExtensionServerDataQuery(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.icon.Family;
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.results.*;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -45,10 +46,10 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionServerTableDataQuery implements Query<Map<UUID, ExtensionTabData>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final int xMostRecentPlayers;
|
||||
|
||||
public ExtensionServerTableDataQuery(UUID serverUUID, int xMostRecentPlayers) {
|
||||
public ExtensionServerTableDataQuery(ServerUUID serverUUID, int xMostRecentPlayers) {
|
||||
this.serverUUID = serverUUID;
|
||||
this.xMostRecentPlayers = xMostRecentPlayers;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.results.ExtensionData;
|
||||
import com.djrapitops.plan.extension.table.Table;
|
||||
import com.djrapitops.plan.extension.table.TableAccessor;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.SQLDB;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
@ -31,7 +32,10 @@ import com.djrapitops.plan.storage.database.sql.tables.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -49,9 +53,9 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
*/
|
||||
public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public ExtensionServerTablesQuery(UUID serverUUID) {
|
||||
public ExtensionServerTablesQuery(ServerUUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.extension.implementation.storage.queries;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionGroupsTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
@ -32,10 +33,10 @@ public class ExtensionUUIDsInGroupQuery extends QueryStatement<Set<UUID>> {
|
||||
|
||||
private final String pluginName;
|
||||
private final String groupProvider;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final List<String> inGroups;
|
||||
|
||||
public ExtensionUUIDsInGroupQuery(String pluginName, String groupProvider, UUID serverUUID, List<String> inGroups) {
|
||||
public ExtensionUUIDsInGroupQuery(String pluginName, String groupProvider, ServerUUID serverUUID, List<String> inGroups) {
|
||||
super(buildSQL(inGroups), 100);
|
||||
this.pluginName = pluginName;
|
||||
this.groupProvider = groupProvider;
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.djrapitops.plan.extension.implementation.storage.transactions;
|
||||
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionIconTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionPluginTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
@ -25,7 +26,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.AND;
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
@ -39,10 +39,10 @@ public class StorePluginTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final long time;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final Icon icon;
|
||||
|
||||
public StorePluginTransaction(String pluginName, long time, UUID serverUUID, Icon icon) {
|
||||
public StorePluginTransaction(String pluginName, long time, ServerUUID serverUUID, Icon icon) {
|
||||
this.pluginName = pluginName;
|
||||
this.time = time;
|
||||
this.serverUUID = serverUUID;
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.djrapitops.plan.extension.implementation.storage.transactions;
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.TabInformation;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionIconTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionPluginTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionTabTable;
|
||||
@ -26,7 +27,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.AND;
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
@ -39,10 +39,10 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
public class StoreTabInformationTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final TabInformation tabInformation;
|
||||
|
||||
public StoreTabInformationTransaction(String pluginName, UUID serverUUID, TabInformation tabInformation) {
|
||||
public StoreTabInformationTransaction(String pluginName, ServerUUID serverUUID, TabInformation tabInformation) {
|
||||
this.pluginName = pluginName;
|
||||
this.serverUUID = serverUUID;
|
||||
this.tabInformation = tabInformation;
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.provid
|
||||
import com.djrapitops.plan.extension.FormatType;
|
||||
import com.djrapitops.plan.extension.implementation.ProviderInformation;
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.building.Sql;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionIconTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionPluginTable;
|
||||
@ -29,7 +30,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.AND;
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
@ -43,9 +43,9 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderT
|
||||
public class StoreProviderTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final DataProvider<?> provider;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
|
||||
public StoreProviderTransaction(DataProvider<?> provider, UUID serverUUID) {
|
||||
public StoreProviderTransaction(DataProvider<?> provider, ServerUUID serverUUID) {
|
||||
this.provider = provider;
|
||||
this.serverUUID = serverUUID;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.provid
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
import com.djrapitops.plan.extension.implementation.ProviderInformation;
|
||||
import com.djrapitops.plan.extension.table.Table;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionIconTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionPluginTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionTabTable;
|
||||
@ -29,7 +30,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.AND;
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
@ -42,11 +42,11 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionTableProv
|
||||
*/
|
||||
public class StoreTableProviderTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final ProviderInformation information;
|
||||
private final Table table;
|
||||
|
||||
public StoreTableProviderTransaction(UUID serverUUID, ProviderInformation information, Table table) {
|
||||
public StoreTableProviderTransaction(ServerUUID serverUUID, ProviderInformation information, Table table) {
|
||||
this.information = information;
|
||||
this.table = table;
|
||||
this.serverUUID = serverUUID;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.extension.implementation.storage.transactions.results;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.*;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -24,7 +25,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
|
||||
@ -36,10 +36,10 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
public class RemoveInvalidResultsTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final Collection<String> invalidatedMethods;
|
||||
|
||||
public RemoveInvalidResultsTransaction(String pluginName, UUID serverUUID, Collection<String> invalidatedMethods) {
|
||||
public RemoveInvalidResultsTransaction(String pluginName, ServerUUID serverUUID, Collection<String> invalidatedMethods) {
|
||||
this.pluginName = pluginName;
|
||||
this.serverUUID = serverUUID;
|
||||
this.invalidatedMethods = invalidatedMethods;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.extension.implementation.storage.transactions.results;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -37,13 +38,13 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerVal
|
||||
public class StorePlayerBooleanResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
private final UUID playerUUID;
|
||||
|
||||
private final boolean value;
|
||||
|
||||
public StorePlayerBooleanResultTransaction(String pluginName, UUID serverUUID, String providerName, UUID playerUUID, boolean value) {
|
||||
public StorePlayerBooleanResultTransaction(String pluginName, ServerUUID serverUUID, String providerName, UUID playerUUID, boolean value) {
|
||||
this.pluginName = pluginName;
|
||||
this.serverUUID = serverUUID;
|
||||
this.providerName = providerName;
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -43,7 +44,7 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerVal
|
||||
public class StorePlayerDoubleResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
private final UUID playerUUID;
|
||||
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionGroupsTable;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
@ -39,7 +40,7 @@ import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
public class StorePlayerGroupsResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
private final UUID playerUUID;
|
||||
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -39,7 +40,7 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerVal
|
||||
public class StorePlayerNumberResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
private final UUID playerUUID;
|
||||
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -40,7 +41,7 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerVal
|
||||
public class StorePlayerStringResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
private final UUID playerUUID;
|
||||
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.extension.table.Table;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionPluginTable;
|
||||
@ -45,13 +46,13 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerTab
|
||||
public class StorePlayerTableResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
private final UUID playerUUID;
|
||||
|
||||
private final Table table;
|
||||
|
||||
public StorePlayerTableResultTransaction(String pluginName, UUID serverUUID, String providerName, UUID playerUUID, Table table) {
|
||||
public StorePlayerTableResultTransaction(String pluginName, ServerUUID serverUUID, String providerName, UUID playerUUID, Table table) {
|
||||
this.pluginName = pluginName;
|
||||
this.serverUUID = serverUUID;
|
||||
this.providerName = providerName;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.extension.implementation.storage.transactions.results;
|
||||
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -23,7 +24,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerValueTable.*;
|
||||
@ -36,12 +36,12 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerVal
|
||||
public class StoreServerBooleanResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
|
||||
private final boolean value;
|
||||
|
||||
public StoreServerBooleanResultTransaction(String pluginName, UUID serverUUID, String providerName, boolean value) {
|
||||
public StoreServerBooleanResultTransaction(String pluginName, ServerUUID serverUUID, String providerName, boolean value) {
|
||||
this.pluginName = pluginName;
|
||||
this.serverUUID = serverUUID;
|
||||
this.providerName = providerName;
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -25,7 +26,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerValueTable.*;
|
||||
@ -38,7 +38,7 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerVal
|
||||
public class StoreServerDoubleResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
|
||||
private final double value;
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -25,7 +26,6 @@ import com.djrapitops.plan.storage.database.transactions.ThrowawayTransaction;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerValueTable.*;
|
||||
@ -38,7 +38,7 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerVal
|
||||
public class StoreServerNumberResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
|
||||
private final long value;
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import com.djrapitops.plan.extension.implementation.providers.Parameters;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderTable;
|
||||
import com.djrapitops.plan.storage.database.transactions.ExecStatement;
|
||||
import com.djrapitops.plan.storage.database.transactions.Executable;
|
||||
@ -26,7 +27,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.WHERE;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerValueTable.*;
|
||||
@ -39,7 +39,7 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerVal
|
||||
public class StoreServerStringResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
|
||||
private final String value;
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
|
||||
import com.djrapitops.plan.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.extension.table.Table;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.storage.database.queries.Query;
|
||||
import com.djrapitops.plan.storage.database.queries.QueryStatement;
|
||||
import com.djrapitops.plan.storage.database.sql.tables.ExtensionPluginTable;
|
||||
@ -32,7 +33,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.*;
|
||||
@ -45,12 +45,12 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTab
|
||||
public class StoreServerTableResultTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final String pluginName;
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final String providerName;
|
||||
|
||||
private final Table table;
|
||||
|
||||
public StoreServerTableResultTransaction(String pluginName, UUID serverUUID, String providerName, Table table) {
|
||||
public StoreServerTableResultTransaction(String pluginName, ServerUUID serverUUID, String providerName, Table table) {
|
||||
this.pluginName = pluginName;
|
||||
this.serverUUID = serverUUID;
|
||||
this.providerName = providerName;
|
||||
|
@ -16,10 +16,10 @@
|
||||
*/
|
||||
package com.djrapitops.plan.gathering;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
@ -29,10 +29,10 @@ import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.playeranalytics.plugin.server.PluginLogger;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Class in charge of performing save operations when the server shuts down.
|
||||
@ -72,7 +72,7 @@ public abstract class ServerShutdownSave {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Map<UUID, Session> activeSessions = SessionCache.getActiveSessions();
|
||||
Collection<ActiveSession> activeSessions = SessionCache.getActiveSessions();
|
||||
if (activeSessions.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@ -85,10 +85,9 @@ public abstract class ServerShutdownSave {
|
||||
return attemptSave(activeSessions);
|
||||
}
|
||||
|
||||
private Optional<Future<?>> attemptSave(Map<UUID, Session> activeSessions) {
|
||||
private Optional<Future<?>> attemptSave(Collection<ActiveSession> activeSessions) {
|
||||
try {
|
||||
prepareSessionsForStorage(activeSessions, System.currentTimeMillis());
|
||||
return Optional.of(saveActiveSessions(activeSessions));
|
||||
return Optional.of(saveActiveSessions(finishSessions(activeSessions, System.currentTimeMillis())));
|
||||
} catch (DBInitException e) {
|
||||
errorLogger.error(e, ErrorContext.builder()
|
||||
.whatToDo("Find the sessions in the error file and save them manually or ignore. Report & delete the error file after.")
|
||||
@ -104,7 +103,7 @@ public abstract class ServerShutdownSave {
|
||||
}
|
||||
}
|
||||
|
||||
private Future<?> saveActiveSessions(Map<UUID, Session> activeSessions) {
|
||||
private Future<?> saveActiveSessions(Collection<FinishedSession> finishedSessions) {
|
||||
Database database = dbSystem.getDatabase();
|
||||
if (database.getState() == Database.State.CLOSED) {
|
||||
// Ensure that database is not closed when performing the transaction.
|
||||
@ -112,20 +111,15 @@ public abstract class ServerShutdownSave {
|
||||
database.init();
|
||||
}
|
||||
|
||||
return saveSessions(activeSessions, database);
|
||||
return saveSessions(finishedSessions, database);
|
||||
}
|
||||
|
||||
void prepareSessionsForStorage(Map<UUID, Session> activeSessions, long now) {
|
||||
for (Session session : activeSessions.values()) {
|
||||
Optional<Long> end = session.getValue(SessionKeys.END);
|
||||
if (!end.isPresent()) {
|
||||
session.endSession(now);
|
||||
}
|
||||
}
|
||||
Collection<FinishedSession> finishSessions(Collection<ActiveSession> activeSessions, long now) {
|
||||
return activeSessions.stream().map(session -> session.toFinishedSession(now)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Future<?> saveSessions(Map<UUID, Session> activeSessions, Database database) {
|
||||
return database.executeTransaction(new ServerShutdownTransaction(activeSessions.values()));
|
||||
private Future<?> saveSessions(Collection<FinishedSession> finishedSessions, Database database) {
|
||||
return database.executeTransaction(new ServerShutdownTransaction(finishedSessions));
|
||||
}
|
||||
|
||||
private void closeDatabase(Database database) {
|
||||
|
@ -74,7 +74,7 @@ public class AFKTracker {
|
||||
long timeAFK = time - lastMoved - removeAfkCommandEffect;
|
||||
|
||||
SessionCache.getCachedSession(uuid)
|
||||
.ifPresent(session -> session.addAFKTime(timeAFK));
|
||||
.ifPresent(session -> session.addAfkTime(timeAFK));
|
||||
} finally {
|
||||
usedAFKCommand.remove(uuid);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.cache;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -32,16 +32,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Singleton
|
||||
public class SessionCache {
|
||||
|
||||
private static final Map<UUID, Session> ACTIVE_SESSIONS = new ConcurrentHashMap<>();
|
||||
private static final Map<UUID, ActiveSession> ACTIVE_SESSIONS = new ConcurrentHashMap<>();
|
||||
|
||||
@Inject
|
||||
public SessionCache() {
|
||||
// Dagger requires empty inject constructor
|
||||
}
|
||||
|
||||
public static Map<UUID, Session> getActiveSessions() {
|
||||
public static Collection<ActiveSession> getActiveSessions() {
|
||||
refreshActiveSessionsState();
|
||||
return Collections.unmodifiableMap(new HashMap<>(ACTIVE_SESSIONS));
|
||||
return new HashSet<>(ACTIVE_SESSIONS.values());
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
@ -49,7 +49,7 @@ public class SessionCache {
|
||||
}
|
||||
|
||||
public static void refreshActiveSessionsState() {
|
||||
ACTIVE_SESSIONS.values().forEach(Session::updateState);
|
||||
ACTIVE_SESSIONS.values().forEach(ActiveSession::updateState);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,9 +58,9 @@ public class SessionCache {
|
||||
* @param playerUUID UUID of the player.
|
||||
* @return Optional with the session inside it if found.
|
||||
*/
|
||||
public static Optional<Session> getCachedSession(UUID playerUUID) {
|
||||
Optional<Session> found = Optional.ofNullable(ACTIVE_SESSIONS.get(playerUUID));
|
||||
found.ifPresent(Session::updateState);
|
||||
public static Optional<ActiveSession> getCachedSession(UUID playerUUID) {
|
||||
Optional<ActiveSession> found = Optional.ofNullable(ACTIVE_SESSIONS.get(playerUUID));
|
||||
found.ifPresent(ActiveSession::updateState);
|
||||
return found;
|
||||
}
|
||||
|
||||
@ -68,32 +68,36 @@ public class SessionCache {
|
||||
* Cache a new session.
|
||||
*
|
||||
* @param playerUUID UUID of the player
|
||||
* @param session Session to cache.
|
||||
* @param newSession Session to cache.
|
||||
* @return Optional: previous session. Recipients of this object should decide if it needs to be saved.
|
||||
*/
|
||||
public Optional<Session> cacheSession(UUID playerUUID, Session session) {
|
||||
Optional<Session> inProgress = Optional.empty();
|
||||
if (getCachedSession(playerUUID).isPresent()) {
|
||||
inProgress = endSession(playerUUID, session.getUnsafe(SessionKeys.START));
|
||||
public Optional<FinishedSession> cacheSession(UUID playerUUID, ActiveSession newSession) {
|
||||
Optional<ActiveSession> inProgress = getCachedSession(playerUUID);
|
||||
Optional<FinishedSession> finished = Optional.empty();
|
||||
if (inProgress.isPresent()) {
|
||||
finished = endSession(playerUUID, newSession.getStart(), inProgress.get());
|
||||
}
|
||||
ACTIVE_SESSIONS.put(playerUUID, session);
|
||||
return inProgress;
|
||||
ACTIVE_SESSIONS.put(playerUUID, newSession);
|
||||
return finished;
|
||||
}
|
||||
|
||||
/**
|
||||
* End a session and save it to database.
|
||||
*
|
||||
* @param playerUUID UUID of the player.
|
||||
* @param time Time the session ended.
|
||||
* @param playerUUID UUID of the player.
|
||||
* @param time Time the session ended.
|
||||
* @param activeSession Currently active session
|
||||
* @return Optional: ended session. Recipients of this object should decide if it needs to be saved.
|
||||
*/
|
||||
public Optional<Session> endSession(UUID playerUUID, long time) {
|
||||
Session session = ACTIVE_SESSIONS.get(playerUUID);
|
||||
if (session == null || session.getUnsafe(SessionKeys.START) > time) {
|
||||
public Optional<FinishedSession> endSession(UUID playerUUID, long time, ActiveSession activeSession) {
|
||||
if (activeSession == null || activeSession.getStart() > time) {
|
||||
return Optional.empty();
|
||||
}
|
||||
ACTIVE_SESSIONS.remove(playerUUID);
|
||||
session.endSession(time);
|
||||
return Optional.of(session);
|
||||
return Optional.of(activeSession.toFinishedSession(time));
|
||||
}
|
||||
|
||||
public Optional<FinishedSession> endSession(UUID playerUUID, long time) {
|
||||
return endSession(playerUUID, time, ACTIVE_SESSIONS.get(playerUUID));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
import com.djrapitops.plan.gathering.domain.event.PlayerJoin;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ActiveSession {
|
||||
|
||||
private final UUID playerUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final long start;
|
||||
private final DataMap extraData;
|
||||
private long afkTime;
|
||||
|
||||
public ActiveSession(UUID playerUUID, ServerUUID serverUUID, long start, String world, String gameMode) {
|
||||
this.playerUUID = playerUUID;
|
||||
this.serverUUID = serverUUID;
|
||||
this.start = start;
|
||||
this.afkTime = 0L;
|
||||
|
||||
extraData = new DataMap();
|
||||
extraData.put(WorldTimes.class, new WorldTimes(world, gameMode, start));
|
||||
extraData.put(MobKillCounter.class, new MobKillCounter());
|
||||
extraData.put(DeathCounter.class, new DeathCounter());
|
||||
extraData.put(PlayerKills.class, new PlayerKills());
|
||||
}
|
||||
|
||||
public static ActiveSession fromPlayerJoin(PlayerJoin join) {
|
||||
return new ActiveSession(join.getPlayerUUID(), join.getServerUUID(), join.getTime(), join.getWorld(), join.getGameMode());
|
||||
}
|
||||
|
||||
public FinishedSession toFinishedSessionFromStillActive() {
|
||||
FinishedSession finishedSession = toFinishedSession(System.currentTimeMillis());
|
||||
finishedSession.getExtraData().put(ActiveSession.class, this);
|
||||
return finishedSession;
|
||||
}
|
||||
|
||||
public FinishedSession toFinishedSession(long end) {
|
||||
return new FinishedSession(playerUUID, serverUUID, start, end, afkTime, extraData);
|
||||
}
|
||||
|
||||
public UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
public long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void addAfkTime(long time) {
|
||||
afkTime += time;
|
||||
}
|
||||
|
||||
public void addDeath() {
|
||||
extraData.get(DeathCounter.class).ifPresent(Counter::add);
|
||||
}
|
||||
|
||||
public void addMobKill() {
|
||||
extraData.get(MobKillCounter.class).ifPresent(Counter::add);
|
||||
}
|
||||
|
||||
public void addPlayerKill(PlayerKill kill) {
|
||||
extraData.get(PlayerKills.class).ifPresent(kills -> kills.add(kill));
|
||||
}
|
||||
|
||||
public void setAsFirstSessionIfMatches(Long registerDate) {
|
||||
if (registerDate != null && Math.abs(start - registerDate) < TimeUnit.SECONDS.toMillis(15L)) {
|
||||
extraData.put(FirstSession.class, new FirstSession());
|
||||
}
|
||||
}
|
||||
|
||||
public DataMap getExtraData() {
|
||||
return extraData;
|
||||
}
|
||||
|
||||
public void updateState() {
|
||||
extraData.get(WorldTimes.class).ifPresent(times -> times.updateState(System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
public void changeState(String world, String gameMode, long time) {
|
||||
extraData.get(WorldTimes.class).ifPresent(times -> times.updateState(world, gameMode, time));
|
||||
}
|
||||
|
||||
public <T> Optional<T> getExtraData(Class<T> ofType) {
|
||||
return getExtraData().get(ofType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ActiveSession that = (ActiveSession) o;
|
||||
return start == that.start && afkTime == that.afkTime &&
|
||||
Objects.equals(playerUUID, that.playerUUID) &&
|
||||
Objects.equals(serverUUID, that.serverUUID) &&
|
||||
Objects.equals(getExtraData(WorldTimes.class), that.getExtraData(WorldTimes.class)) &&
|
||||
Objects.equals(getExtraData(PlayerKills.class), that.getExtraData(PlayerKills.class)) &&
|
||||
Objects.equals(getExtraData(MobKillCounter.class), that.getExtraData(MobKillCounter.class)) &&
|
||||
Objects.equals(getExtraData(DeathCounter.class), that.getExtraData(DeathCounter.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(playerUUID, serverUUID, start, afkTime, extraData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActiveSession{" +
|
||||
"playerUUID=" + playerUUID +
|
||||
", serverUUID=" + serverUUID +
|
||||
", start=" + start +
|
||||
", afkTime=" + afkTime +
|
||||
", extraData=" + extraData +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class FirstSession {}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Counter {
|
||||
|
||||
private int count;
|
||||
|
||||
public Counter() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public Counter(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void add() {
|
||||
count++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Counter counter = (Counter) o;
|
||||
return count == counter.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Counter{" +
|
||||
"count=" + count +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DataMap {
|
||||
|
||||
private final Map<Class<?>, Object> data;
|
||||
|
||||
public DataMap() {
|
||||
this.data = new HashMap<>();
|
||||
}
|
||||
|
||||
public <T> void put(Class<T> type, T value) {
|
||||
data.put(type, value);
|
||||
}
|
||||
|
||||
public <T> Optional<T> get(Class<T> ofType) {
|
||||
return Optional.ofNullable(ofType.cast(data.get(ofType)));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DataMap dataMap = (DataMap) o;
|
||||
return Objects.equals(data, dataMap.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataMap{" +
|
||||
"data=" + data +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
public class DeathCounter extends Counter {
|
||||
|
||||
public DeathCounter() {
|
||||
}
|
||||
|
||||
public DeathCounter(int count) {
|
||||
super(count);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.DateHolder;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class FinishedSession implements DateHolder {
|
||||
|
||||
private final UUID playerUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final long start;
|
||||
private final long end;
|
||||
|
||||
private final long afkTime;
|
||||
private final DataMap extraData;
|
||||
|
||||
public FinishedSession(
|
||||
UUID playerUUID, ServerUUID serverUUID,
|
||||
long start, long end, long afkTime,
|
||||
DataMap extraData
|
||||
) {
|
||||
this.playerUUID = playerUUID;
|
||||
this.serverUUID = serverUUID;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.afkTime = afkTime;
|
||||
this.extraData = extraData;
|
||||
}
|
||||
|
||||
public UUID getPlayerUUID() {
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
public long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public long getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public long getAfkTime() {
|
||||
return afkTime;
|
||||
}
|
||||
|
||||
public long getLength() {
|
||||
return end - start;
|
||||
}
|
||||
|
||||
public long getActiveTime() {
|
||||
return getLength() - getAfkTime();
|
||||
}
|
||||
|
||||
public int getMobKillCount() {
|
||||
return extraData.get(MobKillCounter.class).map(MobKillCounter::getCount).orElse(0);
|
||||
}
|
||||
|
||||
public int getDeathCount() {
|
||||
return extraData.get(DeathCounter.class).map(DeathCounter::getCount).orElse(0);
|
||||
}
|
||||
|
||||
public int getPlayerKillCount() {
|
||||
return extraData.get(PlayerKills.class).map(PlayerKills::asList).map(List::size).orElse(0);
|
||||
}
|
||||
|
||||
public void setAsFirstSessionIfMatches(Long registerDate) {
|
||||
if (registerDate != null && Math.abs(start - registerDate) < TimeUnit.SECONDS.toMillis(15L)) {
|
||||
extraData.put(ActiveSession.FirstSession.class, new ActiveSession.FirstSession());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFirstSession() {
|
||||
return extraData.get(ActiveSession.FirstSession.class).isPresent();
|
||||
}
|
||||
|
||||
public DataMap getExtraData() {
|
||||
return extraData;
|
||||
}
|
||||
|
||||
public <T> Optional<T> getExtraData(Class<T> ofType) {
|
||||
return getExtraData().get(ofType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDate() {
|
||||
return getStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FinishedSession that = (FinishedSession) o;
|
||||
return start == that.start && end == that.end &&
|
||||
afkTime == that.afkTime &&
|
||||
Objects.equals(playerUUID, that.playerUUID) &&
|
||||
Objects.equals(serverUUID, that.serverUUID) &&
|
||||
Objects.equals(getExtraData(WorldTimes.class), that.getExtraData(WorldTimes.class)) &&
|
||||
Objects.equals(getExtraData(PlayerKills.class), that.getExtraData(PlayerKills.class)) &&
|
||||
Objects.equals(getExtraData(MobKillCounter.class), that.getExtraData(MobKillCounter.class)) &&
|
||||
Objects.equals(getExtraData(DeathCounter.class), that.getExtraData(DeathCounter.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(playerUUID, serverUUID, start, end, afkTime, extraData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FinishedSession{" +
|
||||
"playerUUID=" + playerUUID +
|
||||
", serverUUID=" + serverUUID +
|
||||
", start=" + start +
|
||||
", end=" + end +
|
||||
", afkTime=" + afkTime +
|
||||
", extraData=" + extraData +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class Id {
|
||||
private final int id;
|
||||
|
||||
public Id(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
@ -114,4 +114,13 @@ public class GMTimes extends TimeKeeper {
|
||||
String state = super.getState();
|
||||
return state != null ? state : SURVIVAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GMTimes{" +
|
||||
"times=" + times +
|
||||
", state='" + state + '\'' +
|
||||
", lastStateChange=" + lastStateChange +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
public class MobKillCounter extends Counter {
|
||||
|
||||
public MobKillCounter() {
|
||||
}
|
||||
|
||||
public MobKillCounter(int count) {
|
||||
super(count);
|
||||
}
|
||||
}
|
@ -17,18 +17,18 @@
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.DateObj;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Ping extends DateObj<Double> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private final ServerUUID serverUUID;
|
||||
private final double average;
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
||||
public Ping(long date, UUID serverUUID, int min, int max, double average) {
|
||||
public Ping(long date, ServerUUID serverUUID, int min, int max, double average) {
|
||||
super(date, average);
|
||||
this.serverUUID = serverUUID;
|
||||
this.average = average;
|
||||
@ -36,7 +36,7 @@ public class Ping extends DateObj<Double> {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public UUID getServerUUID() {
|
||||
public ServerUUID getServerUUID() {
|
||||
return serverUUID;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.gathering.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerDeaths {
|
||||
|
||||
private final DeathCounter deathCounter;
|
||||
private final List<PlayerKill> deaths;
|
||||
|
||||
public PlayerDeaths(DeathCounter deathCounter) {
|
||||
this(deathCounter, new ArrayList<>());
|
||||
}
|
||||
|
||||
public PlayerDeaths(DeathCounter deathCounter, List<PlayerKill> deaths) {
|
||||
this.deathCounter = deathCounter;
|
||||
this.deaths = deaths;
|
||||
}
|
||||
|
||||
public void add(PlayerKill kill) {
|
||||
deaths.add(kill);
|
||||
}
|
||||
|
||||
public List<PlayerKill> playerCausedDeathsAsList() {
|
||||
return deaths;
|
||||
}
|
||||
|
||||
public int getDeathCount() {
|
||||
return deathCounter.getCount();
|
||||
}
|
||||
|
||||
public int getPlayerCausedDeathCount() {
|
||||
return playerCausedDeathsAsList().size();
|
||||
}
|
||||
|
||||
public int getMobCausedDeathCount() {
|
||||
return getDeathCount() - getPlayerCausedDeathCount();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user