Fixed #292 & Bypassed #295

This commit is contained in:
Rsl1122 2017-09-28 19:29:49 +03:00
parent d57f159486
commit 15cc6092d1
3 changed files with 38 additions and 22 deletions

View File

@ -50,10 +50,8 @@ public class PlanCommand extends TreeCommand<Plan> {
RegisterCommand registerCommand = new RegisterCommand(plugin); RegisterCommand registerCommand = new RegisterCommand(plugin);
commands.add(registerCommand); commands.add(registerCommand);
commands.add(new WebUserCommand(plugin, registerCommand)); commands.add(new WebUserCommand(plugin, registerCommand));
if (plugin.getInfoManager().isUsingAnotherWebServer()) { commands.add(new NetworkCommand(plugin));
commands.add(new NetworkCommand());
commands.add(new ListServersCommand(plugin)); commands.add(new ListServersCommand(plugin));
}
if (Settings.DEV_MODE.isTrue()) { if (Settings.DEV_MODE.isTrue()) {
commands.add(new DevCommand(plugin)); commands.add(new DevCommand(plugin));

View File

@ -19,17 +19,22 @@ import main.java.com.djrapitops.plan.locale.Msg;
*/ */
public class NetworkCommand extends SubCommand { public class NetworkCommand extends SubCommand {
private final Plan plugin;
/** /**
* Class Constructor. * Class Constructor.
*/ */
public NetworkCommand() { public NetworkCommand(Plan plugin) {
super("network, n, netw", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), Locale.get(Msg.CMD_USG_LIST).toString(), ""); super("network, n, netw", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), Locale.get(Msg.CMD_USG_LIST).toString(), "");
this.plugin = plugin;
} }
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (plugin.getInfoManager().isUsingAnotherWebServer()) {
sender.sendMessage("§cNot using Bungee WebServer!");
return true;
}
sendNetworkMsg(sender); sendNetworkMsg(sender);
return true; return true;
} }

View File

@ -19,6 +19,7 @@ import main.java.com.djrapitops.plan.systems.info.parsing.AnalysisPageParser;
import main.java.com.djrapitops.plan.systems.info.parsing.InspectPageParser; import main.java.com.djrapitops.plan.systems.info.parsing.InspectPageParser;
import main.java.com.djrapitops.plan.systems.processing.Processor; import main.java.com.djrapitops.plan.systems.processing.Processor;
import main.java.com.djrapitops.plan.systems.webserver.PageCache; import main.java.com.djrapitops.plan.systems.webserver.PageCache;
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
import main.java.com.djrapitops.plan.systems.webserver.response.AnalysisPageResponse; import main.java.com.djrapitops.plan.systems.webserver.response.AnalysisPageResponse;
import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse; import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse;
import main.java.com.djrapitops.plan.systems.webserver.response.InternalErrorResponse; import main.java.com.djrapitops.plan.systems.webserver.response.InternalErrorResponse;
@ -246,6 +247,11 @@ public class BukkitInformationManager extends InformationManager {
@Override @Override
public boolean attemptConnection() { public boolean attemptConnection() {
WebServer webServer = plugin.getWebServer();
boolean webServerIsEnabled = webServer.isEnabled();
boolean previousState = usingAnotherWebServer;
try {
Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")"); Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")");
PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class); PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class);
try { try {
@ -263,6 +269,13 @@ public class BukkitInformationManager extends InformationManager {
Log.info("Bungee Connection Failed."); Log.info("Bungee Connection Failed.");
usingAnotherWebServer = false; usingAnotherWebServer = false;
return false; return false;
} finally {
boolean changedState = previousState != usingAnotherWebServer;
if (webServerIsEnabled && changedState) {
webServer.stop();
webServer.initServer();
}
}
} }
@Override @Override