mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +01:00
Fixed some enable issues on Bukkit version. More:
Tested functioning: - Enable - Reload - Analysis & Inspect command - Debug page - WebServer functions partially Tested not functioning: - /player/playername (Null response) - Some PageHandlers return null Response (Not supposed to) - /server/ (Endless "Refreshing" page) - /server/name - Style responses not found in sub folders (eg /server/page) - /players (jquery.dataTables.js Unexpected token) - Internal InfoRequests do not work as intended - Internal errors in RequestHandler - /plan manage backup, restore, setup Not Tested, probably not functioning: - Bungee - /plan manage setup Not implemented: - Player online information to transfer table - Config setting transfer - Bukkit - Bungee Set-up
This commit is contained in:
parent
2b412f6f7b
commit
a60f77f06f
@ -81,7 +81,7 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
registerCommand("plan", new PlanCommand(this));
|
registerCommand("plan", new PlanCommand(this));
|
||||||
|
|
||||||
Benchmark.start("Hook to 3rd party plugins");
|
Benchmark.start("Hook to 3rd party plugins");
|
||||||
hookHandler = new HookHandler(this);
|
hookHandler = new HookHandler();
|
||||||
Benchmark.stop("Enable", "Hook to 3rd party plugins");
|
Benchmark.stop("Enable", "Hook to 3rd party plugins");
|
||||||
|
|
||||||
ImporterManager.registerImporter(new OfflinePlayerImporter());
|
ImporterManager.registerImporter(new OfflinePlayerImporter());
|
||||||
|
@ -24,9 +24,9 @@ public interface PlanPlugin extends IPlugin {
|
|||||||
boolean bungeeAvailable = Check.isBungeeAvailable();
|
boolean bungeeAvailable = Check.isBungeeAvailable();
|
||||||
if (bukkitAvailable && bungeeAvailable) {
|
if (bukkitAvailable && bungeeAvailable) {
|
||||||
// TODO Test Plugin
|
// TODO Test Plugin
|
||||||
} else if (bungeeAvailable) {
|
|
||||||
return Plan.getInstance();
|
|
||||||
} else if (bukkitAvailable) {
|
} else if (bukkitAvailable) {
|
||||||
|
return Plan.getInstance();
|
||||||
|
} else if (bungeeAvailable) {
|
||||||
return PlanBungee.getInstance();
|
return PlanBungee.getInstance();
|
||||||
}
|
}
|
||||||
throw new IllegalAccessError("Plugin instance not available");
|
throw new IllegalAccessError("Plugin instance not available");
|
||||||
|
69
Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java
Normal file
69
Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.djrapitops.plan.api;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
|
import com.djrapitops.plan.data.plugin.PluginData;
|
||||||
|
import com.djrapitops.plan.system.BukkitSystem;
|
||||||
|
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||||
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //TODO Class Javadoc Comment
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class BukkitAPI implements PlanAPI {
|
||||||
|
|
||||||
|
private final BukkitSystem bukkitSystem;
|
||||||
|
|
||||||
|
public BukkitAPI(BukkitSystem bukkitSystem) {
|
||||||
|
this.bukkitSystem = bukkitSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPluginDataSource(PluginData pluginData) {
|
||||||
|
bukkitSystem.getHookHandler().addPluginDataSource(pluginData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlayerInspectPageLink(UUID uuid) {
|
||||||
|
return getPlayerInspectPageLink(getPlayerName(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlayerInspectPageLink(String playerName) {
|
||||||
|
return "../player/" + playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlayerName(UUID uuid) {
|
||||||
|
return bukkitSystem.getCacheSystem().getDataCache().getName(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID playerNameToUUID(String playerName) {
|
||||||
|
return bukkitSystem.getCacheSystem().getDataCache().getUUIDof(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<UUID, String> getKnownPlayerNames() {
|
||||||
|
try {
|
||||||
|
return bukkitSystem.getDatabaseSystem().getActiveDatabase().fetch().getPlayerNames();
|
||||||
|
} catch (DBException e) {
|
||||||
|
Log.toLog(this.getClass(), e);
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FetchOperations fetchFromPlanDB() {
|
||||||
|
return bukkitSystem.getDatabaseSystem().getActiveDatabase().fetch();
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
package com.djrapitops.plan.api;
|
package com.djrapitops.plan.api;
|
||||||
|
|
||||||
import com.djrapitops.plan.data.plugin.PluginData;
|
import com.djrapitops.plan.data.plugin.PluginData;
|
||||||
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -18,7 +19,7 @@ import java.util.UUID;
|
|||||||
public interface PlanAPI {
|
public interface PlanAPI {
|
||||||
|
|
||||||
static PlanAPI getInstance() {
|
static PlanAPI getInstance() {
|
||||||
throw new IllegalAccessError("Not yet implemented"); // TODO
|
return PlanSystem.getInstance().getPlanAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPluginDataSource(PluginData pluginData);
|
void addPluginDataSource(PluginData pluginData);
|
||||||
|
@ -2,8 +2,12 @@ package com.djrapitops.plan.data.plugin;
|
|||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.data.element.InspectContainer;
|
import com.djrapitops.plan.data.element.InspectContainer;
|
||||||
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
import com.djrapitops.pluginbridge.plan.Bridge;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -14,29 +18,35 @@ import java.util.*;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 2.6.0
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
public class HookHandler {
|
public class HookHandler implements SubSystem {
|
||||||
|
|
||||||
private final List<PluginData> additionalDataSources;
|
private final List<PluginData> additionalDataSources;
|
||||||
private final PluginsConfigSection configHandler;
|
private PluginsConfigSection configHandler;
|
||||||
|
|
||||||
/**
|
public HookHandler() {
|
||||||
* Class constructor, hooks to plugins.
|
|
||||||
*
|
|
||||||
* @param plugin Current instance of plan.
|
|
||||||
*/
|
|
||||||
public HookHandler(Plan plugin) {
|
|
||||||
additionalDataSources = new ArrayList<>();
|
additionalDataSources = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HookHandler getInstance() {
|
||||||
|
HookHandler hookHandler = PlanSystem.getInstance().getHookHandler();
|
||||||
|
NullCheck.check(hookHandler, new IllegalStateException("Plugin Hooks were not initialized."));
|
||||||
|
return hookHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
configHandler = new PluginsConfigSection();
|
configHandler = new PluginsConfigSection();
|
||||||
try {
|
try {
|
||||||
// Bridge.hook(this);
|
Bridge.hook(this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
Log.error("Plan Plugin Bridge not included in the plugin jar.");
|
Log.error("Plan Plugin Bridge not included in the plugin jar.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HookHandler getInstance() {
|
@Override
|
||||||
return null;// TODO
|
public void disable() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,8 +6,11 @@ package com.djrapitops.plan.system;
|
|||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.ShutdownHook;
|
import com.djrapitops.plan.ShutdownHook;
|
||||||
|
import com.djrapitops.plan.api.BukkitAPI;
|
||||||
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import com.djrapitops.plan.system.database.BukkitDBSystem;
|
import com.djrapitops.plan.system.database.BukkitDBSystem;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
|
import com.djrapitops.plan.system.info.BukkitInfoSystem;
|
||||||
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.BukkitListenerSystem;
|
import com.djrapitops.plan.system.listeners.BukkitListenerSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.BukkitConfigSystem;
|
import com.djrapitops.plan.system.settings.config.BukkitConfigSystem;
|
||||||
@ -30,8 +33,12 @@ public class BukkitSystem extends PlanSystem {
|
|||||||
listenerSystem = new BukkitListenerSystem(plugin);
|
listenerSystem = new BukkitListenerSystem(plugin);
|
||||||
taskSystem = new BukkitTaskSystem(plugin);
|
taskSystem = new BukkitTaskSystem(plugin);
|
||||||
|
|
||||||
|
infoSystem = new BukkitInfoSystem();
|
||||||
serverInfo = new BukkitServerInfo(plugin);
|
serverInfo = new BukkitServerInfo(plugin);
|
||||||
|
|
||||||
|
hookHandler = new HookHandler();
|
||||||
|
planAPI = new BukkitAPI(this);
|
||||||
|
|
||||||
StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass());
|
StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass());
|
||||||
new ShutdownHook().register();
|
new ShutdownHook().register();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.system;
|
|||||||
import com.djrapitops.plan.PlanBungee;
|
import com.djrapitops.plan.PlanBungee;
|
||||||
import com.djrapitops.plan.system.database.BungeeDBSystem;
|
import com.djrapitops.plan.system.database.BungeeDBSystem;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
import com.djrapitops.plan.system.info.BukkitInfoSystem;
|
import com.djrapitops.plan.system.info.BungeeInfoSystem;
|
||||||
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
|
import com.djrapitops.plan.system.listeners.BungeeListenerSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.BungeeConfigSystem;
|
import com.djrapitops.plan.system.settings.config.BungeeConfigSystem;
|
||||||
@ -29,7 +29,7 @@ public class BungeeSystem extends PlanSystem {
|
|||||||
listenerSystem = new BungeeListenerSystem(plugin);
|
listenerSystem = new BungeeListenerSystem(plugin);
|
||||||
taskSystem = new BungeeTaskSystem(plugin);
|
taskSystem = new BungeeTaskSystem(plugin);
|
||||||
|
|
||||||
infoSystem = new BukkitInfoSystem();
|
infoSystem = new BungeeInfoSystem();
|
||||||
serverInfo = new BungeeServerInfo(plugin);
|
serverInfo = new BungeeServerInfo(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system;
|
package com.djrapitops.plan.system;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.api.PlanAPI;
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import com.djrapitops.plan.system.cache.CacheSystem;
|
import com.djrapitops.plan.system.cache.CacheSystem;
|
||||||
import com.djrapitops.plan.system.database.DBSystem;
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
@ -44,6 +46,9 @@ public abstract class PlanSystem implements SubSystem {
|
|||||||
protected TaskSystem taskSystem;
|
protected TaskSystem taskSystem;
|
||||||
protected ServerInfo serverInfo;
|
protected ServerInfo serverInfo;
|
||||||
|
|
||||||
|
protected HookHandler hookHandler;
|
||||||
|
protected PlanAPI planAPI;
|
||||||
|
|
||||||
public PlanSystem() {
|
public PlanSystem() {
|
||||||
processingQueue = new ProcessingQueue();
|
processingQueue = new ProcessingQueue();
|
||||||
webServerSystem = new WebServerSystem();
|
webServerSystem = new WebServerSystem();
|
||||||
@ -117,6 +122,8 @@ public abstract class PlanSystem implements SubSystem {
|
|||||||
NullCheck.check(serverInfo, new IllegalStateException("ServerInfo was not initialized."));
|
NullCheck.check(serverInfo, new IllegalStateException("ServerInfo was not initialized."));
|
||||||
NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized."));
|
NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized."));
|
||||||
NullCheck.check(taskSystem, new IllegalStateException("Task system was not initialized."));
|
NullCheck.check(taskSystem, new IllegalStateException("Task system was not initialized."));
|
||||||
|
NullCheck.check(hookHandler, new IllegalStateException("Plugin Hooks were not initialized."));
|
||||||
|
NullCheck.check(planAPI, new IllegalStateException("Plan API was not initialized."));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e);
|
throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e);
|
||||||
}
|
}
|
||||||
@ -167,4 +174,12 @@ public abstract class PlanSystem implements SubSystem {
|
|||||||
public InfoSystem getInfoSystem() {
|
public InfoSystem getInfoSystem() {
|
||||||
return infoSystem;
|
return infoSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HookHandler getHookHandler() {
|
||||||
|
return hookHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlanAPI getPlanAPI() {
|
||||||
|
return planAPI;
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,10 +8,6 @@ import com.djrapitops.plan.api.exceptions.EnableException;
|
|||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.SubSystem;
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
import com.djrapitops.plan.utilities.NullCheck;
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System that holds data caches of the plugin.
|
* System that holds data caches of the plugin.
|
||||||
@ -36,13 +32,9 @@ public class CacheSystem implements SubSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() throws EnableException {
|
public void enable() throws EnableException {
|
||||||
try {
|
dataCache.enable();
|
||||||
GeolocationCache.checkDB();
|
geolocationCache.enable();
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
Log.error("Plan Requires internet access on first run to download GeoLite2 Geolocation database.");
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new EnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,7 @@ package com.djrapitops.plan.system.cache;
|
|||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.utilities.NullCheck;
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
@ -21,9 +22,9 @@ import java.util.*;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public class DataCache extends SessionCache {
|
public class DataCache extends SessionCache implements SubSystem {
|
||||||
|
|
||||||
private final Database db;
|
private Database db;
|
||||||
private final Map<UUID, String> playerNames;
|
private final Map<UUID, String> playerNames;
|
||||||
private final Map<String, UUID> uuids;
|
private final Map<String, UUID> uuids;
|
||||||
private final Map<UUID, String> displayNames;
|
private final Map<UUID, String> displayNames;
|
||||||
@ -35,13 +36,21 @@ public class DataCache extends SessionCache {
|
|||||||
*/
|
*/
|
||||||
public DataCache(PlanSystem system) {
|
public DataCache(PlanSystem system) {
|
||||||
super(system);
|
super(system);
|
||||||
db = system.getDatabaseSystem().getActiveDatabase();
|
|
||||||
|
|
||||||
playerNames = new HashMap<>();
|
playerNames = new HashMap<>();
|
||||||
displayNames = new HashMap<>();
|
displayNames = new HashMap<>();
|
||||||
uuids = new HashMap<>();
|
uuids = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
db = system.getDatabaseSystem().getActiveDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
}
|
||||||
|
|
||||||
public static DataCache getInstance() {
|
public static DataCache getInstance() {
|
||||||
DataCache dataCache = CacheSystem.getInstance().getDataCache();
|
DataCache dataCache = CacheSystem.getInstance().getDataCache();
|
||||||
NullCheck.check(dataCache, new IllegalStateException("Data Cache was not initialized."));
|
NullCheck.check(dataCache, new IllegalStateException("Data Cache was not initialized."));
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package com.djrapitops.plan.system.cache;
|
package com.djrapitops.plan.system.cache;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
import com.djrapitops.plan.utilities.NullCheck;
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.maxmind.geoip2.DatabaseReader;
|
import com.maxmind.geoip2.DatabaseReader;
|
||||||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||||
@ -13,6 +16,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -29,14 +33,29 @@ import java.util.zip.GZIPInputStream;
|
|||||||
* @author Fuzzlemann
|
* @author Fuzzlemann
|
||||||
* @since 3.5.5
|
* @since 3.5.5
|
||||||
*/
|
*/
|
||||||
public class GeolocationCache {
|
public class GeolocationCache implements SubSystem {
|
||||||
|
|
||||||
private final Map<String, String> geolocationCache;
|
private final Map<String, String> geolocationCache;
|
||||||
private final File geolocationDB;
|
private File geolocationDB;
|
||||||
|
|
||||||
public GeolocationCache() {
|
public GeolocationCache() {
|
||||||
geolocationCache = new HashMap<>();
|
geolocationCache = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() throws EnableException {
|
||||||
geolocationDB = new File(FileSystem.getDataFolder(), "GeoIP.dat");
|
geolocationDB = new File(FileSystem.getDataFolder(), "GeoIP.dat");
|
||||||
|
try {
|
||||||
|
GeolocationCache.checkDB();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
Log.error("Plan Requires internet access on first run to download GeoLite2 Geolocation database.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new EnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GeolocationCache getInstance() {
|
private static GeolocationCache getInstance() {
|
||||||
|
@ -50,7 +50,7 @@ public abstract class DBSystem implements SubSystem {
|
|||||||
Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName()));
|
Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName()));
|
||||||
Benchmark.stop("Enable", "Init Database");
|
Benchmark.stop("Enable", "Init Database");
|
||||||
} catch (DBInitException e) {
|
} catch (DBInitException e) {
|
||||||
throw new EnableException(db.getName() + "-Database failed to initialize", e);
|
throw new EnableException("Database failed to initialize", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql;
|
package com.djrapitops.plan.system.database.databases.sql;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.database.databases.operation.TransferOperations;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.operation.SQLTransferOps;
|
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
@ -16,15 +14,7 @@ public class MySQLDB extends SQLDB {
|
|||||||
|
|
||||||
private BasicDataSource dataSource;
|
private BasicDataSource dataSource;
|
||||||
|
|
||||||
private final SQLTransferOps transferOps;
|
|
||||||
|
|
||||||
public MySQLDB() {
|
public MySQLDB() {
|
||||||
transferOps = new SQLTransferOps(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TransferOperations transfer() {
|
|
||||||
return transferOps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +48,7 @@ public abstract class SQLDB extends Database {
|
|||||||
private final SQLSearchOps searchOps;
|
private final SQLSearchOps searchOps;
|
||||||
private final SQLCountOps countOps;
|
private final SQLCountOps countOps;
|
||||||
private final SQLSaveOps saveOps;
|
private final SQLSaveOps saveOps;
|
||||||
|
private final SQLTransferOps transferOps;
|
||||||
|
|
||||||
private final boolean usingMySQL;
|
private final boolean usingMySQL;
|
||||||
private boolean open = false;
|
private boolean open = false;
|
||||||
@ -81,7 +82,7 @@ public abstract class SQLDB extends Database {
|
|||||||
countOps = new SQLCountOps(this);
|
countOps = new SQLCountOps(this);
|
||||||
searchOps = new SQLSearchOps(this);
|
searchOps = new SQLSearchOps(this);
|
||||||
saveOps = new SQLSaveOps(this);
|
saveOps = new SQLSaveOps(this);
|
||||||
|
transferOps = new SQLTransferOps(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -390,4 +391,9 @@ public abstract class SQLDB extends Database {
|
|||||||
public SaveOperations save() {
|
public SaveOperations save() {
|
||||||
return saveOps;
|
return saveOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TransferOperations transfer() {
|
||||||
|
return transferOps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql;
|
package com.djrapitops.plan.system.database.databases.sql;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
import com.djrapitops.plan.PlanPlugin;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.UnsupportedTransferDatabaseException;
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.TransferOperations;
|
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
@ -37,11 +35,6 @@ public class SQLiteDB extends SQLDB {
|
|||||||
this.dbName = dbName;
|
this.dbName = dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TransferOperations transfer() throws UnsupportedTransferDatabaseException {
|
|
||||||
throw new UnsupportedTransferDatabaseException(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setups the {@link BasicDataSource}
|
* Setups the {@link BasicDataSource}
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +69,7 @@ public class TransferTable extends Table {
|
|||||||
.column(columnSenderID, Sql.INT).notNull()
|
.column(columnSenderID, Sql.INT).notNull()
|
||||||
.column(columnExpiry, Sql.LONG).notNull().defaultValue("0")
|
.column(columnExpiry, Sql.LONG).notNull().defaultValue("0")
|
||||||
.column(columnInfoType, Sql.varchar(100)).notNull()
|
.column(columnInfoType, Sql.varchar(100)).notNull()
|
||||||
.column(columnExtraVariables, Sql.varchar(255)).defaultValue("")
|
.column(columnExtraVariables, Sql.varchar(255)).defaultValue("''")
|
||||||
.column(columnContent, usingMySQL ? "MEDIUMTEXT" : Sql.varchar(1)) // SQLite does not enforce varchar limits.
|
.column(columnContent, usingMySQL ? "MEDIUMTEXT" : Sql.varchar(1)) // SQLite does not enforce varchar limits.
|
||||||
.foreignKey(columnSenderID, serverTable.toString(), serverTable.getColumnID())
|
.foreignKey(columnSenderID, serverTable.toString(), serverTable.getColumnID())
|
||||||
.toString()
|
.toString()
|
||||||
|
@ -27,6 +27,9 @@ public class BukkitInfoSystem extends InfoSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void runLocally(InfoRequest infoRequest) throws WebException {
|
protected void runLocally(InfoRequest infoRequest) throws WebException {
|
||||||
|
if (infoRequest instanceof CacheNetworkPageContentRequest) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (infoRequest instanceof InfoRequestWithVariables) {
|
if (infoRequest instanceof InfoRequestWithVariables) {
|
||||||
infoRequest.handleRequest(((InfoRequestWithVariables) infoRequest).getVariables());
|
infoRequest.handleRequest(((InfoRequestWithVariables) infoRequest).getVariables());
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package com.djrapitops.plan.system.info;
|
package com.djrapitops.plan.system.info;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
|
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.SubSystem;
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
@ -57,10 +58,14 @@ public abstract class InfoSystem implements SubSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendRequest(InfoRequest infoRequest) throws WebException {
|
public void sendRequest(InfoRequest infoRequest) throws WebException {
|
||||||
if (!connectionSystem.isServerAvailable()) {
|
try {
|
||||||
|
if (!connectionSystem.isServerAvailable()) {
|
||||||
|
runLocally(infoRequest);
|
||||||
|
}
|
||||||
|
connectionSystem.sendInfoRequest(infoRequest);
|
||||||
|
} catch (NoServersException e) {
|
||||||
runLocally(infoRequest);
|
runLocally(infoRequest);
|
||||||
}
|
}
|
||||||
connectionSystem.sendInfoRequest(infoRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void runLocally(InfoRequest infoRequest) throws WebException;
|
protected abstract void runLocally(InfoRequest infoRequest) throws WebException;
|
||||||
@ -70,6 +75,8 @@ public abstract class InfoSystem implements SubSystem {
|
|||||||
connectionSystem.enable();
|
connectionSystem.enable();
|
||||||
try {
|
try {
|
||||||
updateNetworkPage();
|
updateNetworkPage();
|
||||||
|
} catch (NoServersException e) {
|
||||||
|
/* Ignored */
|
||||||
} catch (WebException e) {
|
} catch (WebException e) {
|
||||||
// TODO Exception handling
|
// TODO Exception handling
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
@ -87,7 +94,7 @@ public abstract class InfoSystem implements SubSystem {
|
|||||||
|
|
||||||
public abstract void updateNetworkPage() throws WebException;
|
public abstract void updateNetworkPage() throws WebException;
|
||||||
|
|
||||||
public void requestSetUp(String address) throws WebException {
|
public void requestSetUp(String address) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -77,7 +77,7 @@ public class BukkitConnectionSystem extends ConnectionSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw new NoServersException("Proper server is not available to process requests.");
|
throw new NoServersException("Proper server is not available to process request: " + infoRequest.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class BungeeConnectionSystem extends ConnectionSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
throw new NoServersException("Proper server is not available to process requests.");
|
throw new NoServersException("Proper server is not available to process request: " + infoRequest.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class ConnectionOut {
|
|||||||
public void sendRequest() throws WebException {
|
public void sendRequest() throws WebException {
|
||||||
String address = toServer.getWebAddress();
|
String address = toServer.getWebAddress();
|
||||||
try {
|
try {
|
||||||
URL url = new URL(address + "/info/" + this.getClass().getSimpleName().toLowerCase());
|
URL url = new URL(address + "/info/" + infoRequest.getClass().getSimpleName().toLowerCase());
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
if (address.startsWith("https")) {
|
if (address.startsWith("https")) {
|
||||||
HttpsURLConnection httpsConn = (HttpsURLConnection) connection;
|
HttpsURLConnection httpsConn = (HttpsURLConnection) connection;
|
||||||
|
@ -54,11 +54,13 @@ public abstract class ConnectionSystem implements SubSystem {
|
|||||||
private Map<String, InfoRequest> loadDataRequests() {
|
private Map<String, InfoRequest> loadDataRequests() {
|
||||||
Map<String, InfoRequest> requests = new HashMap<>();
|
Map<String, InfoRequest> requests = new HashMap<>();
|
||||||
putRequest(requests, CacheInspectPageRequest.createHandler());
|
putRequest(requests, CacheInspectPageRequest.createHandler());
|
||||||
|
putRequest(requests, CacheInspectPluginsTabRequest.createHandler());
|
||||||
putRequest(requests, CacheAnalysisPageRequest.createHandler());
|
putRequest(requests, CacheAnalysisPageRequest.createHandler());
|
||||||
putRequest(requests, CacheNetworkPageContentRequest.createHandler());
|
putRequest(requests, CacheNetworkPageContentRequest.createHandler());
|
||||||
|
|
||||||
putRequest(requests, GenerateAnalysisPageRequest.createHandler());
|
putRequest(requests, GenerateAnalysisPageRequest.createHandler());
|
||||||
putRequest(requests, GenerateInspectPageRequest.createHandler());
|
putRequest(requests, GenerateInspectPageRequest.createHandler());
|
||||||
|
putRequest(requests, GenerateInspectPluginsTabRequest.createHandler());
|
||||||
return requests;
|
return requests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,12 +24,11 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public abstract class ConfigSystem implements SubSystem {
|
public abstract class ConfigSystem implements SubSystem {
|
||||||
|
|
||||||
protected final Config config;
|
protected Config config;
|
||||||
protected final Locale locale;
|
protected final Locale locale;
|
||||||
protected final Theme theme;
|
protected final Theme theme;
|
||||||
|
|
||||||
public ConfigSystem() {
|
public ConfigSystem() {
|
||||||
config = new Config(FileSystem.getConfigFile());
|
|
||||||
locale = new Locale();
|
locale = new Locale();
|
||||||
theme = new Theme();
|
theme = new Theme();
|
||||||
}
|
}
|
||||||
@ -50,6 +49,7 @@ public abstract class ConfigSystem implements SubSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() throws EnableException {
|
public void enable() throws EnableException {
|
||||||
|
config = new Config(FileSystem.getConfigFile());
|
||||||
try {
|
try {
|
||||||
copyDefaults();
|
copyDefaults();
|
||||||
config.save();
|
config.save();
|
||||||
|
@ -16,7 +16,6 @@ import com.sun.net.httpserver.Headers;
|
|||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +49,7 @@ public class RequestHandler implements HttpHandler {
|
|||||||
}
|
}
|
||||||
response.setResponseHeaders(responseHeaders);
|
response.setResponseHeaders(responseHeaders);
|
||||||
response.send(exchange);
|
response.send(exchange);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
if (Settings.DEV_MODE.isTrue()) {
|
if (Settings.DEV_MODE.isTrue()) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse;
|
|||||||
import com.djrapitops.plan.system.webserver.response.errors.UnauthorizedServerResponse;
|
import com.djrapitops.plan.system.webserver.response.errors.UnauthorizedServerResponse;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -79,8 +80,10 @@ public class ResponseHandler extends TreePageHandler {
|
|||||||
|
|
||||||
public Response getResponse(Request request) {
|
public Response getResponse(Request request) {
|
||||||
String targetString = request.getTarget();
|
String targetString = request.getTarget();
|
||||||
List<String> target = Arrays.asList(targetString.split("/"));
|
List<String> target = new ArrayList<>(Arrays.asList(targetString.split("/")));
|
||||||
target.remove(0);
|
if (!target.isEmpty()) {
|
||||||
|
target.remove(0);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return getResponse(request, targetString, target);
|
return getResponse(request, targetString, target);
|
||||||
} catch (WebUserAuthException e) {
|
} catch (WebUserAuthException e) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.djrapitops.plan.system.webserver;
|
package com.djrapitops.plan.system.webserver;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
import com.djrapitops.plan.PlanPlugin;
|
||||||
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.system.SubSystem;
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
@ -44,17 +45,28 @@ public class WebServer implements SubSystem {
|
|||||||
private ResponseHandler responseHandler;
|
private ResponseHandler responseHandler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() throws EnableException {
|
||||||
this.port = Settings.WEBSERVER_PORT.getNumber();
|
this.port = Settings.WEBSERVER_PORT.getNumber();
|
||||||
|
|
||||||
|
requestHandler = new RequestHandler(this);
|
||||||
|
responseHandler = requestHandler.getResponseHandler();
|
||||||
|
|
||||||
PlanPlugin plugin = PlanPlugin.getInstance();
|
PlanPlugin plugin = PlanPlugin.getInstance();
|
||||||
StaticHolder.saveInstance(RequestHandler.class, plugin.getClass());
|
StaticHolder.saveInstance(RequestHandler.class, plugin.getClass());
|
||||||
StaticHolder.saveInstance(ResponseHandler.class, plugin.getClass());
|
StaticHolder.saveInstance(ResponseHandler.class, plugin.getClass());
|
||||||
|
|
||||||
requestHandler = new RequestHandler(this);
|
|
||||||
responseHandler = requestHandler.getResponseHandler();
|
|
||||||
|
|
||||||
initServer();
|
initServer();
|
||||||
|
|
||||||
|
if (!isEnabled()) {
|
||||||
|
if (Check.isBungeeAvailable()) {
|
||||||
|
throw new EnableException("WebServer did not initialize!");
|
||||||
|
}
|
||||||
|
if (Settings.WEBSERVER_DISABLED.isTrue()) {
|
||||||
|
Log.warn("WebServer was not initialized. (WebServer.DisableWebServer: true)");
|
||||||
|
} else {
|
||||||
|
Log.error("WebServer was not initialized successfully. Is the port (" + Settings.WEBSERVER_PORT.getNumber() + ") in use?");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,7 +77,7 @@ public class WebServer implements SubSystem {
|
|||||||
/**
|
/**
|
||||||
* Starts up the WebServer in a new Thread Pool.
|
* Starts up the WebServer in a new Thread Pool.
|
||||||
*/
|
*/
|
||||||
public void initServer() {
|
private void initServer() {
|
||||||
// Check if Bukkit WebServer has been disabled.
|
// Check if Bukkit WebServer has been disabled.
|
||||||
if (!Check.isBungeeAvailable() && Settings.WEBSERVER_DISABLED.isTrue()) {
|
if (!Check.isBungeeAvailable() && Settings.WEBSERVER_DISABLED.isTrue()) {
|
||||||
return;
|
return;
|
||||||
@ -86,7 +98,6 @@ public class WebServer implements SubSystem {
|
|||||||
Log.infoColor("§eUser Authorization Disabled! (Not possible over http)");
|
Log.infoColor("§eUser Authorization Disabled! (Not possible over http)");
|
||||||
server = HttpServer.create(new InetSocketAddress(Settings.WEBSERVER_IP.toString(), port), 10);
|
server = HttpServer.create(new InetSocketAddress(Settings.WEBSERVER_IP.toString(), port), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
server.createContext("/", requestHandler);
|
server.createContext("/", requestHandler);
|
||||||
|
|
||||||
server.setExecutor(new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100)));
|
server.setExecutor(new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100)));
|
||||||
|
@ -7,11 +7,8 @@ package com.djrapitops.plan.system.webserver;
|
|||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.system.PlanSystem;
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
import com.djrapitops.plan.system.SubSystem;
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
|
||||||
import com.djrapitops.plan.system.webserver.response.cache.ResponseCache;
|
import com.djrapitops.plan.system.webserver.response.cache.ResponseCache;
|
||||||
import com.djrapitops.plugin.api.Benchmark;
|
import com.djrapitops.plugin.api.Benchmark;
|
||||||
import com.djrapitops.plugin.api.Check;
|
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebServer subsystem for managing WebServer initialization.
|
* WebServer subsystem for managing WebServer initialization.
|
||||||
@ -38,17 +35,7 @@ public class WebServerSystem implements SubSystem {
|
|||||||
@Override
|
@Override
|
||||||
public void enable() throws EnableException {
|
public void enable() throws EnableException {
|
||||||
Benchmark.start("WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
webServer.initServer();
|
webServer.enable();
|
||||||
if (!webServer.isEnabled()) {
|
|
||||||
if (Check.isBungeeAvailable()) {
|
|
||||||
throw new EnableException("WebServer did not initialize!");
|
|
||||||
}
|
|
||||||
if (Settings.WEBSERVER_DISABLED.isTrue()) {
|
|
||||||
Log.warn("WebServer was not initialized. (WebServer.DisableWebServer: true)");
|
|
||||||
} else {
|
|
||||||
Log.error("WebServer was not initialized successfully. Is the port (" + Settings.WEBSERVER_PORT.getNumber() + ") in use?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Benchmark.stop("Enable", "WebServer Initialization");
|
Benchmark.stop("Enable", "WebServer Initialization");
|
||||||
ResponseHandler responseHandler = webServer.getResponseHandler();
|
ResponseHandler responseHandler = webServer.getResponseHandler();
|
||||||
responseHandler.registerWebAPIPages();
|
responseHandler.registerWebAPIPages();
|
||||||
|
Loading…
Reference in New Issue
Block a user