mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-06 02:42:05 +01:00
parent
d57f159486
commit
15cc6092d1
@ -50,10 +50,8 @@ public class PlanCommand extends TreeCommand<Plan> {
|
||||
RegisterCommand registerCommand = new RegisterCommand(plugin);
|
||||
commands.add(registerCommand);
|
||||
commands.add(new WebUserCommand(plugin, registerCommand));
|
||||
if (plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||
commands.add(new NetworkCommand());
|
||||
commands.add(new ListServersCommand(plugin));
|
||||
}
|
||||
commands.add(new NetworkCommand(plugin));
|
||||
commands.add(new ListServersCommand(plugin));
|
||||
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
commands.add(new DevCommand(plugin));
|
||||
|
@ -19,17 +19,22 @@ import main.java.com.djrapitops.plan.locale.Msg;
|
||||
*/
|
||||
public class NetworkCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*/
|
||||
public NetworkCommand() {
|
||||
public NetworkCommand(Plan plugin) {
|
||||
super("network, n, netw", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), Locale.get(Msg.CMD_USG_LIST).toString(), "");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
|
||||
if (plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||
sender.sendMessage("§cNot using Bungee WebServer!");
|
||||
return true;
|
||||
}
|
||||
sendNetworkMsg(sender);
|
||||
return true;
|
||||
}
|
||||
|
@ -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.processing.Processor;
|
||||
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.InspectPageResponse;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.InternalErrorResponse;
|
||||
@ -246,23 +247,35 @@ public class BukkitInformationManager extends InformationManager {
|
||||
|
||||
@Override
|
||||
public boolean attemptConnection() {
|
||||
Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")");
|
||||
PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class);
|
||||
WebServer webServer = plugin.getWebServer();
|
||||
boolean webServerIsEnabled = webServer.isEnabled();
|
||||
boolean previousState = usingAnotherWebServer;
|
||||
|
||||
try {
|
||||
api.sendRequest(webServerAddress);
|
||||
getWebAPI().getAPI(PostOriginalBukkitSettingsWebAPI.class).sendRequest(webServerAddress);
|
||||
Log.info("Bungee Connection OK");
|
||||
plugin.getServerInfoManager().resetConnectionFails();
|
||||
usingAnotherWebServer = true;
|
||||
return true;
|
||||
} catch (WebAPIConnectionFailException e) {
|
||||
plugin.getServerInfoManager().markConnectionFail();
|
||||
} catch (WebAPIException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")");
|
||||
PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class);
|
||||
try {
|
||||
api.sendRequest(webServerAddress);
|
||||
getWebAPI().getAPI(PostOriginalBukkitSettingsWebAPI.class).sendRequest(webServerAddress);
|
||||
Log.info("Bungee Connection OK");
|
||||
plugin.getServerInfoManager().resetConnectionFails();
|
||||
usingAnotherWebServer = true;
|
||||
return true;
|
||||
} catch (WebAPIConnectionFailException e) {
|
||||
plugin.getServerInfoManager().markConnectionFail();
|
||||
} catch (WebAPIException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
Log.info("Bungee Connection Failed.");
|
||||
usingAnotherWebServer = false;
|
||||
return false;
|
||||
} finally {
|
||||
boolean changedState = previousState != usingAnotherWebServer;
|
||||
if (webServerIsEnabled && changedState) {
|
||||
webServer.stop();
|
||||
webServer.initServer();
|
||||
}
|
||||
}
|
||||
Log.info("Bungee Connection Failed.");
|
||||
usingAnotherWebServer = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user