From 604bfd9e67f0aba3b2428bf5adba26c7055fa3ba Mon Sep 17 00:00:00 2001 From: Aurora Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Thu, 7 Apr 2022 18:24:40 +0300 Subject: [PATCH] Add Plan version to /plan servers Affects issues: - Resolve #2245 --- .../plan/identification/BungeeServerInfo.java | 12 ++++--- .../commands/subcommands/LinkCommands.java | 2 +- .../plan/identification/Server.java | 13 ++++++-- .../plan/identification/ServerServerInfo.java | 7 +++- .../storage/ServerFileLoader.java | 6 +++- .../settings/locale/lang/CommandLang.java | 2 +- .../plan/storage/database/SQLDB.java | 3 +- .../queries/objects/ServerQueries.java | 20 +++++------ .../database/sql/tables/ServerTable.java | 18 +++++----- .../StoreServerInformationTransaction.java | 4 ++- .../patches/ServerPlanVersionPatch.java | 33 +++++++++++++++++++ .../assets/plan/locale/locale_CN.yml | 2 +- .../assets/plan/locale/locale_CS.yml | 2 +- .../assets/plan/locale/locale_DE.yml | 2 +- .../assets/plan/locale/locale_EN.yml | 2 +- .../assets/plan/locale/locale_ES.yml | 2 +- .../assets/plan/locale/locale_FI.yml | 2 +- .../assets/plan/locale/locale_FR.yml | 2 +- .../assets/plan/locale/locale_IT.yml | 2 +- .../assets/plan/locale/locale_JA.yml | 2 +- .../assets/plan/locale/locale_KO.yml | 2 +- .../assets/plan/locale/locale_NL.yml | 2 +- .../assets/plan/locale/locale_PT_BR.yml | 2 +- .../assets/plan/locale/locale_RU.yml | 2 +- .../assets/plan/locale/locale_TR.yml | 2 +- .../assets/plan/locale/locale_ZH_TW.yml | 2 +- .../delivery/webserver/AccessControlTest.java | 4 +-- .../plan/gathering/ShutdownSaveTest.java | 4 +-- .../plan/storage/database/MySQLTest.java | 4 +-- .../plan/storage/database/SQLiteTest.java | 5 +-- .../database/queries/ServerQueriesTest.java | 3 +- .../database/queries/SessionQueriesTest.java | 14 +++++--- .../database/queries/UserInfoQueriesTest.java | 4 +-- .../sql/building/CreateTableBuilderTest.java | 2 +- .../test/java/utilities/TestConstants.java | 3 ++ .../src/test/java/utilities/TestData.java | 4 +-- .../utilities/dagger/ProxyServerInfo.java | 6 +++- .../identification/VelocityServerInfo.java | 10 ++++-- 38 files changed, 143 insertions(+), 70 deletions(-) create mode 100644 Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/patches/ServerPlanVersionPatch.java diff --git a/Plan/bungeecord/src/main/java/com/djrapitops/plan/identification/BungeeServerInfo.java b/Plan/bungeecord/src/main/java/com/djrapitops/plan/identification/BungeeServerInfo.java index 4e1712aaa..af0a618b7 100644 --- a/Plan/bungeecord/src/main/java/com/djrapitops/plan/identification/BungeeServerInfo.java +++ b/Plan/bungeecord/src/main/java/com/djrapitops/plan/identification/BungeeServerInfo.java @@ -28,6 +28,7 @@ import com.djrapitops.plan.settings.locale.lang.PluginLang; import net.playeranalytics.plugin.server.PluginLogger; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; /** @@ -38,6 +39,7 @@ import javax.inject.Singleton; @Singleton public class BungeeServerInfo extends ServerInfo { + private final String currentVersion; private final ServerLoader fromFile; private final ServerLoader fromDatabase; @@ -49,6 +51,7 @@ public class BungeeServerInfo extends ServerInfo { @Inject public BungeeServerInfo( + @Named("currentVersion") String currentVersion, ServerProperties serverProperties, ServerFileLoader fromFile, ServerDBLoader fromDatabase, @@ -58,6 +61,7 @@ public class BungeeServerInfo extends ServerInfo { PluginLogger logger ) { super(serverProperties); + this.currentVersion = currentVersion; this.fromFile = fromFile; this.fromDatabase = fromDatabase; this.processing = processing; @@ -89,7 +93,7 @@ public class BungeeServerInfo extends ServerInfo { } /** - * @throws EnableException + * @throws EnableException If IP setting is unset */ private void checkIfDefaultIP() { String ip = serverProperties.getIp(); @@ -101,7 +105,7 @@ public class BungeeServerInfo extends ServerInfo { } /** - * @throws EnableException + * @throws EnableException If IP setting is unset */ private Server registerServer() { Server proxy = createServerObject(); @@ -115,11 +119,11 @@ public class BungeeServerInfo extends ServerInfo { } /** - * @throws EnableException + * @throws EnableException If IP setting is unset */ private Server createServerObject() { 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); + return new Server(-1, serverUUID, "BungeeCord", accessAddress, true, currentVersion); } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/LinkCommands.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/LinkCommands.java index 13f430cbe..e6b7d0c6e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/LinkCommands.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/LinkCommands.java @@ -125,7 +125,7 @@ public class LinkCommands { String serversListed = dbSystem.getDatabase() .query(ServerQueries.fetchPlanServerInformationCollection()) .stream().sorted() - .map(server -> m + server.getId().orElse(0) + "::" + t + server.getName() + "::" + s + server.getUuid() + "\n") + .map(server -> m + server.getId().orElse(0) + "::" + t + server.getName() + "::" + s + server.getUuid() + "::" + s + server.getPlanVersion() + "\n") .collect(StringBuilder::new, StringBuilder::append, StringBuilder::append) .toString(); sender.buildMessage() diff --git a/Plan/common/src/main/java/com/djrapitops/plan/identification/Server.java b/Plan/common/src/main/java/com/djrapitops/plan/identification/Server.java index ed92faeaf..9c4545b38 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/identification/Server.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/identification/Server.java @@ -31,16 +31,19 @@ public class Server implements Comparable { private String webAddress; private boolean proxy; - public Server(ServerUUID uuid, String name, String webAddress) { - this(null, uuid, name, webAddress, false); + private final String planVersion; + + public Server(ServerUUID uuid, String name, String webAddress, String planVersion) { + this(null, uuid, name, webAddress, false, planVersion); } - public Server(Integer id, ServerUUID uuid, String name, String webAddress, boolean proxy) { + public Server(Integer id, ServerUUID uuid, String name, String webAddress, boolean proxy, String planVersion) { this.id = id; this.uuid = uuid; this.name = name; this.webAddress = webAddress; this.proxy = proxy; + this.planVersion = planVersion; } public Optional getId() { @@ -79,6 +82,10 @@ public class Server implements Comparable { this.webAddress = webAddress; } + public String getPlanVersion() { + return planVersion; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java b/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java index efe1d181f..ee292620f 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java @@ -30,6 +30,7 @@ import com.djrapitops.plan.settings.locale.lang.PluginLang; import net.playeranalytics.plugin.server.PluginLogger; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; import java.util.Optional; @@ -43,6 +44,8 @@ import java.util.Optional; @Singleton public class ServerServerInfo extends ServerInfo { + private final String currentVersion; + private final ServerLoader fromFile; private final ServerLoader fromDatabase; @@ -55,6 +58,7 @@ public class ServerServerInfo extends ServerInfo { @Inject public ServerServerInfo( + @Named("currentVersion") String currentVersion, ServerProperties serverProperties, ServerFileLoader fromFile, ServerDBLoader fromDatabase, @@ -65,6 +69,7 @@ public class ServerServerInfo extends ServerInfo { PluginLogger logger ) { super(serverProperties); + this.currentVersion = currentVersion; this.fromFile = fromFile; this.fromDatabase = fromDatabase; this.processing = processing; @@ -112,6 +117,6 @@ public class ServerServerInfo extends ServerInfo { private Server createServerObject(ServerUUID serverUUID) { String webAddress = addresses.getAccessAddress().orElseGet(addresses::getFallbackLocalhostAddress); String name = config.get(PluginSettings.SERVER_NAME); - return new Server(serverUUID, name, webAddress); + return new Server(serverUUID, name, webAddress, currentVersion); } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java b/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java index 06898ffd3..3ae5c952d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java @@ -27,6 +27,7 @@ import com.djrapitops.plan.settings.config.paths.PluginSettings; import com.djrapitops.plan.storage.file.PlanFiles; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; import java.io.IOException; import java.util.Objects; @@ -35,6 +36,7 @@ import java.util.Optional; @Singleton public class ServerFileLoader extends Config implements ServerLoader { + private final String currentVersion; private final PlanFiles files; private final PlanConfig config; @@ -42,10 +44,12 @@ public class ServerFileLoader extends Config implements ServerLoader { @Inject public ServerFileLoader( + @Named("currentVersion") String currentVersion, PlanFiles files, PlanConfig config ) { super(files.getFileFromPluginFolder("ServerInfoFile.yml")); + this.currentVersion = currentVersion; this.files = files; this.config = config; @@ -76,7 +80,7 @@ public class ServerFileLoader extends Config implements ServerLoader { .orElse("Proxy"); String address = getString("Server.Web_address"); - return Optional.of(new Server(id, serverUUID, name, address, false)); + return Optional.of(new Server(id, serverUUID, name, address, false, currentVersion)); } catch (IOException e) { throw new EnableException("Failed to read ServerInfoFile.yml: " + e.getMessage()); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java index 547d18242..3ca92c0f5 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/CommandLang.java @@ -81,7 +81,7 @@ public enum CommandLang implements Lang { HEADER_PLAYERS("command.header.players", "Cmd Header - Players", "> §2Players"), HEADER_WEB_USERS("command.header.webUsers", "Cmd Header - Web Users", "> §2${0} Web Users"), HEADER_NETWORK("command.header.network", "Cmd Header - Network", "> §2Network Page"), - HEADER_SERVER_LIST("command.header.serverList", "Cmd Header - server list", "id::name::uuid"), + HEADER_SERVER_LIST("command.header.serverList", "Cmd Header - server list", "id::name::uuid::version"), HEADER_WEB_USER_LIST("command.header.webUserList", "Cmd Header - web user list", "username::linked to::permission level"), INFO_VERSION("command.subcommand.info.version", "Cmd Info - Version", " §2Version: §f${0}"), diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java index ee6ef27fe..6bf02282a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java @@ -218,7 +218,8 @@ public abstract class SQLDB extends AbstractDatabase { new PlayerTableRowPatch(), new ExtensionTableProviderValuesForPatch(), new RemoveIncorrectTebexPackageDataPatch(), - new ExtensionTableProviderFormattersPatch() + new ExtensionTableProviderFormattersPatch(), + new ServerPlanVersionPatch() }; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/ServerQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/ServerQueries.java index 1c241ef9b..49ec770a6 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/ServerQueries.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/ServerQueries.java @@ -62,8 +62,8 @@ public class ServerQueries { ServerUUID.fromString(set.getString(ServerTable.SERVER_UUID)), set.getString(ServerTable.NAME), set.getString(ServerTable.WEB_ADDRESS), - set.getBoolean(ServerTable.PROXY) - )); + set.getBoolean(ServerTable.PROXY), + set.getString(ServerTable.PLAN_VERSION))); } return servers; } @@ -94,8 +94,8 @@ public class ServerQueries { serverUUID, set.getString(ServerTable.NAME), set.getString(ServerTable.WEB_ADDRESS), - set.getBoolean(ServerTable.PROXY) - )); + set.getBoolean(ServerTable.PROXY), + set.getString(ServerTable.PLAN_VERSION))); } return servers; } @@ -137,8 +137,8 @@ public class ServerQueries { ServerUUID.fromString(set.getString(ServerTable.SERVER_UUID)), set.getString(ServerTable.NAME), set.getString(ServerTable.WEB_ADDRESS), - set.getBoolean(ServerTable.PROXY) - )); + set.getBoolean(ServerTable.PROXY), + set.getString(ServerTable.PLAN_VERSION))); } return Optional.empty(); } @@ -165,8 +165,8 @@ public class ServerQueries { ServerUUID.fromString(set.getString(ServerTable.SERVER_UUID)), set.getString(ServerTable.NAME), set.getString(ServerTable.WEB_ADDRESS), - set.getBoolean(ServerTable.PROXY) - )); + set.getBoolean(ServerTable.PROXY), + set.getString(ServerTable.PLAN_VERSION))); } return Optional.empty(); } @@ -239,8 +239,8 @@ public class ServerQueries { ServerUUID.fromString(set.getString(ServerTable.SERVER_UUID)), set.getString(ServerTable.NAME), set.getString(ServerTable.WEB_ADDRESS), - set.getBoolean(ServerTable.PROXY) - )); + set.getBoolean(ServerTable.PROXY), + set.getString(ServerTable.PLAN_VERSION))); } return matches; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/ServerTable.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/ServerTable.java index 88ae1050a..c1cf72a9b 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/ServerTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/tables/ServerTable.java @@ -45,19 +45,19 @@ public class ServerTable { public static final String WEB_ADDRESS = "web_address"; public static final String INSTALLED = "is_installed"; public static final String PROXY = "is_proxy"; - @Deprecated - public static final String MAX_PLAYERS = "max_players"; + public static final String PLAN_VERSION = "plan_version"; public static final String INSERT_STATEMENT = Insert.values(TABLE_NAME, SERVER_UUID, NAME, - WEB_ADDRESS, INSTALLED, PROXY); + WEB_ADDRESS, INSTALLED, PROXY, PLAN_VERSION); public static final String UPDATE_STATEMENT = Update.values(TABLE_NAME, - SERVER_UUID, - NAME, - WEB_ADDRESS, - INSTALLED, - PROXY) + SERVER_UUID, + NAME, + WEB_ADDRESS, + INSTALLED, + PROXY, + PLAN_VERSION) .where(SERVER_UUID + "=?") .toString(); @@ -78,7 +78,7 @@ public class ServerTable { .column(WEB_ADDRESS, Sql.varchar(100)) .column(INSTALLED, Sql.BOOL).notNull().defaultValue(true) .column(PROXY, Sql.BOOL).notNull().defaultValue(false) - .column(MAX_PLAYERS, Sql.INT).notNull().defaultValue("-1") + .column(PLAN_VERSION, Sql.varchar(18)) .toString(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreServerInformationTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreServerInformationTransaction.java index 6797b6f5b..ccb18e97d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreServerInformationTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreServerInformationTransaction.java @@ -54,7 +54,8 @@ public class StoreServerInformationTransaction extends Transaction { statement.setString(3, server.getWebAddress()); statement.setBoolean(4, true); statement.setBoolean(5, server.isProxy()); - statement.setString(6, serverUUIDString); + statement.setString(6, server.getPlanVersion()); + statement.setString(7, serverUUIDString); } }; } @@ -68,6 +69,7 @@ public class StoreServerInformationTransaction extends Transaction { statement.setString(3, server.getWebAddress()); statement.setBoolean(4, true); statement.setBoolean(5, server.isProxy()); + statement.setString(6, server.getPlanVersion()); } }; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/patches/ServerPlanVersionPatch.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/patches/ServerPlanVersionPatch.java new file mode 100644 index 000000000..4ed8090d5 --- /dev/null +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/patches/ServerPlanVersionPatch.java @@ -0,0 +1,33 @@ +/* + * 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.transactions.patches; + +import com.djrapitops.plan.storage.database.sql.building.Sql; +import com.djrapitops.plan.storage.database.sql.tables.ServerTable; + +public class ServerPlanVersionPatch extends Patch { + + @Override + public boolean hasBeenApplied() { + return hasColumn(ServerTable.TABLE_NAME, ServerTable.PLAN_VERSION); + } + + @Override + protected void applyPatch() { + addColumn(ServerTable.TABLE_NAME, ServerTable.PLAN_VERSION + " " + Sql.varchar(18) + " DEFAULT 'Old'"); + } +} diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_CN.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_CN.yml index a968938c1..51725db75 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_CN.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_CN.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} 帮助" servers: "> §2全部服务器" search: "> §2${0} 对于 §f${1}§2 的结果:" - serverList: "id::名称::uuid" + serverList: "id::名称::uuid::version" inspect: "> §2玩家: §f${0}" network: "> §2群组网络页面" webUsers: "> §2${0} 网页用户" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_CS.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_CS.yml index 46fab7562..c85c53025 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_CS.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_CS.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Pomoc" servers: "> §2Servery" search: "> §2${0} Výsledky pro §f${1}§2:" - serverList: "id::jméno::uuid" + serverList: "id::jméno::uuid::version" inspect: "> §2Hráč: §f${0}" network: "> §2Stránka Sítě" webUsers: "> §2${0} Web uživatelé" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_DE.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_DE.yml index 89499fba9..4db432ac7 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_DE.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_DE.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Hilfe" servers: "> §2Server" search: "> §2${0} Ergebnisse für §f${1}§2:" - serverList: "id::name::uuid" + serverList: "id::name::uuid::version" inspect: "> §2Benutzer: §f${0}" network: "> §2Netzwerkseite" webUsers: "> §2${0} Accounts" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_EN.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_EN.yml index 67dfeea97..141b6eca2 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_EN.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_EN.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Help" servers: "> §2Servers" search: "> §2${0} Results for §f${1}§2:" - serverList: "id::name::uuid" + serverList: "id::name::uuid::version" inspect: "> §2Player: §f${0}" network: "> §2Network Page" webUsers: "> §2${0} Web Users" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_ES.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_ES.yml index a6d0c7087..0fa361a55 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_ES.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_ES.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Ayuda" servers: "> §2Servidores" search: "> §2${0} Resultados para §f${1}§2:" - serverList: "id::name::uuid" + serverList: "id::name::uuid::version" inspect: "> §2Jugador: §f${0}" network: "> §2Página de red" webUsers: "> §2${0} Usuarios web" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_FI.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_FI.yml index e744ef1d7..c737c299a 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_FI.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_FI.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Apu" servers: "> §2Palvelimet" search: "> §2${0} Tulosta haulle §f${1}§2:" - serverList: "id::nimi::uuid" + serverList: "id::nimi::uuid::version" inspect: "> §2Pelaaja: §f${0}" network: "> §2Verkoston Sivu" webUsers: "> §2${0} Web Käyttäjät" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_FR.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_FR.yml index 8062c85d2..e78fa7760 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_FR.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_FR.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Help" servers: "> §2Serveurs" search: "> §2${0} Résultats pour §f${1}§2 :" - serverList: "id::nom d'utilisateur::uuid" + serverList: "id::nom d'utilisateur::uuid::version" inspect: "> §2Joueur : §f${0}" network: "> §2Page du réseau" webUsers: "> §2${0} Utilisateurs Web" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_IT.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_IT.yml index c5d03be89..35461b4ac 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_IT.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_IT.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Help" servers: "> §2Servers" search: "> §2${0} Risultati per §f${1}§2:" - serverList: "id::name::uuid" + serverList: "id::name::uuid::version" inspect: "> §2Nome: §f${0}" network: "> §2Pagina Network" webUsers: "> §2${0} Utenti Web" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_JA.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_JA.yml index f111c3e60..6a03a7006 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_JA.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_JA.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0}の詳細" servers: "> §2サーバー" search: "> §2${0} §f${1}§2 の結果:" - serverList: "Minecraft id::名前::uuid" + serverList: "Minecraft id::名前::uuid::version" inspect: "> §2プレイヤー: §f${0}" network: "> §2ネットワークページ" webUsers: "> §2${0} ウェブユーザー" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_KO.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_KO.yml index 58ede012b..86eb6b9f1 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_KO.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_KO.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Help" servers: "> §2서버 목록" search: "> §2${0} Results for §f${1}§2:" - serverList: "id::name::uuid" + serverList: "id::name::uuid::version" inspect: "> §2플레이어: §f${0}" network: "> §2네트워크 페이지" webUsers: "> §2${0} 웹 사용자" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_NL.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_NL.yml index f82984a9c..c1ed47703 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_NL.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_NL.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Hulp" servers: "> §2Servers" search: "> §2${0} Resultaten voor §f${1}§2:" - serverList: "id::name::uuid" + serverList: "id::name::uuid::version" inspect: "> §2Speler: §f${0}" network: "> §2Netwerkpagina" webUsers: "> §2${0} Webgebruikers" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_PT_BR.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_PT_BR.yml index d777a35ef..aa8422b5c 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_PT_BR.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_PT_BR.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Help" servers: "> §2Servidores" search: "> §2${0} Resultados para §f${1}§2:" - serverList: "id::name::uuid" + serverList: "id::name::uuid::version" inspect: "> §2Jogador: §f${0}" network: "> §2Página da Network" webUsers: "> §2${0} Usuários da Web" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_RU.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_RU.yml index e95502ae8..90bffe0e6 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_RU.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_RU.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Помощь" servers: "> §2Серверы" search: "> §2${0} Результаты для §f${1}§2:" - serverList: "id::название::uuid" + serverList: "id::название::uuid::version" inspect: "> §2Игрок: §f${0}" network: "> §2Сетевая страница" webUsers: "> §2${0} Веб-пользователи" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_TR.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_TR.yml index 4377e2ee1..e4a5756e1 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_TR.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_TR.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} Help" servers: "> §2Sunucular" search: "> §2${0} §f${1} §2için sonuçlar:" - serverList: "id::isim::uuid" + serverList: "id::isim::uuid::version" inspect: "> §2Oyuncu: §f${0}" network: "> §2Ağ Sayfası" webUsers: "> §2${0} Web kullanıcıları" diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_ZH_TW.yml b/Plan/common/src/main/resources/assets/plan/locale/locale_ZH_TW.yml index be73a431b..6af09f6d0 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_ZH_TW.yml +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_ZH_TW.yml @@ -253,7 +253,7 @@ command: help: "> §2/${0} 幫助" servers: "> §2全部伺服器" search: "> §2${0} 對於 §f${1}§2 的結果:" - serverList: "id::名稱::uuid" + serverList: "id::名稱::uuid::version" inspect: "> §2玩家: §f${0}" network: "> §2群組網路頁面" webUsers: "> §2${0} 網頁使用者" diff --git a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java index 8a623c1a9..aeef07b11 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java @@ -108,8 +108,8 @@ class AccessControlTest { system.getDatabaseSystem().getDatabase().executeTransaction(new StoreServerInformationTransaction(new Server( TestConstants.SERVER_UUID, TestConstants.SERVER_NAME, - address - ))); + address, + TestConstants.VERSION))); Caller caller = system.getExtensionService().register(new ExtensionsDatabaseTest.PlayerExtension()) .orElseThrow(AssertionError::new); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/gathering/ShutdownSaveTest.java b/Plan/common/src/test/java/com/djrapitops/plan/gathering/ShutdownSaveTest.java index ebb835c59..2e3ed8d97 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/gathering/ShutdownSaveTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/gathering/ShutdownSaveTest.java @@ -103,7 +103,7 @@ class ShutdownSaveTest { UUID playerUUID = TestConstants.PLAYER_ONE_UUID; String worldName = TestConstants.WORLD_ONE_NAME; - database.executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID, "-", ""))); + database.executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID, "-", "", TestConstants.VERSION))); database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> 0L, TestConstants.PLAYER_ONE_NAME)); database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName)) .get(); @@ -152,7 +152,7 @@ class ShutdownSaveTest { long endTime = System.currentTimeMillis(); Collection activeSessions = SessionCache.getActiveSessions(); for (FinishedSession session : underTest.finishSessions(activeSessions, endTime)) { - assertEquals(endTime, session.getEnd(), () -> "One of the sessions had differing end time"); + assertEquals(endTime, session.getEnd(), "One of the sessions had differing end time"); } } diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/MySQLTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/MySQLTest.java index 817031cd3..8090961f8 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/MySQLTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/MySQLTest.java @@ -69,7 +69,7 @@ class MySQLTest implements DatabaseTest, QueriesTestAggregate { private static DBPreparer preparer; @BeforeAll - static void setupDatabase(@TempDir Path temp) throws Exception { + static void setupDatabase(@TempDir Path temp) { component = DaggerDatabaseTestComponent.builder() .bindTemporaryDirectory(temp) .build(); @@ -100,7 +100,7 @@ class MySQLTest implements DatabaseTest, QueriesTestAggregate { db().executeTransaction(new CreateTablesTransaction()); db().executeTransaction(new RemoveEverythingTransaction()); - db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), TestConstants.SERVER_NAME, ""))); + db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), TestConstants.SERVER_NAME, "", TestConstants.VERSION))); assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get()); } diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/SQLiteTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/SQLiteTest.java index af062ca21..ec762da4e 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/SQLiteTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/SQLiteTest.java @@ -38,6 +38,7 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import utilities.DBPreparer; import utilities.RandomData; +import utilities.TestConstants; import utilities.TestErrorLogger; import java.nio.file.Path; @@ -62,7 +63,7 @@ public class SQLiteTest implements DatabaseTest, QueriesTestAggregate { private static DBPreparer preparer; @BeforeAll - static void setupDatabase(@TempDir Path temp) throws Exception { + static void setupDatabase(@TempDir Path temp) { component = DaggerDatabaseTestComponent.builder() .bindTemporaryDirectory(temp) .build(); @@ -92,7 +93,7 @@ public class SQLiteTest implements DatabaseTest, QueriesTestAggregate { db().executeTransaction(new CreateTablesTransaction()); db().executeTransaction(new RemoveEverythingTransaction()); - db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), "ServerName", ""))); + db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), "ServerName", "", TestConstants.VERSION))); assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get()); } diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ServerQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ServerQueriesTest.java index e2abe7122..a132dd853 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ServerQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/ServerQueriesTest.java @@ -25,6 +25,7 @@ import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythi import com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction; import org.junit.jupiter.api.Test; import utilities.OptionalAssert; +import utilities.TestConstants; import java.util.Collection; import java.util.Map; @@ -56,7 +57,7 @@ public interface ServerQueriesTest extends DatabaseTestPreparer { assertFalse(bungeeInfo.isPresent()); ServerUUID bungeeUUID = ServerUUID.randomUUID(); - Server bungeeCord = new Server(bungeeUUID, "BungeeCord", "Random:1234"); + Server bungeeCord = new Server(bungeeUUID, "BungeeCord", "Random:1234", TestConstants.VERSION); bungeeCord.setProxy(true); db().executeTransaction(new StoreServerInformationTransaction(bungeeCord)); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java index bf0b1cbc2..3bf444f1d 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java @@ -152,7 +152,8 @@ public interface SessionQueriesTest extends DatabaseTestPreparer { List allSessions = db().query(SessionQueries.fetchAllSessions()); - assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class).get()); + assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class) + .orElseThrow(AssertionError::new)); } @Test @@ -180,7 +181,8 @@ public interface SessionQueriesTest extends DatabaseTestPreparer { List allSessions = db().query(SessionQueries.fetchAllSessions()); - assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class).get()); + assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class) + .orElseThrow(AssertionError::new)); } @Test @@ -240,7 +242,8 @@ public interface SessionQueriesTest extends DatabaseTestPreparer { prepareForSessionSave(); FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID); - List expected = session.getExtraData(PlayerKills.class).map(PlayerKills::asList).get(); + List expected = session.getExtraData(PlayerKills.class).map(PlayerKills::asList) + .orElseThrow(AssertionError::new); execute(DataStoreQueries.storeSession(session)); forcePersistenceCheck(); @@ -250,7 +253,8 @@ public interface SessionQueriesTest extends DatabaseTestPreparer { assertNotNull(savedSessions); assertFalse(savedSessions.isEmpty()); - List got = savedSessions.get(0).getExtraData(PlayerKills.class).map(PlayerKills::asList).get(); + List got = savedSessions.get(0).getExtraData(PlayerKills.class).map(PlayerKills::asList) + .orElseThrow(AssertionError::new); assertEquals(expected, got); } @@ -366,7 +370,7 @@ public interface SessionQueriesTest extends DatabaseTestPreparer { server1Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session))); ServerUUID serverTwoUuid = TestConstants.SERVER_TWO_UUID; - executeTransactions(new StoreServerInformationTransaction(new Server(serverTwoUuid, TestConstants.SERVER_TWO_NAME, ""))); + executeTransactions(new StoreServerInformationTransaction(new Server(serverTwoUuid, TestConstants.SERVER_TWO_NAME, "", TestConstants.VERSION))); db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[0])); db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[1])); List server2Sessions = RandomData.randomSessions(serverTwoUuid, worlds, playerUUID, player2UUID); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java index 7e76e81f0..0c7d8410b 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/UserInfoQueriesTest.java @@ -80,7 +80,7 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer { db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), () -> null)); db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME)); - db().executeTransaction(new StoreServerInformationTransaction(new Server(TestConstants.SERVER_TWO_UUID, TestConstants.SERVER_TWO_NAME, ""))); + db().executeTransaction(new StoreServerInformationTransaction(new Server(TestConstants.SERVER_TWO_UUID, TestConstants.SERVER_TWO_NAME, "", TestConstants.VERSION))); db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, TestConstants.SERVER_TWO_UUID, () -> "example.join.address")); Set userInfo = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID)); @@ -301,7 +301,7 @@ public interface UserInfoQueriesTest extends DatabaseTestPreparer { @Test default void joinAddressQueryHasDistinctPlayers() { - db().executeTransaction(new StoreServerInformationTransaction(new Server(TestConstants.SERVER_TWO_UUID, TestConstants.SERVER_TWO_NAME, ""))); + db().executeTransaction(new StoreServerInformationTransaction(new Server(TestConstants.SERVER_TWO_UUID, TestConstants.SERVER_TWO_NAME, "", TestConstants.VERSION))); db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME)); db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, TestConstants.SERVER_TWO_UUID, TestConstants.GET_PLAYER_HOSTNAME)); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/sql/building/CreateTableBuilderTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/sql/building/CreateTableBuilderTest.java index 9542966af..9a616a7f4 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/sql/building/CreateTableBuilderTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/sql/building/CreateTableBuilderTest.java @@ -39,7 +39,7 @@ class CreateTableBuilderTest { .column(ServerTable.NAME, Sql.varchar(100)) .column(ServerTable.WEB_ADDRESS, Sql.varchar(100)) .column(ServerTable.INSTALLED, Sql.BOOL).notNull().defaultValue(true) - .column(ServerTable.MAX_PLAYERS, Sql.INT).notNull().defaultValue("-1") + .column("max_players", Sql.INT).notNull().defaultValue("-1") .toString(); assertEquals(expected, result); } diff --git a/Plan/common/src/test/java/utilities/TestConstants.java b/Plan/common/src/test/java/utilities/TestConstants.java index eccb1160a..36bea9b81 100644 --- a/Plan/common/src/test/java/utilities/TestConstants.java +++ b/Plan/common/src/test/java/utilities/TestConstants.java @@ -29,6 +29,7 @@ import java.util.function.Supplier; public class TestConstants { + private TestConstants() { /* Static variable class */ } @@ -57,4 +58,6 @@ public class TestConstants { public static final int SERVER_MAX_PLAYERS = 20; public static final int BUNGEE_MAX_PLAYERS = 100; + public static final String VERSION = "1.0.0"; + } diff --git a/Plan/common/src/test/java/utilities/TestData.java b/Plan/common/src/test/java/utilities/TestData.java index 4df6ef5d8..8c7d21d9f 100644 --- a/Plan/common/src/test/java/utilities/TestData.java +++ b/Plan/common/src/test/java/utilities/TestData.java @@ -98,8 +98,8 @@ public class TestData { return new Transaction() { @Override protected void performOperations() { - executeOther(new StoreServerInformationTransaction(new Server(serverUUID, "Server 1", ""))); - executeOther(new StoreServerInformationTransaction(new Server(server2UUID, "Server 2", ""))); + executeOther(new StoreServerInformationTransaction(new Server(serverUUID, "Server 1", "", TestConstants.VERSION))); + executeOther(new StoreServerInformationTransaction(new Server(server2UUID, "Server 2", "", TestConstants.VERSION))); for (String worldName : serverWorldNames) { executeOther(new WorldNameStoreTransaction(serverUUID, worldName)); diff --git a/Plan/common/src/test/java/utilities/dagger/ProxyServerInfo.java b/Plan/common/src/test/java/utilities/dagger/ProxyServerInfo.java index 477b57651..c57c6f20f 100644 --- a/Plan/common/src/test/java/utilities/dagger/ProxyServerInfo.java +++ b/Plan/common/src/test/java/utilities/dagger/ProxyServerInfo.java @@ -31,6 +31,7 @@ import com.djrapitops.plan.settings.locale.lang.PluginLang; import net.playeranalytics.plugin.server.PluginLogger; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; /** @@ -41,6 +42,7 @@ import javax.inject.Singleton; @Singleton public class ProxyServerInfo extends ServerInfo { + private final String currentVersion; private final ServerLoader fromFile; private final ServerLoader fromDatabase; @@ -52,6 +54,7 @@ public class ProxyServerInfo extends ServerInfo { @Inject public ProxyServerInfo( + @Named("currentVersion") String currentVersion, ServerProperties serverProperties, ServerFileLoader fromFile, ServerDBLoader fromDatabase, @@ -61,6 +64,7 @@ public class ProxyServerInfo extends ServerInfo { PluginLogger logger ) { super(serverProperties); + this.currentVersion = currentVersion; this.fromFile = fromFile; this.fromDatabase = fromDatabase; this.processing = processing; @@ -114,6 +118,6 @@ public class ProxyServerInfo extends ServerInfo { private Server createServerObject() { 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); + return new Server(-1, serverUUID, "BungeeCord", accessAddress, true, currentVersion); } } diff --git a/Plan/velocity/src/main/java/com/djrapitops/plan/identification/VelocityServerInfo.java b/Plan/velocity/src/main/java/com/djrapitops/plan/identification/VelocityServerInfo.java index e3c676e58..1f470ebaa 100644 --- a/Plan/velocity/src/main/java/com/djrapitops/plan/identification/VelocityServerInfo.java +++ b/Plan/velocity/src/main/java/com/djrapitops/plan/identification/VelocityServerInfo.java @@ -28,6 +28,7 @@ import com.djrapitops.plan.settings.locale.lang.PluginLang; import net.playeranalytics.plugin.server.PluginLogger; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; /** @@ -38,6 +39,7 @@ import javax.inject.Singleton; @Singleton public class VelocityServerInfo extends ServerInfo { + private final String currentVersion; private final ServerLoader fromFile; private final ServerLoader fromDatabase; @@ -49,6 +51,7 @@ public class VelocityServerInfo extends ServerInfo { @Inject public VelocityServerInfo( + @Named("currentVersion") String currentVersion, ServerProperties serverProperties, ServerFileLoader fromFile, ServerDBLoader fromDatabase, @@ -58,6 +61,7 @@ public class VelocityServerInfo extends ServerInfo { PluginLogger logger ) { super(serverProperties); + this.currentVersion = currentVersion; this.fromFile = fromFile; this.fromDatabase = fromDatabase; this.processing = processing; @@ -89,7 +93,7 @@ public class VelocityServerInfo extends ServerInfo { } /** - * @throws EnableException + * @throws EnableException If IP setting is unset */ private void checkIfDefaultIP() { String ip = serverProperties.getIp(); @@ -112,12 +116,12 @@ public class VelocityServerInfo extends ServerInfo { } /** - * @throws EnableException + * @throws EnableException If IP setting is unset */ private Server createServerObject() { 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, "Velocity", accessAddress, true); + return new Server(-1, serverUUID, "Velocity", accessAddress, true, currentVersion); } }