mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Fixed wrong webserver address in db after enable
This commit is contained in:
parent
24342947e3
commit
23485310d1
@ -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<String> 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 {
|
||||
|
@ -126,9 +126,9 @@ public class PlanSystem implements SubSystem {
|
||||
localeSystem,
|
||||
versionCheckSystem,
|
||||
databaseSystem,
|
||||
webServerSystem,
|
||||
processing,
|
||||
serverInfo,
|
||||
webServerSystem,
|
||||
importSystem,
|
||||
exportSystem,
|
||||
infoSystem,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user