diff --git a/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java b/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java index f76eba214..65f0fabcc 100644 --- a/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java +++ b/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java @@ -17,7 +17,10 @@ package com.djrapitops.plan; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.db.Database; +import com.djrapitops.plan.db.access.queries.objects.ServerQueries; import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.settings.ConfigSettingKeyTest; import com.djrapitops.plan.system.settings.config.PlanConfig; import com.djrapitops.plan.system.settings.paths.WebserverSettings; @@ -31,9 +34,11 @@ import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; import rules.BukkitComponentMocker; import rules.ComponentMocker; +import utilities.OptionalAssert; import utilities.RandomData; import java.util.Collection; +import java.util.Optional; import static org.junit.Assert.assertTrue; @@ -71,6 +76,21 @@ public class BukkitSystemTest { } } + @Test + public void correctWebAddressInDatabaseAfterEnable() throws EnableException { + try { + system.enable(); + Database database = system.getDatabaseSystem().getDatabase(); + String expectedAddress = system.getWebServerSystem().getWebServer().getAccessAddress(); + Optional found = database.query(ServerQueries.fetchServerMatchingIdentifier(system.getServerInfo().getServerUUID())) + .map(Server::getWebAddress); + + OptionalAssert.equals(expectedAddress, found); + } finally { + system.disable(); + } + } + @Test public void bukkitSystemHasDefaultConfigValuesAfterEnable() throws EnableException, IllegalAccessException { try { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 3c459df91..a1610fc04 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -126,9 +126,9 @@ public class PlanSystem implements SubSystem { localeSystem, versionCheckSystem, databaseSystem, + webServerSystem, processing, serverInfo, - webServerSystem, importSystem, exportSystem, infoSystem, diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index 164089a0b..caa057e60 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -25,6 +25,7 @@ import com.djrapitops.plan.system.locale.Locale; import com.djrapitops.plan.system.locale.lang.PluginLang; import com.djrapitops.plan.system.settings.config.PlanConfig; import com.djrapitops.plan.system.settings.paths.WebserverSettings; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.logging.L; import com.djrapitops.plugin.logging.console.PluginLogger; import com.djrapitops.plugin.logging.error.ErrorHandler; @@ -101,7 +102,7 @@ public class WebServer implements SubSystem { initServer(); if (!isEnabled()) { - if (serverInfo.getServer().isProxy()) { + if (Check.isBungeeAvailable() || Check.isVelocityAvailable()) { throw new EnableException(locale.getString(PluginLang.ENABLE_FAIL_NO_WEB_SERVER_PROXY)); } if (config.isTrue(WebserverSettings.DISABLED)) { @@ -118,8 +119,8 @@ public class WebServer implements SubSystem { * Starts up the WebServer in a new Thread Pool. */ private void initServer() { - if (serverInfo.getServer().isNotProxy() && config.isTrue(WebserverSettings.DISABLED)) { - // Bukkit WebServer has been disabled. + if ((Check.isBukkitAvailable() || Check.isSpongeAvailable()) && config.isTrue(WebserverSettings.DISABLED)) { + // Bukkit/Sponge WebServer has been disabled. return; }