From 8f6c286d9c5b5893d9e275d85dd5efda913241b6 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Wed, 3 Feb 2021 19:25:04 +0200 Subject: [PATCH] Removed ServerContainerQuery APIv4 (deprecated) getServerContainer now returns empty data --- .../com/djrapitops/plan/api/CommonAPI.java | 2 +- .../containers/ContainerFetchQueries.java | 12 --- .../containers/ServerContainerQuery.java | 101 ------------------ 3 files changed, 1 insertion(+), 114 deletions(-) delete mode 100644 Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ServerContainerQuery.java diff --git a/Plan/common/src/main/java/com/djrapitops/plan/api/CommonAPI.java b/Plan/common/src/main/java/com/djrapitops/plan/api/CommonAPI.java index 990c9186c..f2550d1c4 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/api/CommonAPI.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/api/CommonAPI.java @@ -106,7 +106,7 @@ public class CommonAPI implements PlanAPI { @Override public ServerContainer fetchServerContainer(UUID serverUUID) { - return new ServerContainer(queryDB(ContainerFetchQueries.fetchServerContainer(serverUUID))); + return new ServerContainer(new com.djrapitops.plan.delivery.domain.container.ServerContainer()); } @Override diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ContainerFetchQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ContainerFetchQueries.java index 599e493f8..b9d257228 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ContainerFetchQueries.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ContainerFetchQueries.java @@ -18,7 +18,6 @@ package com.djrapitops.plan.storage.database.queries.containers; import com.djrapitops.plan.delivery.domain.container.DataContainer; import com.djrapitops.plan.delivery.domain.container.PlayerContainer; -import com.djrapitops.plan.delivery.domain.container.ServerContainer; import com.djrapitops.plan.storage.database.queries.Query; import java.util.UUID; @@ -34,17 +33,6 @@ public class ContainerFetchQueries { /* Static method class */ } - /** - * Used to get a ServerContainer, some limitations apply to values returned by DataContainer keys. - * - * @param serverUUID UUID of the Server. - * @return a new ServerContainer. - * @see ServerContainerQuery - */ - public static Query fetchServerContainer(UUID serverUUID) { - return new ServerContainerQuery(serverUUID); - } - /** * Used to get a PlayerContainer of a specific player. *

diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ServerContainerQuery.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ServerContainerQuery.java deleted file mode 100644 index 54dd3373e..000000000 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/containers/ServerContainerQuery.java +++ /dev/null @@ -1,101 +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 . - */ -package com.djrapitops.plan.storage.database.queries.containers; - -import com.djrapitops.plan.delivery.domain.container.ServerContainer; -import com.djrapitops.plan.delivery.domain.keys.ServerKeys; -import com.djrapitops.plan.delivery.domain.mutators.PlayersMutator; -import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator; -import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery; -import com.djrapitops.plan.gathering.cache.SessionCache; -import com.djrapitops.plan.gathering.domain.Session; -import com.djrapitops.plan.identification.Server; -import com.djrapitops.plan.storage.database.SQLDB; -import com.djrapitops.plan.storage.database.queries.Query; -import com.djrapitops.plan.storage.database.queries.objects.ServerQueries; -import com.djrapitops.plan.storage.database.queries.objects.TPSQueries; -import com.djrapitops.plan.storage.database.queries.objects.WorldTimesQueries; - -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -/** - * Used to get a ServerContainer, some limitations apply to values returned by DataContainer keys. - *

- * Limitations: - * - ServerKeys.PLAYERS PlayerContainers PlayerKeys.PER_SERVER only contains information about the queried server. - *

- * Blocking methods are not called until DataContainer getter methods are called. - * - * @author Rsl1122 - */ -public class ServerContainerQuery implements Query { - - private final UUID serverUUID; - - public ServerContainerQuery(UUID serverUUID) { - this.serverUUID = serverUUID; - } - - @Override - public ServerContainer executeQuery(SQLDB db) { - ServerContainer container = new ServerContainer(); - - Optional serverInfo = db.query(ServerQueries.fetchServerMatchingIdentifier(serverUUID)); - if (!serverInfo.isPresent()) { - return container; - } - - container.putRawData(ServerKeys.SERVER_UUID, serverUUID); - container.putRawData(ServerKeys.NAME, serverInfo.get().getName()); - container.putCachingSupplier(ServerKeys.PLAYERS, () -> db.query(new ServerPlayerContainersQuery(serverUUID))); - container.putSupplier(ServerKeys.PLAYER_COUNT, () -> container.getValue(ServerKeys.PLAYERS).map(Collection::size).orElse(0)); - - container.putCachingSupplier(ServerKeys.TPS, () -> db.query(TPSQueries.fetchTPSDataOfServer(serverUUID))); - container.putCachingSupplier(ServerKeys.PING, () -> PlayersMutator.forContainer(container).pings()); - container.putCachingSupplier(ServerKeys.ALL_TIME_PEAK_PLAYERS, () -> - db.query(TPSQueries.fetchAllTimePeakPlayerCount(serverUUID)).orElse(null) - ); - container.putCachingSupplier(ServerKeys.RECENT_PEAK_PLAYERS, () -> { - long twoDaysAgo = System.currentTimeMillis() - (TimeUnit.DAYS.toMillis(2L)); - return db.query(TPSQueries.fetchPeakPlayerCount(serverUUID, twoDaysAgo)).orElse(null); - }); - - container.putCachingSupplier(ServerKeys.WORLD_TIMES, () -> db.query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID))); - - // Calculating getters - container.putCachingSupplier(ServerKeys.OPERATORS, () -> PlayersMutator.forContainer(container).operators()); - container.putCachingSupplier(ServerKeys.SESSIONS, () -> { - List sessions = PlayersMutator.forContainer(container).getSessions(); - if (serverUUID.equals(serverInfo.get().getUuid())) { - sessions.addAll(SessionCache.getActiveSessions().values()); - } - return sessions; - }); - container.putCachingSupplier(ServerKeys.PLAYER_KILLS, () -> SessionsMutator.forContainer(container).toPlayerKillList()); - container.putCachingSupplier(ServerKeys.PLAYER_KILL_COUNT, () -> container.getUnsafe(ServerKeys.PLAYER_KILLS).size()); - container.putCachingSupplier(ServerKeys.MOB_KILL_COUNT, () -> SessionsMutator.forContainer(container).toMobKillCount()); - container.putCachingSupplier(ServerKeys.DEATH_COUNT, () -> SessionsMutator.forContainer(container).toDeathCount()); - - container.putCachingSupplier(ServerKeys.EXTENSION_DATA, () -> db.query(new ExtensionServerDataQuery(serverUUID))); - - return container; - } -} \ No newline at end of file