From c786e7795a855d77794b608d0b0f61fc0b263621 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 19:14:50 +0200 Subject: [PATCH] Deleted InformationManagers --- .../main/java/com/djrapitops/plan/Plan.java | 14 +- .../java/com/djrapitops/plan/PlanBungee.java | 16 -- .../java/com/djrapitops/plan/PlanPlugin.java | 4 - .../plan/command/commands/ListCommand.java | 4 +- .../plan/command/commands/NetworkCommand.java | 3 +- .../commands/manage/ManageImportCommand.java | 2 +- .../plan/system/info/InfoSystem.java | 7 + .../importing}/ImporterManager.java | 4 +- .../importing/ServerImportData.java | 2 +- .../importing/UserImportData.java | 2 +- .../importing/UserImportRefiner.java | 2 +- .../importing/importers/Importer.java | 13 +- .../importers/OfflinePlayerImporter.java | 6 +- .../system/tasks/bukkit/BootAnalysisTask.java | 12 +- .../tasks/bukkit/PeriodicAnalysisTask.java | 12 +- .../tasks/bungee/EnableConnectionTask.java | 8 +- .../webserver/pages/ServerPageHandler.java | 4 +- .../response/pages/AnalysisPageResponse.java | 44 +--- .../webapi/bukkit/AnalysisReadyWebAPI.java | 9 +- .../webapi/bukkit/AnalyzeWebAPI.java | 9 +- .../webapi/bungee/PostHtmlWebAPI.java | 55 +---- .../info/BukkitInformationManager.java | 204 ------------------ .../info/BungeeInformationManager.java | 185 ---------------- .../plan/systems/info/InformationManager.java | 61 ------ .../utilities/file/export/HtmlExport.java | 5 +- .../plan/utilities/metrics/BStats.java | 3 +- .../java/com/djrapitops/plan/api/API.java | 15 +- .../importer/ImportBuilderTest.java | 4 +- 28 files changed, 87 insertions(+), 622 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/{systems/info => system/processing/importing}/ImporterManager.java (91%) rename Plan/src/main/java/com/djrapitops/plan/system/processing/{processors => }/importing/ServerImportData.java (97%) rename Plan/src/main/java/com/djrapitops/plan/system/processing/{processors => }/importing/UserImportData.java (99%) rename Plan/src/main/java/com/djrapitops/plan/system/processing/{processors => }/importing/UserImportRefiner.java (99%) rename Plan/src/main/java/com/djrapitops/plan/system/processing/{processors => }/importing/importers/Importer.java (95%) rename Plan/src/main/java/com/djrapitops/plan/system/processing/{processors => }/importing/importers/OfflinePlayerImporter.java (85%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index f49a10e6e..a6f1e9017 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -34,16 +34,14 @@ import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.info.server.BukkitServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerProperties; -import com.djrapitops.plan.system.processing.processors.importing.importers.OfflinePlayerImporter; +import com.djrapitops.plan.system.processing.importing.ImporterManager; +import com.djrapitops.plan.system.processing.importing.importers.OfflinePlayerImporter; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.systems.info.BukkitInformationManager; -import com.djrapitops.plan.systems.info.ImporterManager; -import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; @@ -75,7 +73,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { private HookHandler hookHandler; // Manages 3rd party data sources - private BukkitInformationManager infoManager; private BukkitServerInfo serverInfoManager; private ServerProperties serverProperties; @@ -137,7 +134,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { Benchmark.start("WebServer Initialization"); serverInfoManager = new BukkitServerInfo(this); - infoManager = new BukkitInformationManager(this); WebServerSystem.getInstance().enable(); if (!WebServerSystem.isWebServerEnabled()) { if (Settings.WEBSERVER_DISABLED.isTrue()) { @@ -148,7 +144,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { } } serverInfoManager.updateServerInfo(); - infoManager.updateConnection(); Benchmark.stop("Enable", "WebServer Initialization"); @@ -270,11 +265,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { return serverInfoManager; } - @Deprecated - public InformationManager getInfoManager() { - return infoManager; - } - public boolean isReloading() { return reloading; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 6384cef4e..0b1cc6893 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -21,13 +21,10 @@ import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.systems.info.BungeeInformationManager; -import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.systems.TaskCenter; import com.djrapitops.plugin.api.utility.log.DebugLog; import com.djrapitops.plugin.api.utility.log.Log; @@ -47,7 +44,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { private BungeeSystem system; private BungeeServerInfo serverInfoManager; - private BungeeInformationManager infoManager; private ServerProperties variableHolder; @Deprecated @@ -89,7 +85,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { Benchmark.start("WebServer Initialization"); serverInfoManager = new BungeeServerInfo(this); - infoManager = new BungeeInformationManager(this); WebServerSystem.getInstance().enable(); serverInfoManager.loadServerInfo(); @@ -137,12 +132,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { return serverInfoManager; } - @Override - @Deprecated - public InformationManager getInfoManager() { - return infoManager; - } - @Override public WebServer getWebServer() { return WebServerSystem.getInstance().getWebServer(); @@ -153,11 +142,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { return getResourceAsStream(resource); } - @Override - public Config getMainConfig() { - return ConfigSystem.getInstance().getConfig(); - } - @Override public ColorScheme getColorScheme() { return PlanColorScheme.create(); diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 157fcc095..d5a2204e5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -7,7 +7,6 @@ package com.djrapitops.plan; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.webserver.WebServer; -import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.settings.ColorScheme; @@ -44,9 +43,6 @@ public interface PlanPlugin extends IPlugin { @Deprecated UUID getServerUuid(); - @Deprecated - InformationManager getInfoManager(); - @Deprecated WebServer getWebServer(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListCommand.java index 3b8851fce..b629010d2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; @@ -43,7 +43,7 @@ public class ListCommand extends SubCommand { sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse()); // Link - String url = PlanPlugin.getInstance().getInfoManager().getLinkTo("/players/"); + String url = ConnectionSystem.getAddress() + "/players/"; String message = Locale.get(Msg.CMD_INFO_LINK).toString(); boolean console = !CommandUtils.isPlayer(sender); if (console) { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/NetworkCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/NetworkCommand.java index 2d63a7b95..2d7f88e7e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/NetworkCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/NetworkCommand.java @@ -3,6 +3,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; @@ -42,7 +43,7 @@ public class NetworkCommand extends SubCommand { sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse()); // Link - String url = plugin.getInfoManager().getLinkTo("/network/"); + String url = ConnectionSystem.getAddress() + "/network/"; String message = Locale.get(Msg.CMD_INFO_LINK).toString(); boolean console = !CommandUtils.isPlayer(sender); if (console) { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java index acc7f92e5..9110ac378 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java @@ -3,8 +3,8 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.processing.importing.ImporterManager; import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/InfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/InfoSystem.java index 041a15e8b..f71c7b8f0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/InfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/InfoSystem.java @@ -14,6 +14,7 @@ import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest; import com.djrapitops.plan.system.info.request.GenerateInspectPageRequest; import com.djrapitops.plan.system.info.request.InfoRequest; import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.utility.log.Log; import java.util.UUID; @@ -67,6 +68,12 @@ public abstract class InfoSystem implements SubSystem { @Override public void enable() throws EnableException { connectionSystem.enable(); + try { + updateNetworkPage(); + } catch (WebException e) { + // TODO Exception handling + Log.toLog(this.getClass().getName(), e); + } } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/ImporterManager.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/importing/ImporterManager.java index 762a45a24..581430d5c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/ImporterManager.java @@ -2,9 +2,9 @@ * 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.systems.info; +package com.djrapitops.plan.system.processing.importing; -import com.djrapitops.plan.system.processing.processors.importing.importers.Importer; +import com.djrapitops.plan.system.processing.importing.importers.Importer; import java.util.ArrayList; import java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/ServerImportData.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/ServerImportData.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/ServerImportData.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/importing/ServerImportData.java index 1624d758f..33c711df7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/ServerImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/ServerImportData.java @@ -2,7 +2,7 @@ * 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.system.processing.processors.importing; +package com.djrapitops.plan.system.processing.importing; import com.djrapitops.plan.data.container.TPS; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportData.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportData.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportData.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportData.java index 572607797..450e9d6cd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportData.java @@ -2,7 +2,7 @@ * 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.system.processing.processors.importing; +package com.djrapitops.plan.system.processing.importing; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.time.GMTimes; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportRefiner.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportRefiner.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportRefiner.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportRefiner.java index 0afe68c08..e99dfa97b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportRefiner.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportRefiner.java @@ -2,7 +2,7 @@ * 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.system.processing.processors.importing; +package com.djrapitops.plan.system.processing.importing; import com.djrapitops.plan.Plan; import com.djrapitops.plugin.api.Benchmark; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/Importer.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/Importer.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java index 3c343aea7..40d3cc3e4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java @@ -2,7 +2,7 @@ * 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.system.processing.processors.importing.importers; +package com.djrapitops.plan.system.processing.importing.importers; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; @@ -12,9 +12,10 @@ import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.processing.processors.importing.ServerImportData; -import com.djrapitops.plan.system.processing.processors.importing.UserImportData; -import com.djrapitops.plan.system.processing.processors.importing.UserImportRefiner; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.processing.importing.ServerImportData; +import com.djrapitops.plan.system.processing.importing.UserImportData; +import com.djrapitops.plan.system.processing.importing.UserImportRefiner; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; @@ -95,7 +96,7 @@ public abstract class Importer { } Plan plugin = Plan.getInstance(); - UUID uuid = plugin.getServerInfoManager().getServerUUID(); + UUID uuid = ServerInfo.getServerUUID(); Database db = plugin.getDB(); ExecutorService service = Executors.newCachedThreadPool(); @@ -151,7 +152,7 @@ public abstract class Importer { UserImportRefiner userImportRefiner = new UserImportRefiner(plugin, userImportData); userImportData = userImportRefiner.refineData(); - UUID serverUUID = plugin.getServerInfoManager().getServerUUID(); + UUID serverUUID = ServerInfo.getServerUUID(); Database db = plugin.getDB(); Set existingUUIDs = db.fetch().getSavedUUIDs(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/OfflinePlayerImporter.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/OfflinePlayerImporter.java similarity index 85% rename from Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/OfflinePlayerImporter.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/OfflinePlayerImporter.java index ed7546cbe..c61bb1b88 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/OfflinePlayerImporter.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/OfflinePlayerImporter.java @@ -2,10 +2,10 @@ * 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.system.processing.processors.importing.importers; +package com.djrapitops.plan.system.processing.importing.importers; -import com.djrapitops.plan.system.processing.processors.importing.ServerImportData; -import com.djrapitops.plan.system.processing.processors.importing.UserImportData; +import com.djrapitops.plan.system.processing.importing.ServerImportData; +import com.djrapitops.plan.system.processing.importing.UserImportData; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BootAnalysisTask.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BootAnalysisTask.java index 2c4c14af1..2f7186f3d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BootAnalysisTask.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BootAnalysisTask.java @@ -1,8 +1,12 @@ package com.djrapitops.plan.system.tasks.bukkit; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.connection.WebExceptionLogger; +import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; @@ -16,7 +20,11 @@ public class BootAnalysisTask extends AbsRunnable { public void run() { String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString(); Log.info(bootAnalysisRunMsg); - Plan.getInstance().getInfoManager().refreshAnalysis(Plan.getServerUUID()); + if (!Analysis.isAnalysisBeingRun()) { + WebExceptionLogger.logIfOccurs(this.getClass(), () -> + InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) + ); + } cancel(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PeriodicAnalysisTask.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PeriodicAnalysisTask.java index 79cb344fa..c0c780a04 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PeriodicAnalysisTask.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PeriodicAnalysisTask.java @@ -1,6 +1,10 @@ package com.djrapitops.plan.system.tasks.bukkit; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.connection.WebExceptionLogger; +import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plugin.task.AbsRunnable; public class PeriodicAnalysisTask extends AbsRunnable { @@ -11,6 +15,10 @@ public class PeriodicAnalysisTask extends AbsRunnable { @Override public void run() { - Plan.getInstance().getInfoManager().refreshAnalysis(Plan.getServerUUID()); + if (!Analysis.isAnalysisBeingRun()) { + WebExceptionLogger.logIfOccurs(this.getClass(), () -> + InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) + ); + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/EnableConnectionTask.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/EnableConnectionTask.java index b6b66734f..9a4e43627 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/EnableConnectionTask.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/EnableConnectionTask.java @@ -1,7 +1,5 @@ package com.djrapitops.plan.system.tasks.bungee; -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plugin.task.AbsRunnable; public class EnableConnectionTask extends AbsRunnable { @@ -12,9 +10,9 @@ public class EnableConnectionTask extends AbsRunnable { @Override public void run() { - BungeeInformationManager infoManager = (BungeeInformationManager) PlanBungee.getInstance().getInfoManager(); - infoManager.attemptConnection(); - infoManager.sendConfigSettings(); +// TODO Config InfoRequests. + // infoManager.attemptConnection(); +// infoManager.sendConfigSettings(); cancel(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java index 5c3b5ed2f..294245e78 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java @@ -28,9 +28,7 @@ public class ServerPageHandler extends PageHandler { @Override public Response getResponse(Request request, List target) { UUID serverUUID = getServerUUID(target); - return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), - () -> new AnalysisPageResponse(PlanPlugin.getInstance().getInfoManager()) - ); + return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), AnalysisPageResponse::refreshNow); } private UUID getServerUUID(List target) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java index 696b0ac15..6538d937f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java @@ -1,13 +1,10 @@ package com.djrapitops.plan.system.webserver.response.pages; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.AnalysisData; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; -import com.djrapitops.plan.systems.info.BukkitInformationManager; -import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plugin.task.AbsRunnable; -import com.djrapitops.plugin.task.RunnableFactory; +import com.djrapitops.plugin.api.utility.log.Log; /** * @author Rsl1122 @@ -15,35 +12,14 @@ import com.djrapitops.plugin.task.RunnableFactory; */ public class AnalysisPageResponse extends Response { - /** - * Constructor. - * - * @param informationManager InformationManager to use for getting the Html - * @throws NullPointerException if AnalysisData has not been cached after 1 second. - */ - public AnalysisPageResponse(InformationManager informationManager) { - super.setHeader("HTTP/1.1 200 OK"); - - if (informationManager instanceof BukkitInformationManager) { - AnalysisData analysisData = ((BukkitInformationManager) informationManager).getAnalysisData(); - if (analysisData == null) { - RunnableFactory.createNew("OnRequestAnalysisRefreshTask", new AbsRunnable() { - @Override - public void run() { - informationManager.refreshAnalysis(Plan.getServerUUID()); - } - }).runTaskAsynchronously(); - - ErrorResponse analysisRefreshPage = new ErrorResponse(); - analysisRefreshPage.setTitle("Analysis is being refreshed.."); - analysisRefreshPage.setParagraph(" Analysis is being run, refresh the page after a few seconds.. (F5)"); - analysisRefreshPage.replacePlaceholders(); - super.setContent(analysisRefreshPage.getContent()); - - return; - } + public static AnalysisPageResponse refreshNow() { + try { + InfoSystem.getInstance().generateAnalysisPageOfThisServer(); + } catch (WebException e) { + // TODO Exception handling + Log.toLog(AnalysisPageResponse.class, e); } - super.setContent(informationManager.getAnalysisHtml()); + return new AnalysisPageResponse(getRefreshingHtml()); } public AnalysisPageResponse(String html) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java index af3d13be7..0e4f0a50e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java @@ -15,16 +15,11 @@ import java.util.UUID; /** * @author Rsl1122 */ +@Deprecated public class AnalysisReadyWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { - String serverUUIDS = variables.get("serverUUID"); - if (serverUUIDS == null) { - return badRequest("serverUUID was not present"); - } - UUID serverUUID = UUID.fromString(serverUUIDS); - plugin.getInfoManager().analysisReady(serverUUID); - return success(); + return fail("Deprecated"); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java index 621b13f65..0abc9ccfb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java @@ -15,16 +15,11 @@ import java.util.UUID; /** * @author Rsl1122 */ +@Deprecated public class AnalyzeWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { - String serverUUIDS = variables.get("serverUUID"); - if (serverUUIDS == null) { - return badRequest("serverUUID was not present"); - } - UUID serverUUID = UUID.fromString(serverUUIDS); - plugin.getInfoManager().refreshAnalysis(serverUUID); - return success(); + return fail("Deprecated"); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java index 9d92bd9e8..b54d10ee0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java @@ -6,19 +6,9 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.response.cache.PageId; -import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; -import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; -import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.utilities.file.export.HtmlExport; -import com.djrapitops.plugin.api.utility.log.Log; -import org.apache.commons.lang3.text.StrSubstitutor; -import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -27,53 +17,12 @@ import java.util.UUID; * * @author Rsl1122 */ +@Deprecated public class PostHtmlWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { - try { - String htmlVariable = variables.get("html"); - if (htmlVariable == null) { - return badRequest("Html was null"); - } - if (!htmlVariable.startsWith("")) { - String[] split = htmlVariable.split("", 2); - if (split.length <= 1) { - Log.debug(htmlVariable); - return badRequest("Html did not start with "); - } - htmlVariable = "" + split[1]; - } - String html = htmlVariable; - - String target = variables.get("target"); - InformationManager infoManager = plugin.getInfoManager(); - switch (target) { - case "inspectPage": - String uuid = variables.get("uuid"); - - Map map = new HashMap<>(); - map.put("networkName", Settings.BUNGEE_NETWORK_NAME.toString()); - - ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(infoManager, UUID.fromString(uuid), StrSubstitutor.replace(html, map))); - if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportPlayer(UUID.fromString(uuid)); - } - break; - case "analysisPage": - String sender = variables.get("sender"); - ResponseCache.cacheResponse(PageId.SERVER.of(sender), () -> new AnalysisPageResponse(html)); - if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportServer(UUID.fromString(sender)); - } - break; - default: - return badRequest("Faulty Target"); - } - return success(); - } catch (NullPointerException e) { - return badRequest(e.toString()); - } + return fail("Deprecated"); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java deleted file mode 100644 index 97bcb829b..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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.systems.info; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException; -import com.djrapitops.plan.api.exceptions.connection.NotFoundException; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.api.exceptions.connection.WebFailException; -import com.djrapitops.plan.data.AnalysisData; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.WebServer; -import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.system.webserver.pages.parsing.AnalysisPage; -import com.djrapitops.plan.system.webserver.response.cache.PageId; -import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; -import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; -import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; -import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; -import com.djrapitops.plan.system.webserver.webapi.WebAPIManager; -import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalysisReadyWebAPI; -import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI; -import com.djrapitops.plan.system.webserver.webapi.bungee.PostHtmlWebAPI; -import com.djrapitops.plan.system.webserver.webapi.bungee.PostOriginalBukkitSettingsWebAPI; -import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plan.utilities.analysis.Analysis; -import com.djrapitops.plan.utilities.file.export.HtmlExport; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.util.HashSet; -import java.util.Optional; -import java.util.UUID; - -/** - * Manages the Information going to the ResponseCache. - *

- * This means Inspect and Analysis pages as well as managing what is sent to Bungee WebServer when one is in use. - * - * @author Rsl1122 - */ -@Deprecated -public class BukkitInformationManager extends InformationManager { - - private final Plan plugin; - private final Analysis analysis; - private AnalysisData analysisData; - - public BukkitInformationManager(Plan plugin) { - this.plugin = plugin; - analysis = new Analysis(plugin); - usingAnotherWebServer = false; - } - - public void updateConnection() { - Optional bungeeConnectionAddress = plugin.getServerInfoManager().getBungeeConnectionAddress(); - if (bungeeConnectionAddress.isPresent() && Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isFalse()) { - webServerAddress = bungeeConnectionAddress.get(); - attemptConnection(); - } else { - usingAnotherWebServer = false; - } - } - - @Override - public void refreshAnalysis(UUID serverUUID) { - if (Plan.getServerUUID().equals(serverUUID)) { - analysis.runAnalysis(); - } else if (usingAnotherWebServer) { - try { - getWebAPI().getAPI(AnalyzeWebAPI.class).sendRequest(webServerAddress, serverUUID); - } catch (WebFailException e) { - Log.error("Failed to request Analysis refresh from Bungee."); - } catch (WebException e) { - attemptConnection(); - refreshAnalysis(serverUUID); - } - } - - } - - private WebAPIManager getWebAPI() { - return plugin.getWebServer().getWebAPI(); - } - - /** - * Get the HTML for analysis page of this server. - * - * @return Html for Analysis page - * @throws NullPointerException if AnalysisData has not been cached. - */ - @Override - public String getAnalysisHtml() { - if (analysisData == null) { - analysis.runAnalysis(); - ErrorResponse analysisRefreshPage = new ErrorResponse(); - analysisRefreshPage.setTitle("Analysis is being refreshed.."); - analysisRefreshPage.setParagraph(" Analysis is being run, refresh the page after a few seconds.. (F5)"); - analysisRefreshPage.replacePlaceholders(); - return analysisRefreshPage.getContent(); - } - try { - return Theme.replaceColors(new AnalysisPage(analysisData, plugin).toHtml()); - } catch (ParseException e) { - return new InternalErrorResponse(e, this.getClass().getSimpleName()).getContent(); - } - } - - public void cacheAnalysisData(AnalysisData analysisData) { - this.analysisData = analysisData; - refreshDate = MiscUtils.getTime(); - cacheAnalysisHtml(); - UUID serverUUID = Plan.getServerUUID(); - if (usingAnotherWebServer) { - try { - getWebAPI().getAPI(AnalysisReadyWebAPI.class).sendRequest(webServerAddress, serverUUID); -// updateNetworkPageContent(); - return; - } catch (WebFailException ignored) { - Log.error("Failed to notify Bungee of Analysis Completion."); - } catch (WebException e) { - attemptConnection(); - } - } - analysisReady(serverUUID); - } - - private void cacheAnalysisHtml() { - cacheAnalysisHtml(getAnalysisHtml()); - } - - @Deprecated - public void cacheAnalysisHtml(String html) { - if (usingAnotherWebServer) { - try { - getWebAPI().getAPI(PostHtmlWebAPI.class).sendAnalysisHtml(webServerAddress, html); - } catch (WebFailException e) { - Log.error("Failed to send Analysis HTML to Bungee Server."); - } catch (WebException e) { - attemptConnection(); - cacheAnalysisHtml(html); - } - } else { - UUID serverUUID = Plan.getServerUUID(); - ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); - if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportServer(serverUUID); - } - } - } - - public AnalysisData getAnalysisData() { - return analysisData; - } - - @Override - public boolean attemptConnection() { - boolean webServerIsEnabled = WebServerSystem.isWebServerEnabled(); - boolean previousState = usingAnotherWebServer; - - try { - 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 (ConnectionFailException e) { - plugin.getServerInfoManager().markConnectionFail(); - } catch (NotFoundException e) { - Log.info("Bungee reported that UUID of this server is not in the MySQL-database. Try using '/plan m setup " + webServerAddress + "' again"); - } catch (WebException 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 webServer = WebServerSystem.getInstance().getWebServer(); - webServer.stop(); - webServer.initServer(); - } - } - } - - @Override - public String getWebServerAddress() { - return webServerAddress != null ? webServerAddress : plugin.getWebServer().getAccessAddress(); - } - - @Override - public void analysisReady(UUID serverUUID) { - analysisNotification.getOrDefault(serverUUID, new HashSet<>()).clear(); - } - -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java deleted file mode 100644 index 3236e8ef8..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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.systems.info; - -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.info.server.BungeeServerInfo; -import com.djrapitops.plan.system.info.server.Server; -import com.djrapitops.plan.system.webserver.pages.parsing.NetworkPage; -import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; -import com.djrapitops.plan.system.webserver.webapi.WebAPIManager; -import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalysisReadyWebAPI; -import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.sql.SQLException; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * Manages information going to the ResponseCache from Bukkit servers. - * - * @author Rsl1122 - */ -@Deprecated -public class BungeeInformationManager extends InformationManager { - - private final PlanBungee plugin; - private final BungeeServerInfo serverInfoManager; - private Map bukkitServers; - - public BungeeInformationManager(PlanBungee plugin) { - usingAnotherWebServer = false; - this.plugin = plugin; - serverInfoManager = plugin.getServerInfoManager(); - refreshBukkitServerMap(); - } - - /** - * Refreshes the Offline Bukkit server Map (UUID - Server Address Map) from DB. - * - * @throws SQLException If DB Error occurs. - */ - private void refreshBukkitServerMap() { - bukkitServers = plugin.getDB().getServerTable().getBukkitServers().stream().collect(Collectors.toMap(Server::getUuid, Function.identity())); - } - - /** - * Sends a "Refresh Analysis" WebAPI call to the appropriate Bukkit server. - *

- * if server is not online, api request will not be made. - * - * @param serverUUID Server UUID of the server in question. - */ - @Override - public void refreshAnalysis(UUID serverUUID) { - if (PlanBungee.getServerUUID().equals(serverUUID)) { - return; - } - Server server = getOnlineServerInfo(serverUUID); - if (server == null) { - return; - } - - AnalyzeWebAPI api = plugin.getWebServer().getWebAPI().getAPI(AnalyzeWebAPI.class); - try { - api.sendRequest(server.getWebAddress(), serverUUID); - } catch (ConnectionFailException e) { - attemptConnection(); - } catch (WebException e) { - Log.toLog(this.getClass().getName(), e); - } - } - - /** - * Attempts to get info of a server that is online. - *

- * Returns null if server doesn't exist. - * - * @param serverUUID UUID of server - * @return Online Server or null - */ - private Server getOnlineServerInfo(UUID serverUUID) { - Server server = bukkitServers.get(serverUUID); - if (server == null) { - try { - refreshBukkitServerMap(); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } - server = bukkitServers.get(serverUUID); - } - if (server == null) { - return null; - } - - if (serverInfoManager.getOnlineBukkitServers().contains(server) || serverInfoManager.attemptConnection(server)) { - return server; - } - return null; - } - - /** - * Attempts a connection to every Bukkit server in the database. - * - * @return true (always) - */ - @Override - public boolean attemptConnection() { - try { - List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); - for (Server server : bukkitServers) { - serverInfoManager.attemptConnection(server); - } - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } - return true; - } - - /** - * Get the Network page html. - * - * @return Html string (Full page) - */ - @Override - public String getAnalysisHtml() { - try { - return new NetworkPage(plugin).toHtml(); - } catch (ParseException e) { - return new InternalErrorResponse(e, this.getClass().getSimpleName()).getContent(); - } - } - - /** - * Shortcut for getting WebAPIManager - * - * @return WebAPIManager - */ - private WebAPIManager getWebAPI() { - return plugin.getWebServer().getWebAPI(); - } - - /** - * Get address of Bungee WebServer. - * - * @return URL String - */ - @Override - public String getWebServerAddress() { - return plugin.getWebServer().getAccessAddress(); - } - - /** - * Send notification of analysis being ready to all online bukkit servers via WebAPI. - * - * @param serverUUID UUID of a server which analysis is ready. - */ - @Override - public void analysisReady(UUID serverUUID) { - AnalysisReadyWebAPI api = getWebAPI().getAPI(AnalysisReadyWebAPI.class); - for (Server server : serverInfoManager.getOnlineBukkitServers()) { - try { - api.sendRequest(server.getWebAddress(), serverUUID); - } catch (WebException ignored) { - /*Ignored*/ - } - } - } - - public void sendConfigSettings() { - Collection online = serverInfoManager.getOnlineBukkitServers(); - online.stream().map(Server::getUuid) - .forEach(serverInfoManager::sendConfigSettings); - } - -} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java deleted file mode 100644 index 272c16825..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.systems.info; - -import com.djrapitops.plugin.command.ISender; - -import java.util.*; - -/** - * Abstract layer for Bukkit and Bungee Information managers. - *

- * Manages analysis notification sending. - * - * @author Rsl1122 - */ -@Deprecated -public abstract class InformationManager { - boolean usingAnotherWebServer; - String webServerAddress; - Map> analysisNotification; - - public InformationManager() { - analysisNotification = new HashMap<>(); - } - - public abstract boolean attemptConnection(); - - public String getLinkTo(String target) { - return getWebServerAddress() + target; - } - - public abstract void refreshAnalysis(UUID serverUUID); - - /** - * Used for /server on Bukkit and /network on Bungee - * - * @return Html of a page. - */ - public abstract String getAnalysisHtml(); - - public void addAnalysisNotification(ISender sender, UUID serverUUID) { - Set notify = analysisNotification.getOrDefault(serverUUID, new HashSet<>()); - notify.add(sender); - analysisNotification.put(serverUUID, notify); - } - - public boolean isUsingAnotherWebServer() { - return usingAnotherWebServer; - } - - public abstract String getWebServerAddress(); - - public boolean isAuthRequired() { - return getWebServerAddress().startsWith("https"); - } - - public abstract void analysisReady(UUID serverUUID); - -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java index 8f9be87e0..58a1c471c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/HtmlExport.java @@ -10,9 +10,11 @@ import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.webserver.response.pages.PlayersPageResponse; import com.djrapitops.plan.system.webserver.webapi.bungee.PostHtmlWebAPI; import com.djrapitops.plan.utilities.file.FileUtil; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.RunnableFactory; @@ -57,8 +59,7 @@ public class HtmlExport extends SpecificExport { @Override public void run() { try { - boolean usingAnotherWebServer = plugin.getInfoManager().isUsingAnotherWebServer(); - if (usingAnotherWebServer) { + if (Check.isBukkitAvailable() && ConnectionSystem.getInstance().isServerAvailable()) { return; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java b/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java index 1f5591dfe..6c65caf4d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java @@ -2,6 +2,7 @@ package com.djrapitops.plan.utilities.metrics; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; @@ -53,7 +54,7 @@ public class BStats { map.put("HTTPS", isEnabled("HTTPS".equals(plugin.getWebServer().getProtocol().toUpperCase()))); map.put("HTML Export", isEnabled(Settings.ANALYSIS_EXPORT.isTrue())); - boolean isConnectedToBungee = plugin.getInfoManager().isUsingAnotherWebServer(); + boolean isConnectedToBungee = ConnectionSystem.getInstance().isServerAvailable(); map.put("BungeeCord Connected", isEnabled(isConnectedToBungee)); if (isConnectedToBungee) { map.put("Copy Bungee Config Values", isEnabled(Settings.BUNGEE_COPY_CONFIG.isTrue())); diff --git a/Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java b/Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java index d24a84184..d434bcf1d 100644 --- a/Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java +++ b/Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java @@ -7,11 +7,14 @@ import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.connection.WebExceptionLogger; +import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.pages.DefaultResponses; import com.djrapitops.plan.system.webserver.response.cache.PageId; import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; -import com.djrapitops.plan.systems.info.BukkitInformationManager; +import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; +import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -182,7 +185,11 @@ public class API { */ @Deprecated public void updateAnalysisCache() { - plugin.getInfoManager().refreshAnalysis(plugin.getServerUuid()); + if (!Analysis.isAnalysisBeingRun()) { + WebExceptionLogger.logIfOccurs(this.getClass(), () -> + InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) + ); + } } /** @@ -195,7 +202,7 @@ public class API { */ @Deprecated public String getAnalysisHtmlAsString() { - return plugin.getInfoManager().getAnalysisHtml(); + return ResponseCache.loadResponse(PageId.SERVER.of(ServerInfo.getServerUUID()), AnalysisPageResponse::refreshNow).getContent(); } /** @@ -208,7 +215,7 @@ public class API { */ @Deprecated public AnalysisData getAnalysisDataFromCache() { - return ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisData(); + return new AnalysisData(); } /** diff --git a/Plan/test/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java b/Plan/test/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java index b6e1e5e9e..f2841cc14 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java @@ -7,8 +7,8 @@ package com.djrapitops.plan.data.additional.importer; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.time.GMTimes; -import com.djrapitops.plan.system.processing.processors.importing.ServerImportData; -import com.djrapitops.plan.system.processing.processors.importing.UserImportData; +import com.djrapitops.plan.system.processing.importing.ServerImportData; +import com.djrapitops.plan.system.processing.importing.UserImportData; import com.google.common.collect.ImmutableMap; import org.junit.Test; import test.utilities.RandomData;