mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-13 22:25:53 +01:00
WebServer now initialized inside WebServerSystem
This commit is contained in:
parent
be21756611
commit
c1229385c4
@ -60,6 +60,7 @@ import main.java.com.djrapitops.plan.systems.store.config.ConfigSystem;
|
|||||||
import main.java.com.djrapitops.plan.systems.store.database.DBSystem;
|
import main.java.com.djrapitops.plan.systems.store.database.DBSystem;
|
||||||
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
|
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
||||||
|
import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.pagecache.PageCache;
|
import main.java.com.djrapitops.plan.systems.webserver.pagecache.PageCache;
|
||||||
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
|
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||||
import main.java.com.djrapitops.plan.utilities.metrics.BStats;
|
import main.java.com.djrapitops.plan.utilities.metrics.BStats;
|
||||||
@ -91,8 +92,6 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
private ProcessingQueue processingQueue;
|
private ProcessingQueue processingQueue;
|
||||||
private HookHandler hookHandler; // Manages 3rd party data sources
|
private HookHandler hookHandler; // Manages 3rd party data sources
|
||||||
|
|
||||||
private WebServer webServer;
|
|
||||||
|
|
||||||
private BukkitInformationManager infoManager;
|
private BukkitInformationManager infoManager;
|
||||||
private BukkitServerInfoManager serverInfoManager;
|
private BukkitServerInfoManager serverInfoManager;
|
||||||
|
|
||||||
@ -185,15 +184,13 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
DBSystem.getInstance().init();
|
DBSystem.getInstance().init();
|
||||||
|
|
||||||
Benchmark.start("WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
webServer = new WebServer(this);
|
|
||||||
|
|
||||||
processingQueue = new ProcessingQueue();
|
processingQueue = new ProcessingQueue();
|
||||||
|
|
||||||
serverInfoManager = new BukkitServerInfoManager(this);
|
serverInfoManager = new BukkitServerInfoManager(this);
|
||||||
infoManager = new BukkitInformationManager(this);
|
infoManager = new BukkitInformationManager(this);
|
||||||
|
|
||||||
webServer.initServer();
|
WebServerSystem.getInstance().init();
|
||||||
if (!webServer.isEnabled()) {
|
if (!WebServerSystem.isWebServerEnabled()) {
|
||||||
if (Settings.WEBSERVER_DISABLED.isTrue()) {
|
if (Settings.WEBSERVER_DISABLED.isTrue()) {
|
||||||
Log.warn("WebServer was not initialized. (WebServer.DisableWebServer: true)");
|
Log.warn("WebServer was not initialized. (WebServer.DisableWebServer: true)");
|
||||||
} else {
|
} else {
|
||||||
@ -316,11 +313,6 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
//Clears the page cache
|
//Clears the page cache
|
||||||
PageCache.clearCache();
|
PageCache.clearCache();
|
||||||
|
|
||||||
// Stop the UI Server
|
|
||||||
if (webServer != null) {
|
|
||||||
webServer.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Processes unprocessed processors
|
// Processes unprocessed processors
|
||||||
if (processingQueue != null) {
|
if (processingQueue != null) {
|
||||||
List<Processor> processors = processingQueue.stopAndReturnLeftovers();
|
List<Processor> processors = processingQueue.stopAndReturnLeftovers();
|
||||||
@ -394,7 +386,7 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
* @return the WebServer
|
* @return the WebServer
|
||||||
*/
|
*/
|
||||||
public WebServer getWebServer() {
|
public WebServer getWebServer() {
|
||||||
return webServer;
|
return WebServerSystem.getInstance().getWebServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +35,7 @@ import main.java.com.djrapitops.plan.systems.store.config.ConfigSystem;
|
|||||||
import main.java.com.djrapitops.plan.systems.store.database.DBSystem;
|
import main.java.com.djrapitops.plan.systems.store.database.DBSystem;
|
||||||
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
|
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
||||||
|
import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
|
||||||
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
|
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
@ -53,7 +54,6 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
|
|
||||||
private Systems systems;
|
private Systems systems;
|
||||||
|
|
||||||
private WebServer webServer;
|
|
||||||
private BungeeServerInfoManager serverInfoManager;
|
private BungeeServerInfoManager serverInfoManager;
|
||||||
private BungeeInformationManager infoManager;
|
private BungeeInformationManager infoManager;
|
||||||
private ServerVariableHolder variableHolder;
|
private ServerVariableHolder variableHolder;
|
||||||
@ -103,20 +103,13 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
webServer = new WebServer(this);
|
|
||||||
|
|
||||||
serverInfoManager = new BungeeServerInfoManager(this);
|
serverInfoManager = new BungeeServerInfoManager(this);
|
||||||
infoManager = new BungeeInformationManager(this);
|
infoManager = new BungeeInformationManager(this);
|
||||||
webServer.initServer();
|
|
||||||
|
WebServerSystem.getInstance().init();
|
||||||
serverInfoManager.loadServerInfo();
|
serverInfoManager.loadServerInfo();
|
||||||
|
|
||||||
|
|
||||||
if (!webServer.isEnabled()) {
|
|
||||||
Log.error("WebServer was not successfully initialized.");
|
|
||||||
onDisable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RunnableFactory.createNew("Enable Bukkit Connection Task", new AbsRunnable() {
|
RunnableFactory.createNew("Enable Bukkit Connection Task", new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -162,9 +155,6 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
/*ignored*/
|
/*ignored*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (webServer != null) {
|
|
||||||
webServer.stop();
|
|
||||||
}
|
|
||||||
systems.close();
|
systems.close();
|
||||||
Log.info(Locale.get(Msg.DISABLED).toString());
|
Log.info(Locale.get(Msg.DISABLED).toString());
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
@ -197,7 +187,7 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WebServer getWebServer() {
|
public WebServer getWebServer() {
|
||||||
return webServer;
|
return WebServerSystem.getInstance().getWebServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package main.java.com.djrapitops.plan.systems;
|
package main.java.com.djrapitops.plan.systems;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.PlanBungee;
|
import main.java.com.djrapitops.plan.PlanBungee;
|
||||||
import main.java.com.djrapitops.plan.systems.store.FileSystem;
|
import main.java.com.djrapitops.plan.systems.store.FileSystem;
|
||||||
@ -13,6 +14,7 @@ import main.java.com.djrapitops.plan.systems.store.config.PlanConfigSystem;
|
|||||||
import main.java.com.djrapitops.plan.systems.store.database.DBSystem;
|
import main.java.com.djrapitops.plan.systems.store.database.DBSystem;
|
||||||
import main.java.com.djrapitops.plan.systems.store.database.PlanBungeeDBSystem;
|
import main.java.com.djrapitops.plan.systems.store.database.PlanBungeeDBSystem;
|
||||||
import main.java.com.djrapitops.plan.systems.store.database.PlanDBSystem;
|
import main.java.com.djrapitops.plan.systems.store.database.PlanDBSystem;
|
||||||
|
import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
@ -24,8 +26,10 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||||||
public class Systems {
|
public class Systems {
|
||||||
|
|
||||||
private FileSystem fileSystem;
|
private FileSystem fileSystem;
|
||||||
private DBSystem databaseSystem;
|
|
||||||
private ConfigSystem configSystem;
|
private ConfigSystem configSystem;
|
||||||
|
private DBSystem databaseSystem;
|
||||||
|
|
||||||
|
private WebServerSystem webServerSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for Bukkit version.
|
* Constructor for Bukkit version.
|
||||||
@ -37,6 +41,7 @@ public class Systems {
|
|||||||
configSystem = new PlanConfigSystem();
|
configSystem = new PlanConfigSystem();
|
||||||
databaseSystem = new PlanDBSystem();
|
databaseSystem = new PlanDBSystem();
|
||||||
|
|
||||||
|
webServerSystem = new WebServerSystem(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,13 +53,16 @@ public class Systems {
|
|||||||
fileSystem = new FileSystem(plugin);
|
fileSystem = new FileSystem(plugin);
|
||||||
configSystem = new PlanBungeeConfigSystem();
|
configSystem = new PlanBungeeConfigSystem();
|
||||||
databaseSystem = new PlanBungeeDBSystem();
|
databaseSystem = new PlanBungeeDBSystem();
|
||||||
|
|
||||||
|
webServerSystem = new WebServerSystem(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SubSystem[] getSubSystems() {
|
private SubSystem[] getSubSystems() {
|
||||||
return new SubSystem[]{
|
return new SubSystem[]{
|
||||||
fileSystem,
|
fileSystem,
|
||||||
configSystem,
|
configSystem,
|
||||||
databaseSystem
|
databaseSystem,
|
||||||
|
webServerSystem
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +70,11 @@ public class Systems {
|
|||||||
SubSystem[] subSystems = getSubSystems();
|
SubSystem[] subSystems = getSubSystems();
|
||||||
ArrayUtils.reverse(subSystems);
|
ArrayUtils.reverse(subSystems);
|
||||||
for (SubSystem subSystem : subSystems) {
|
for (SubSystem subSystem : subSystems) {
|
||||||
subSystem.close();
|
try {
|
||||||
|
subSystem.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.toLog(Systems.class, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,4 +93,8 @@ public class Systems {
|
|||||||
public ConfigSystem getConfigSystem() {
|
public ConfigSystem getConfigSystem() {
|
||||||
return configSystem;
|
return configSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WebServerSystem getWebServerSystem() {
|
||||||
|
return webServerSystem;
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package main.java.com.djrapitops.plan.systems.webserver;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.api.Check;
|
||||||
|
import main.java.com.djrapitops.plan.api.IPlan;
|
||||||
|
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
||||||
|
import main.java.com.djrapitops.plan.systems.SubSystem;
|
||||||
|
import main.java.com.djrapitops.plan.systems.Systems;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //TODO Class Javadoc Comment
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class WebServerSystem implements SubSystem {
|
||||||
|
|
||||||
|
private WebServer webServer;
|
||||||
|
|
||||||
|
public WebServerSystem(IPlan plugin) {
|
||||||
|
webServer = new WebServer(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WebServerSystem getInstance() {
|
||||||
|
return Systems.getInstance().getWebServerSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws PlanEnableException {
|
||||||
|
webServer.initServer();
|
||||||
|
if (Check.isBungeeAvailable() && !webServer.isEnabled()) {
|
||||||
|
throw new PlanEnableException("WebServer did not initialize!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
webServer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWebServerEnabled() {
|
||||||
|
return getInstance().webServer.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebServer getWebServer() {
|
||||||
|
return webServer;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user