[Fix] Velocity checks where Bungee presence is checked.

This commit is contained in:
Rsl1122 2018-10-14 11:51:28 +03:00
parent 6b58e902e6
commit 9acd4879ba
10 changed files with 18 additions and 15 deletions

View File

@ -65,6 +65,7 @@
<exclude>org.mockito:*</exclude> <exclude>org.mockito:*</exclude>
<exclude>org.easymock:*</exclude> <exclude>org.easymock:*</exclude>
<exclude>junit:*</exclude> <exclude>junit:*</exclude>
<exclued>org.slf4j:*</exclued>
</excludes> </excludes>
</artifactSet> </artifactSet>
<relocations> <relocations>
@ -87,10 +88,6 @@
<pattern>com.zaxxer</pattern> <pattern>com.zaxxer</pattern>
<shadedPattern>plan.com.zaxxer</shadedPattern> <shadedPattern>plan.com.zaxxer</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>plan.org.slf4j</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>com.djrapitops.plan.utilities.metrics</shadedPattern> <shadedPattern>com.djrapitops.plan.utilities.metrics</shadedPattern>

View File

@ -65,7 +65,7 @@ public class ManageConDebugCommand extends CommandNode {
this.webServer = webServer; this.webServer = webServer;
this.dbSystem = dbSystem; this.dbSystem = dbSystem;
setShortHelp(locale.getString(Check.isBungeeAvailable() ? CmdHelpLang.CON : CmdHelpLang.MANAGE_CON)); setShortHelp(locale.getString(Check.isBungeeAvailable() || Check.isVelocityAvailable() ? CmdHelpLang.CON : CmdHelpLang.MANAGE_CON));
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_CON)); setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_CON));
} }

View File

@ -121,7 +121,7 @@ public class NetworkContainer extends DataContainer {
putSupplier(NetworkKeys.TIME_ZONE, config::getTimeZoneOffsetHours); putSupplier(NetworkKeys.TIME_ZONE, config::getTimeZoneOffsetHours);
putCachingSupplier(NetworkKeys.NETWORK_NAME, () -> putCachingSupplier(NetworkKeys.NETWORK_NAME, () ->
Check.isBungeeAvailable() ? Check.isBungeeAvailable() || Check.isVelocityAvailable() ?
config.getString(Settings.BUNGEE_NETWORK_NAME) : config.getString(Settings.BUNGEE_NETWORK_NAME) :
bungeeContainer.getValue(ServerKeys.NAME).orElse("Plan") bungeeContainer.getValue(ServerKeys.NAME).orElse("Plan")
); );

View File

@ -150,6 +150,9 @@ public abstract class InfoSystem implements SubSystem {
if (Check.isBungeeAvailable()) { if (Check.isBungeeAvailable()) {
throw new BadRequestException("Method not available on Bungee."); throw new BadRequestException("Method not available on Bungee.");
} }
if (Check.isVelocityAvailable()) {
throw new BadRequestException("Method not available on Velocity.");
}
Server bungee = new Server(-1, null, "Bungee", addressToRequestServer, -1); Server bungee = new Server(-1, null, "Bungee", addressToRequestServer, -1);
String addressOfThisServer = webServer.get().getAccessAddress(); String addressOfThisServer = webServer.get().getAccessAddress();

View File

@ -48,7 +48,7 @@ public class CheckConnectionRequest extends InfoRequestWithVariables {
public Response handleRequest(Map<String, String> variables) throws WebException { public Response handleRequest(Map<String, String> variables) throws WebException {
// Available variables: sender, address // Available variables: sender, address
if (Check.isBungeeAvailable()) { if (Check.isBungeeAvailable() || Check.isVelocityAvailable()) {
attemptConnection(variables); attemptConnection(variables);
} }

View File

@ -65,6 +65,9 @@ public class SaveDBSettingsRequest extends InfoRequestWithVariables implements S
if (Check.isBungeeAvailable()) { if (Check.isBungeeAvailable()) {
return new BadRequestResponse("Not supposed to be called on a Bungee server"); return new BadRequestResponse("Not supposed to be called on a Bungee server");
} }
if (Check.isVelocityAvailable()) {
return new BadRequestResponse("Not supposed to be called on a Velocity server");
}
if (config.isFalse(Settings.BUNGEE_COPY_CONFIG) || config.isTrue(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE)) { if (config.isFalse(Settings.BUNGEE_COPY_CONFIG) || config.isTrue(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE)) {
return new BadRequestResponse("Bungee config settings overridden on this server."); return new BadRequestResponse("Bungee config settings overridden on this server.");
} }

View File

@ -67,7 +67,7 @@ public class NetworkSettings {
} }
public void loadSettingsFromDB() { public void loadSettingsFromDB() {
if (Check.isBungeeAvailable()) { if (Check.isBungeeAvailable() || Check.isVelocityAvailable()) {
return; return;
} }
@ -81,7 +81,7 @@ public class NetworkSettings {
} }
public void placeSettingsToDB() { public void placeSettingsToDB() {
if (!Check.isBungeeAvailable()) { if (!Check.isBungeeAvailable() && !Check.isVelocityAvailable()) {
return; return;
} }

View File

@ -82,7 +82,7 @@ public class WebServer implements SubSystem {
initServer(); initServer();
if (!isEnabled()) { if (!isEnabled()) {
if (Check.isBungeeAvailable()) { if (Check.isBungeeAvailable() || Check.isVelocityAvailable()) {
throw new EnableException(locale.getString(PluginLang.ENABLE_FAIL_NO_WEB_SERVER_BUNGEE)); throw new EnableException(locale.getString(PluginLang.ENABLE_FAIL_NO_WEB_SERVER_BUNGEE));
} }
if (config.isTrue(Settings.WEBSERVER_DISABLED)) { if (config.isTrue(Settings.WEBSERVER_DISABLED)) {
@ -99,7 +99,7 @@ public class WebServer implements SubSystem {
* Starts up the WebServer in a new Thread Pool. * Starts up the WebServer in a new Thread Pool.
*/ */
private void initServer() { private void initServer() {
if (!Check.isBungeeAvailable() && config.isTrue(Settings.WEBSERVER_DISABLED)) { if (!(Check.isBungeeAvailable() || Check.isVelocityAvailable()) && config.isTrue(Settings.WEBSERVER_DISABLED)) {
// Bukkit WebServer has been disabled. // Bukkit WebServer has been disabled.
return; return;
} }

View File

@ -69,7 +69,7 @@ public class ServerPageHandler implements PageHandler {
if (response != null) { if (response != null) {
return response; return response;
} else { } else {
if (Check.isBungeeAvailable() && serverInfo.getServerUUID().equals(serverUUID)) { if ((Check.isBungeeAvailable() || Check.isVelocityAvailable()) && serverInfo.getServerUUID().equals(serverUUID)) {
return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), responseFactory::networkPageResponse); return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), responseFactory::networkPageResponse);
} }
return refreshNow(serverUUID); return refreshNow(serverUUID);

View File

@ -34,7 +34,7 @@ public abstract class SpecificExport implements Runnable {
private final ServerInfo serverInfo; private final ServerInfo serverInfo;
protected final File outputFolder; protected final File outputFolder;
private final boolean usingBungee; private final boolean usingProxy;
protected SpecificExport( protected SpecificExport(
PlanFiles files, PlanFiles files,
@ -45,7 +45,7 @@ public abstract class SpecificExport implements Runnable {
this.config = config; this.config = config;
this.serverInfo = serverInfo; this.serverInfo = serverInfo;
outputFolder = getFolder(); outputFolder = getFolder();
usingBungee = Check.isBungeeAvailable(); usingProxy = Check.isBungeeAvailable() || Check.isVelocityAvailable();
} }
protected File getFolder() { protected File getFolder() {
@ -112,7 +112,7 @@ public abstract class SpecificExport implements Runnable {
.replace("src=\"js/", "src=\"../js/"); .replace("src=\"js/", "src=\"../js/");
File htmlLocation; File htmlLocation;
if (usingBungee) { if (usingProxy) {
if (serverUUID.equals(serverInfo.getServerUUID())) { if (serverUUID.equals(serverInfo.getServerUUID())) {
htmlLocation = new File(outputFolder, "network"); htmlLocation = new File(outputFolder, "network");
} else { } else {