From eeadbd2efb43689f8b0bd50602e2d484dab01daa Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 11 Jan 2018 16:19:30 +0200 Subject: [PATCH 001/166] Initial batch of refactoring: - Started constructing the new system to plan.system package - ProcessingQueue - VersionCheckSystem - ConfigSystem - getInstance accessor methods now check for null --- .../main/java/com/djrapitops/plan/Plan.java | 31 +- .../java/com/djrapitops/plan/PlanBungee.java | 33 +- .../plan/{api/IPlan.java => PlanPlugin.java} | 25 +- .../djrapitops/plan/ServerVariableHolder.java | 2 +- ...bleException.java => EnableException.java} | 6 +- .../plan/command/PlanBungeeCommand.java | 2 +- .../djrapitops/plan/command/PlanCommand.java | 4 +- .../plan/command/commands/AnalyzeCommand.java | 2 +- .../commands/BungeeSetupToggleCommand.java | 2 +- .../plan/command/commands/InfoCommand.java | 2 +- .../plan/command/commands/InspectCommand.java | 2 +- .../plan/command/commands/ListCommand.java | 4 +- .../command/commands/ListServersCommand.java | 8 +- .../plan/command/commands/ManageCommand.java | 2 +- .../plan/command/commands/NetworkCommand.java | 8 +- .../command/commands/QInspectCommand.java | 8 +- .../command/commands/RegisterCommand.java | 8 +- .../plan/command/commands/ReloadCommand.java | 8 +- .../plan/command/commands/SearchCommand.java | 2 +- .../plan/command/commands/WebUserCommand.java | 6 +- .../commands/manage/ManageBackupCommand.java | 2 +- .../commands/manage/ManageClearCommand.java | 2 +- .../commands/manage/ManageDisableCommand.java | 2 +- .../commands/manage/ManageHotswapCommand.java | 4 +- .../commands/manage/ManageImportCommand.java | 2 +- .../commands/manage/ManageMoveCommand.java | 2 +- .../commands/manage/ManageRemoveCommand.java | 2 +- .../commands/manage/ManageRestoreCommand.java | 2 +- .../commands/manage/ManageSetupCommand.java | 4 +- .../commands/webuser/WebCheckCommand.java | 8 +- .../commands/webuser/WebDeleteCommand.java | 8 +- .../commands/webuser/WebLevelCommand.java | 8 +- .../commands/webuser/WebListUsersCommand.java | 8 +- .../djrapitops/plan/data/AnalysisData.java | 4 +- .../djrapitops/plan/data/PlayerProfile.java | 10 +- .../djrapitops/plan/data/ServerProfile.java | 4 +- .../plan/data/element/HealthNotes.java | 2 +- .../data/plugin/PluginsConfigSection.java | 2 +- .../plan/database/databases/MySQLDB.java | 2 +- .../plan/database/databases/SQLiteDB.java | 2 +- .../plan/database/tables/TPSTable.java | 6 +- .../plan/database/tables/UserInfoTable.java | 4 +- .../plan/database/tables/WorldTable.java | 2 +- .../plan/settings/ServerSpecificSettings.java | 1 + .../plan/settings/WorldAliasSettings.java | 3 +- .../plan/settings/locale/Locale.java | 49 +-- .../plan/settings/theme/PlanColorScheme.java | 2 +- .../djrapitops/plan/settings/theme/Theme.java | 18 +- .../plan/settings/theme/ThemeConfig.java | 6 +- .../djrapitops/plan/system/PlanSystem.java | 97 ++++++ .../com/djrapitops/plan/system/SubSystem.java | 28 ++ .../{systems => system}/file/FileSystem.java | 24 +- .../processing}/ProcessingQueue.java | 50 ++- .../{ => system}/settings/Permissions.java | 2 +- .../plan/{ => system}/settings/Settings.java | 5 +- .../settings/config/BukkitConfigSystem.java} | 11 +- .../settings/config/BungeeConfigSystem.java} | 11 +- .../system/settings/config/ConfigSystem.java | 81 +++++ .../update/VersionCheckSystem.java | 17 +- .../djrapitops/plan/systems/SubSystem.java | 20 -- .../com/djrapitops/plan/systems/Systems.java | 19 +- .../plan/systems/cache/GeolocationCache.java | 2 +- .../systems/file/config/ConfigSystem.java | 58 ---- .../plan/systems/file/database/DBSystem.java | 10 +- .../systems/file/database/PlanDBSystem.java | 2 +- .../info/BukkitInformationManager.java | 2 +- .../info/BungeeInformationManager.java | 4 +- .../info/parsing/AnalysisPageParser.java | 6 +- .../info/parsing/InspectPageParser.java | 10 +- .../info/parsing/NetworkPageParser.java | 2 +- .../info/server/BukkitServerInfoManager.java | 8 +- .../info/server/BungeeServerInfoManager.java | 10 +- .../PlanCommandPreprocessListener.java | 4 +- .../plan/systems/processing/Processor.java | 10 + .../processing/TPSInsertProcessor.java | 2 +- .../info/InspectCacheRequestProcessor.java | 4 +- .../systems/tasks/PlanBungeeTaskSystem.java | 2 +- .../plan/systems/tasks/PlanTaskSystem.java | 4 +- .../plan/systems/tasks/TPSCountTimer.java | 6 +- .../plan/systems/tasks/TaskSystem.java | 6 +- .../systems/webserver/APIRequestHandler.java | 2 +- .../systems/webserver/APIResponseHandler.java | 6 +- .../systems/webserver/RequestHandler.java | 6 +- .../systems/webserver/ResponseHandler.java | 8 +- .../plan/systems/webserver/WebServer.java | 8 +- .../systems/webserver/WebServerSystem.java | 12 +- .../webserver/response/DebugPageResponse.java | 8 +- .../response/PlayersPageResponse.java | 6 +- .../plan/systems/webserver/webapi/WebAPI.java | 10 +- .../webapi/bukkit/AnalysisReadyWebAPI.java | 4 +- .../webapi/bukkit/AnalyzeWebAPI.java | 4 +- .../webapi/bukkit/ConfigurationWebAPI.java | 6 +- .../webapi/bukkit/InspectWebAPI.java | 4 +- .../webapi/bukkit/IsOnlineWebAPI.java | 4 +- .../RequestInspectPluginsTabBukkitWebAPI.java | 4 +- .../webapi/bungee/IsCachedWebAPI.java | 4 +- .../webapi/bungee/PostHtmlWebAPI.java | 6 +- .../bungee/PostInspectPluginsTabWebAPI.java | 4 +- .../bungee/PostNetworkPageContentWebAPI.java | 4 +- .../PostOriginalBukkitSettingsWebAPI.java | 6 +- .../bungee/RequestPluginsTabWebAPI.java | 6 +- .../webapi/bungee/RequestSetupWebAPI.java | 4 +- .../webapi/universal/PingWebAPI.java | 6 +- .../plan/utilities/FormatUtils.java | 2 +- .../djrapitops/plan/utilities/MiscUtils.java | 16 +- .../djrapitops/plan/utilities/NullCheck.java | 22 ++ .../plan/utilities/analysis/Analysis.java | 2 +- .../utilities/analysis/AnalysisUtils.java | 4 +- .../plan/utilities/file/FileUtil.java | 10 +- .../utilities/file/export/HtmlExport.java | 10 +- .../utilities/file/export/SpecificExport.java | 6 +- .../plan/utilities/html/HtmlStructure.java | 2 +- .../plan/utilities/html/HtmlUtils.java | 6 +- .../utilities/html/graphs/pie/WorldPie.java | 2 +- .../structure/SessionTabStructureCreator.java | 2 +- .../html/tables/PlayersTableCreator.java | 4 +- .../html/tables/SessionsTableCreator.java | 2 +- .../plan/utilities/metrics/BStats.java | 2 +- .../plan/utilities/uuid/UUIDUtility.java | 2 +- .../com/djrapitops/plan/PermissionsTest.java | 2 +- .../com/djrapitops/plan/SettingsTest.java | 2 +- .../plan/data/PlayerProfileTest.java | 2 +- .../plan/utilities/export/HastebinTest.java | 2 +- .../main/java/test/utilities/TestInit.java | 2 +- Plan/test/test/java/utils/DBTestSuite.java | 51 --- Plan/test/test/java/utils/MockUtils.java | 216 ------------- Plan/test/test/java/utils/RandomData.java | 77 ----- Plan/test/test/java/utils/TestInit.java | 297 ------------------ Plan/test/test/java/utils/TestUtils.java | 18 -- 129 files changed, 649 insertions(+), 1099 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/{api/IPlan.java => PlanPlugin.java} (62%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{PlanEnableException.java => EnableException.java} (69%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/SubSystem.java rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/file/FileSystem.java (66%) rename Plan/src/main/java/com/djrapitops/plan/{systems/queue => system/processing}/ProcessingQueue.java (53%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/Permissions.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/Settings.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems/file/config/PlanConfigSystem.java => system/settings/config/BukkitConfigSystem.java} (60%) rename Plan/src/main/java/com/djrapitops/plan/{systems/file/config/PlanBungeeConfigSystem.java => system/settings/config/BungeeConfigSystem.java} (61%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/update/VersionCheckSystem.java (78%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/SubSystem.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/file/config/ConfigSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java delete mode 100644 Plan/test/test/java/utils/DBTestSuite.java delete mode 100644 Plan/test/test/java/utils/MockUtils.java delete mode 100644 Plan/test/test/java/utils/RandomData.java delete mode 100644 Plan/test/test/java/utils/TestInit.java delete mode 100644 Plan/test/test/java/utils/TestUtils.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 108f80c4f0..b0d311b8bb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -20,12 +20,11 @@ package com.djrapitops.plan; import com.djrapitops.plan.api.API; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.api.exceptions.PlanEnableException; +import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.command.PlanCommand; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; @@ -33,8 +32,8 @@ import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.GeolocationCache; -import com.djrapitops.plan.systems.file.FileSystem; -import com.djrapitops.plan.systems.file.config.ConfigSystem; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.ImporterManager; @@ -43,9 +42,9 @@ import com.djrapitops.plan.systems.listeners.*; import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plan.systems.processing.importing.importers.OfflinePlayerImporter; -import com.djrapitops.plan.systems.queue.ProcessingQueue; +import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.systems.update.VersionCheckSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.webserver.WebServer; import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plan.systems.webserver.pagecache.PageCache; @@ -78,7 +77,7 @@ * @author Rsl1122 * @since 1.0.0 */ -public class Plan extends BukkitPlugin implements IPlan { +public class Plan extends BukkitPlugin implements PlanPlugin { private API api; @@ -135,12 +134,12 @@ public void onEnable() { super.onEnable(); try { systems = new Systems(this); - FileSystem.getInstance().init(); - ConfigSystem.getInstance().init(); + FileSystem.getInstance().enable(); + ConfigSystem.getInstance().enable(); Log.setDebugMode(Settings.DEBUG.toString()); - VersionCheckSystem.getInstance().init(); + VersionCheckSystem.getInstance().enable(); Benchmark.start("Enable"); @@ -149,25 +148,25 @@ public void onEnable() { } catch (UnknownHostException e) { Log.error("Plan Requires internet access on first run to download GeoLite2 Geolocation database."); } catch (IOException e) { - throw new PlanEnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e); + throw new EnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e); } new Locale().loadLocale(); - Theme.getInstance().init(); + Theme.getInstance().enable(); Benchmark.start("Reading server variables"); serverVariableHolder = new ServerVariableHolder(getServer()); Benchmark.stop("Enable", "Reading server variables"); - DBSystem.getInstance().init(); + DBSystem.getInstance().enable(); Benchmark.start("WebServer Initialization"); processingQueue = new ProcessingQueue(); serverInfoManager = new BukkitServerInfoManager(this); infoManager = new BukkitInformationManager(this); - WebServerSystem.getInstance().init(); + WebServerSystem.getInstance().enable(); if (!WebServerSystem.isWebServerEnabled()) { if (Settings.WEBSERVER_DISABLED.isTrue()) { Log.warn("WebServer was not initialized. (WebServer.DisableWebServer: true)"); @@ -186,7 +185,7 @@ public void onEnable() { } PlanPlayerListener.setCountKicks(true); - TaskSystem.getInstance().init(); + TaskSystem.getInstance().enable(); this.api = new API(this); diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index af170eb8b8..a521c7d9ef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -4,26 +4,25 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.api.IPlan; import com.djrapitops.plan.command.PlanBungeeCommand; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.systems.Systems; -import com.djrapitops.plan.systems.file.FileSystem; -import com.djrapitops.plan.systems.file.config.ConfigSystem; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.listeners.BungeePlayerListener; import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.systems.queue.ProcessingQueue; +import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.systems.update.VersionCheckSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.webserver.WebServer; import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; @@ -45,13 +44,13 @@ * * @author Rsl1122 */ -public class PlanBungee extends BungeePlugin implements IPlan { +public class PlanBungee extends BungeePlugin implements PlanPlugin { private Systems systems; private BungeeServerInfoManager serverInfoManager; private BungeeInformationManager infoManager; - private com.djrapitops.plan.ServerVariableHolder variableHolder; + private ServerVariableHolder variableHolder; private ProcessingQueue processingQueue; @@ -62,19 +61,19 @@ public void onEnable() { super.onEnable(); try { systems = new Systems(this); - FileSystem.getInstance().init(); - ConfigSystem.getInstance().init(); + FileSystem.getInstance().enable(); + ConfigSystem.getInstance().enable(); Log.setDebugMode(Settings.DEBUG.toString()); - VersionCheckSystem.getInstance().init(); + VersionCheckSystem.getInstance().enable(); - variableHolder = new com.djrapitops.plan.ServerVariableHolder(getProxy()); + variableHolder = new ServerVariableHolder(getProxy()); new Locale().loadLocale(); - Theme.getInstance().init(); - DBSystem.getInstance().init(); + Theme.getInstance().enable(); + DBSystem.getInstance().enable(); String ip = variableHolder.getIp(); if ("0.0.0.0".equals(ip)) { @@ -88,10 +87,10 @@ public void onEnable() { serverInfoManager = new BungeeServerInfoManager(this); infoManager = new BungeeInformationManager(this); - WebServerSystem.getInstance().init(); + WebServerSystem.getInstance().enable(); serverInfoManager.loadServerInfo(); - TaskSystem.getInstance().init(); + TaskSystem.getInstance().enable(); processingQueue = new ProcessingQueue(); @@ -188,7 +187,7 @@ public ColorScheme getColorScheme() { } @Override - public com.djrapitops.plan.ServerVariableHolder getVariable() { + public ServerVariableHolder getVariable() { return variableHolder; } diff --git a/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java similarity index 62% rename from Plan/src/main/java/com/djrapitops/plan/api/IPlan.java rename to Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 53c27e9b05..efc80648f8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -1,17 +1,17 @@ -/* +/* * 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; +package com.djrapitops.plan; -import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.database.Database; +import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.systems.queue.ProcessingQueue; import com.djrapitops.plan.systems.webserver.WebServer; import com.djrapitops.plugin.IPlugin; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.settings.ColorScheme; @@ -24,7 +24,7 @@ * * @author Rsl1122 */ -public interface IPlan extends IPlugin { +public interface PlanPlugin extends IPlugin { Database getDB(); ServerVariableHolder getVariable(); @@ -48,4 +48,19 @@ public interface IPlan extends IPlugin { ColorScheme getColorScheme(); Systems getSystems(); + + boolean isReloading(); + + static PlanPlugin getInstance() { + boolean bukkitAvailable = Check.isBukkitAvailable(); + boolean bungeeAvailable = Check.isBungeeAvailable(); + if (bukkitAvailable && bungeeAvailable) { + // TODO Test Plugin + } else if (bungeeAvailable) { + return Plan.getInstance(); + } else if (bukkitAvailable) { + return PlanBungee.getInstance(); + } + throw new IllegalAccessError("Plugin instance not available"); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java b/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java index 3b3ed362ab..6dabe79955 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java +++ b/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java @@ -1,6 +1,6 @@ package com.djrapitops.plan; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import net.md_5.bungee.api.ProxyServer; import org.bukkit.Server; diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PlanEnableException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/EnableException.java similarity index 69% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/PlanEnableException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/EnableException.java index 46888e8ffb..3ecaa5fb25 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PlanEnableException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/EnableException.java @@ -9,13 +9,13 @@ * * @author Rsl1122 */ -public class PlanEnableException extends Exception { +public class EnableException extends Exception { - public PlanEnableException(String message, Throwable cause) { + public EnableException(String message, Throwable cause) { super(message, cause); } - public PlanEnableException(String message) { + public EnableException(String message) { super(message); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java index b2907fd3a6..eed4c92ed3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.command.commands.*; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java index 1247c9ca75..7e5974d79e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java @@ -2,8 +2,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.commands.*; -import com.djrapitops.plan.settings.Permissions; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 493ddd68e9..647080f930 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.info.InformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java index 25db2b3be8..90e532e9a8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java index a5221fa006..bddbe26eaf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 24efbe4e75..d4dbc3f28f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.ConditionUtils; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor; 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 f385c96c70..7406733657 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,6 +1,6 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.MiscUtils; @@ -43,7 +43,7 @@ private void sendListMsg(ISender sender) { sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse()); // Link - String url = MiscUtils.getIPlan().getInfoManager().getLinkTo("/players/"); + String url = PlanPlugin.getInstance().getInfoManager().getLinkTo("/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/ListServersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java index 6efc95d4ee..a7ebd34e78 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.api.utility.log.Log; @@ -21,14 +21,14 @@ */ public class ListServersCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; /** * Subcommand constructor. * * @param plugin Current instance of Plan */ - public ListServersCommand(IPlan plugin) { + public ListServersCommand(PlanPlugin plugin) { super("servers, serverlist, listservers, sl", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java index 28fe8f3f7c..04926184a9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.commands.manage.*; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; 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 1b473e9d33..7c56b3bed1 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 @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; @@ -19,12 +19,12 @@ */ public class NetworkCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; /** * Class Constructor. */ - public NetworkCommand(IPlan plugin) { + public NetworkCommand(PlanPlugin plugin) { super("network, n, netw", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java index 0af0d93481..adc69d7348 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; @@ -30,14 +30,14 @@ */ public class QInspectCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; /** * Class Constructor. * * @param plugin Current instance of Plan */ - public QInspectCommand(IPlan plugin) { + public QInspectCommand(PlanPlugin plugin) { super("qinspect", CommandType.PLAYER_OR_ARGS, Permissions.QUICK_INSPECT.getPermission(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index 97e17055a3..60dd3f858b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; @@ -31,9 +31,9 @@ */ public class RegisterCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; - public RegisterCommand(IPlan plugin) { + public RegisterCommand(PlanPlugin plugin) { super("register", CommandType.PLAYER_OR_ARGS, "", // No Permission Requirement diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java index 0ed5dc405a..f7f480aad6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.api.utility.log.Log; @@ -17,14 +17,14 @@ */ public class ReloadCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; /** * Subcommand constructor. * * @param plugin Current instance of Plan */ - public ReloadCommand(IPlan plugin) { + public ReloadCommand(PlanPlugin plugin) { super("reload", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java index 15bdf37606..9e6f468eba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java index 72540429ac..94b66e4b00 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java @@ -2,12 +2,12 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.command.commands.webuser.WebCheckCommand; import com.djrapitops.plan.command.commands.webuser.WebDeleteCommand; import com.djrapitops.plan.command.commands.webuser.WebLevelCommand; import com.djrapitops.plan.command.commands.webuser.WebListUsersCommand; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; @@ -19,7 +19,7 @@ * @author Rsl1122 * @since 3.5.2 */ -public class WebUserCommand extends TreeCommand { +public class WebUserCommand extends TreeCommand { public WebUserCommand(Plan plugin, RegisterCommand register) { super(plugin, "webuser, web", diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java index 5c05d1ef79..19543b7c46 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java @@ -3,7 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index 3df462979b..ded89d2c69 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -4,7 +4,7 @@ import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.cache.DataCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java index b73515bb00..c08be9927e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.command.commands.manage; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.listeners.PlanPlayerListener; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index 6c8263f40d..162b61acef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -2,8 +2,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Permissions; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; 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 68fee6e8b2..6ecaf7c186 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 @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.info.ImporterManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java index c096670074..9195b96a8a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 4823bd0a39..42a4695501 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.cache.DataCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index b5857ade38..6e2219a37e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -3,7 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.database.Database; import com.djrapitops.plan.database.databases.SQLiteDB; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 73931ea71d..f31722cd7e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -3,8 +3,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPIForbiddenException; -import com.djrapitops.plan.settings.Permissions; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.webserver.webapi.bungee.RequestSetupWebAPI; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java index c5864cb865..1c328ca843 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands.webuser; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; @@ -23,9 +23,9 @@ */ public class WebCheckCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; - public WebCheckCommand(IPlan plugin) { + public WebCheckCommand(PlanPlugin plugin) { super("check", CommandType.PLAYER_OR_ARGS, Permissions.MANAGE_WEB.getPerm(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java index 2262b267d4..d24a2a8d2b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands.webuser; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; @@ -22,9 +22,9 @@ */ public class WebDeleteCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; - public WebDeleteCommand(IPlan plugin) { + public WebDeleteCommand(PlanPlugin plugin) { super("delete, remove", CommandType.PLAYER_OR_ARGS, Permissions.MANAGE_WEB.getPerm(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java index 879b66476f..95464a7bfd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands.webuser; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; @@ -17,9 +17,9 @@ */ public class WebLevelCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; - public WebLevelCommand(IPlan plugin) { + public WebLevelCommand(PlanPlugin plugin) { super("level", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java index 689b61fe74..a6a4e8e7f1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands.webuser; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.utilities.comparators.WebUserComparator; @@ -24,9 +24,9 @@ */ public class WebListUsersCommand extends SubCommand { - private final IPlan plugin; + private final PlanPlugin plugin; - public WebListUsersCommand(IPlan plugin) { + public WebListUsersCommand(PlanPlugin plugin) { super("list", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), "List registered web users & permission levels."); this.plugin = plugin; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java index 3aee89fa30..af3ad3e968 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.data.element.HealthNotes; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; @@ -66,7 +66,7 @@ public void parsePluginsSection(Map containers) { } private void addConstants() { - addValue("version", MiscUtils.getIPlan().getVersion()); + addValue("version", PlanPlugin.getInstance().getVersion()); addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE)); addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE)); addValue("serverName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index fd75a57735..3ff1165f01 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.comparators.ActionComparator; import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; @@ -410,7 +410,7 @@ public void setSessions(Map> sessions) { } public void addActiveSession(Session activeSession) { - UUID serverUUID = MiscUtils.getIPlan().getServerUuid(); + UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); List sessions = getSessions(serverUUID); sessions.add(activeSession); this.sessions.put(serverUUID, sessions); @@ -553,7 +553,7 @@ public long getFirstPlayed() { @Override public long getLastPlayed() { - return getLastSeen(MiscUtils.getIPlan().getServerUuid()); + return getLastSeen(PlanPlugin.getInstance().getServerUuid()); } @Override @@ -573,7 +573,7 @@ public Map serialize() { @Override public boolean isOp() { - return oppedOnServers.contains(MiscUtils.getIPlan().getServerUuid()); + return oppedOnServers.contains(PlanPlugin.getInstance().getServerUuid()); } @Override @@ -582,7 +582,7 @@ public void setOp(boolean b) { } public void calculateWorldTimesPerServer() { - if (worldTimesMap.containsKey(MiscUtils.getIPlan().getServerUuid())) { + if (worldTimesMap.containsKey(PlanPlugin.getInstance().getServerUuid())) { return; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java index 09fde39390..aba72ac2ce 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java @@ -11,7 +11,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; @@ -295,7 +295,7 @@ public static int getPlayersOnline() { } public static int getPlayersMax() { - return MiscUtils.getIPlan().getVariable().getMaxPlayers(); + return PlanPlugin.getInstance().getVariable().getMaxPlayers(); } public Stream getOps() { diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java b/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java index 9685964942..710942da5e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.container.StickyData; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java index aa00b0310d..598e1bc001 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.data.plugin; -import com.djrapitops.plan.systems.file.config.ConfigSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.config.ConfigNode; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java index 9d9c75e497..2ea9c55f4e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.database.databases; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.dbcp2.BasicDataSource; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java index 90468f3f97..c8380ad43a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java @@ -55,7 +55,7 @@ public Connection getNewConnection(String dbName) throws SQLException { return null; // Should never happen. } - String dbFilePath = new File(MiscUtils.getIPlan().getDataFolder(), dbName + ".db").getAbsolutePath(); + String dbFilePath = new File(PlanPlugin.getInstance().getDataFolder(), dbName + ".db").getAbsolutePath(); Connection connection; try { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/TPSTable.java index e144d4ae9f..d24549fd57 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/TPSTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/TPSTable.java @@ -76,7 +76,7 @@ public void createTable() throws DBCreateTableException { * @return @throws SQLException */ public List getTPSData() throws SQLException { - return getTPSData(MiscUtils.getIPlan().getServerUuid()); + return getTPSData(PlanPlugin.getInstance().getServerUuid()); } public List getTPSData(UUID serverUUID) throws SQLException { @@ -112,7 +112,7 @@ public void insertTPS(TPS tps) throws SQLException { execute(new ExecStatement(insertStatement) { @Override public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, MiscUtils.getIPlan().getServerUuid().toString()); + statement.setString(1, PlanPlugin.getInstance().getServerUuid().toString()); statement.setLong(2, tps.getDate()); statement.setDouble(3, tps.getTicksPerSecond()); statement.setInt(4, tps.getPlayers()); @@ -162,7 +162,7 @@ public Optional getAllTimePeak() throws SQLException { } public Optional getPeakPlayerCount(long afterDate) throws SQLException { - return getPeakPlayerCount(MiscUtils.getIPlan().getServerUuid(), afterDate); + return getPeakPlayerCount(PlanPlugin.getInstance().getServerUuid(), afterDate); } public Optional getPeakPlayerCount(UUID serverUUID, long afterDate) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java index 14ecd642f0..dbdb316eb5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java @@ -83,7 +83,7 @@ public void prepare(PreparedStatement statement) throws SQLException { } public boolean isRegistered(UUID uuid) throws SQLException { - return isRegistered(uuid, MiscUtils.getIPlan().getServerUuid()); + return isRegistered(uuid, PlanPlugin.getInstance().getServerUuid()); } public boolean isRegistered(UUID uuid, UUID serverUUID) throws SQLException { @@ -122,7 +122,7 @@ public void prepare(PreparedStatement statement) throws SQLException { } public UserInfo getUserInfo(UUID uuid) throws SQLException { - return getAllUserInfo(uuid).get(MiscUtils.getIPlan().getServerUuid()); + return getAllUserInfo(uuid).get(PlanPlugin.getInstance().getServerUuid()); } public Map getAllUserInfo(UUID uuid) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java index ec9a8e53e5..80be4ca9ec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java @@ -114,7 +114,7 @@ public String getColumnWorldName() { } public Set getWorldNames() throws SQLException { - return getWorldNames(MiscUtils.getIPlan().getServerUuid()); + return getWorldNames(PlanPlugin.getInstance().getServerUuid()); } public Set getWorldNames(UUID serverUUID) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java index 416894c336..b1bbdf22a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java b/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java index fcc51ecce5..d64cf6ad56 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java @@ -4,7 +4,8 @@ */ package com.djrapitops.plan.settings; -import com.djrapitops.plan.systems.file.config.ConfigSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.config.ConfigNode; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java index edba744461..2dfca4158f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java @@ -1,10 +1,11 @@ package com.djrapitops.plan.settings.locale; -import com.djrapitops.plan.settings.Permissions; -import com.djrapitops.plan.settings.Settings; -import com.djrapitops.plan.systems.file.FileSystem; -import com.djrapitops.plan.systems.file.config.ConfigSystem; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plan.utilities.comparators.LocaleEntryComparator; import com.djrapitops.plan.utilities.comparators.StringLengthComparator; import com.djrapitops.plan.utilities.file.FileUtil; @@ -40,24 +41,21 @@ public class Locale { private final Map messages; public Locale() { - LocaleHolder.setLocale(this); messages = new EnumMap<>(Msg.class); } - public static void unload() { - Locale locale = LocaleHolder.getLocale(); - if (locale != null) { - locale.messages.clear(); - LocaleHolder.locale = null; - } + public void unload() { + messages.clear(); + } + + public static Locale getInstance() { + Locale locale = ConfigSystem.getInstance().getLocale(); + NullCheck.check(locale, new IllegalStateException("Locale has not been initialized.")); + return locale; } public static Message get(Msg msg) { - Locale locale = LocaleHolder.getLocale(); - if (locale == null) { - throw new IllegalStateException("Locale has not been initialized."); - } - return locale.getMessage(msg); + return getInstance().getMessage(msg); } public void loadLocale() { @@ -120,7 +118,7 @@ private void loadDefault() { String yellow = "§e"; String red = "§c"; String arrowsRight = DefaultMessages.ARROWS_RIGHT.parse(); - ColorScheme cs = MiscUtils.getIPlan().getColorScheme(); + ColorScheme cs = PlanPlugin.getInstance().getColorScheme(); String mCol = cs.getMainColor(); String sCol = cs.getSecondaryColor(); String tCol = cs.getTertiaryColor(); @@ -342,21 +340,4 @@ private void loadFromContents(List locale, String name) { public Message getMessage(Msg msg) { return messages.getOrDefault(msg, new Message("")); } - - private static class LocaleHolder { - - private static Locale locale; - - private LocaleHolder() { - throw new IllegalStateException("Static variable holder class"); - } - - public static Locale getLocale() { - return locale; - } - - public static void setLocale(Locale locale) { - LocaleHolder.locale = locale; - } - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/PlanColorScheme.java b/Plan/src/main/java/com/djrapitops/plan/settings/theme/PlanColorScheme.java index 9dfcee5c1a..b2d103b51f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/PlanColorScheme.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/theme/PlanColorScheme.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.settings.theme; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.settings.ColorScheme; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java b/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java index 32f0c0af7c..41175780e3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java @@ -4,10 +4,12 @@ */ package com.djrapitops.plan.settings.theme; -import com.djrapitops.plan.api.exceptions.PlanEnableException; -import com.djrapitops.plan.settings.Settings; -import com.djrapitops.plan.systems.SubSystem; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.systems.Systems; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.EnumUtility; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -27,21 +29,23 @@ public class Theme implements SubSystem { private ThemeConfig config; public static Theme getInstance() { - return Systems.getInstance().getThemeSystem(); + Theme themeSystem = ConfigSystem.getInstance().getThemeSystem(); + NullCheck.check(themeSystem, new IllegalStateException("Theme System has not been initialized.")); + return themeSystem; } @Override - public void init() throws PlanEnableException { + public void enable() throws EnableException { String themeName = Settings.THEME_BASE.toString(); try { config = new ThemeConfig(themeName); } catch (IOException e) { - throw new PlanEnableException("Default theme could not be loaded.", e); + throw new EnableException("Default theme could not be loaded.", e); } } @Override - public void close() { + public void disable() { } diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java b/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java index aeff185d09..df1d5e131d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.settings.theme; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.api.config.Config; @@ -33,7 +33,7 @@ public ThemeConfig(String fileName) throws IOException { private static List getDefaults(String fileName) throws IOException { String fileLocation = getFileLocation(fileName); - IPlan plugin = MiscUtils.getIPlan(); + PlanPlugin plugin = PlanPlugin.getInstance(); try { return FileUtil.lines(plugin, fileLocation); } catch (IOException e) { @@ -71,7 +71,7 @@ private static String getFileLocation(String fileName) { private static File getConfigFile() throws IOException { - File folder = MiscUtils.getIPlan().getDataFolder(); + File folder = PlanPlugin.getInstance().getDataFolder(); if (!folder.exists()) { folder.mkdirs(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java new file mode 100644 index 0000000000..5b0c8f0bc2 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -0,0 +1,97 @@ +/* + * 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; + +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.update.VersionCheckSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.Check; + +/** + * PlanSystem contains everything Plan needs to run. + *

+ * This is an abstraction layer on top of Plugin instances so that tests can be run with less mocks. + * + * @author Rsl1122 + */ +public abstract class PlanSystem implements SubSystem { + + // Initialized in this class + protected final ProcessingQueue processingQueue; + + // These need to be initialized in the sub class. + protected VersionCheckSystem versionCheckSystem; + protected FileSystem fileSystem; + protected ConfigSystem configSystem; + + public PlanSystem() { + processingQueue = new ProcessingQueue(); + } + + @Override + public void enable() throws EnableException { + checkSubSystemInitialization(); + + versionCheckSystem.enable(); + configSystem.enable(); + processingQueue.enable(); + } + + @Override + public void disable() { + processingQueue.disable(); + configSystem.disable(); + versionCheckSystem.disable(); + } + + public void reload() throws EnableException { + checkSubSystemInitialization(); + configSystem.reload(); + } + + private void checkSubSystemInitialization() throws EnableException { + try { + NullCheck.check(versionCheckSystem, new IllegalStateException("Version Check system was not initialized.")); + NullCheck.check(fileSystem, new IllegalStateException("File system was not initialized.")); + NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized.")); + } catch (Exception e) { + throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e); + } + } + + public static PlanSystem getInstance() { + boolean bukkitAvailable = Check.isBukkitAvailable(); + boolean bungeeAvailable = Check.isBungeeAvailable(); + if (bukkitAvailable && bungeeAvailable) { + // TODO test system. + } else if (bungeeAvailable) { + // todo bungee + } else { + // Todo bukkit + } + throw new IllegalAccessError("PlanSystem is not available on this platform."); + } + + // Accessor methods. + + public ProcessingQueue getProcessingQueue() { + return processingQueue; + } + + public VersionCheckSystem getVersionCheckSystem() { + return versionCheckSystem; + } + + public ConfigSystem getConfigSystem() { + return configSystem; + } + + public FileSystem getFileSystem() { + return fileSystem; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/SubSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/SubSystem.java new file mode 100644 index 0000000000..be8b9be910 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/SubSystem.java @@ -0,0 +1,28 @@ +/* + * 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; + +import com.djrapitops.plan.api.exceptions.EnableException; + +/** + * Represents a system that can be enabled and disabled. + * + * @author Rsl1122 + */ +public interface SubSystem { + + /** + * Performs enable actions for the subsystem. + * + * @throws EnableException If an error occurred during enable and it is fatal to the subsystem. + */ + void enable() throws EnableException; + + /** + * Performs disable actions for the subsystem + */ + void disable(); + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/FileSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/file/FileSystem.java similarity index 66% rename from Plan/src/main/java/com/djrapitops/plan/systems/file/FileSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/file/FileSystem.java index 2b2de19165..45bfd90755 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/FileSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/file/FileSystem.java @@ -2,12 +2,12 @@ * 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.file; +package com.djrapitops.plan.system.file; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.systems.SubSystem; -import com.djrapitops.plan.systems.Systems; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plan.utilities.file.FileUtil; import java.io.File; @@ -24,16 +24,19 @@ public class FileSystem implements SubSystem { private final File dataFolder; private File configFile; - public FileSystem(IPlan plugin) { + public FileSystem(PlanPlugin plugin) { this(plugin.getDataFolder()); } public FileSystem(File dataFolder) { this.dataFolder = dataFolder; + configFile = new File(dataFolder, "config.yml"); } public static FileSystem getInstance() { - return Systems.getInstance().getFileSystem(); + FileSystem fileSystem = PlanSystem.getInstance().getFileSystem(); + NullCheck.check(fileSystem, new IllegalStateException("File system was not initialized.")); + return fileSystem; } public static File getDataFolder() { @@ -49,17 +52,16 @@ public static File getLocaleFile() { } public static List readFromResource(String fileName) throws IOException { - return FileUtil.lines(MiscUtils.getIPlan(), fileName); + return FileUtil.lines(PlanPlugin.getInstance(), fileName); } @Override - public void init() { + public void enable() { dataFolder.mkdirs(); - configFile = new File(dataFolder, "config.yml"); } @Override - public void close() { + public void disable() { } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/queue/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java similarity index 53% rename from Plan/src/main/java/com/djrapitops/plan/systems/queue/ProcessingQueue.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index ea95fe833c..d7c35a7c84 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/queue/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -1,9 +1,20 @@ -package com.djrapitops.plan.systems.queue; +package com.djrapitops.plan.system.processing; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.systems.processing.Processor; +import com.djrapitops.plan.systems.queue.Consumer; +import com.djrapitops.plan.systems.queue.Queue; +import com.djrapitops.plan.systems.queue.Setup; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; +import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.task.AbsRunnable; +import com.djrapitops.plugin.task.RunnableFactory; +import java.util.List; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -14,17 +25,46 @@ * @author Rsl1122 * @since 3.0.0 */ -public class ProcessingQueue extends Queue { +public class ProcessingQueue extends Queue implements SubSystem { - /** - * Class constructor, starts the new Thread for processing. - */ public ProcessingQueue() { super(new ArrayBlockingQueue<>(20000)); setup = new ProcessSetup(queue); + } + + public static ProcessingQueue getInstance() { + ProcessingQueue processingQueue = PlanSystem.getInstance().getProcessingQueue(); + NullCheck.check(processingQueue, new IllegalStateException("ProcessingQueue has not been initialized.")); + return processingQueue; + } + + @Override + public void enable() { setup.go(); } + @Override + public void disable() { + List processors = stopAndReturnLeftovers(); + if (PlanPlugin.getInstance().isReloading()) { + RunnableFactory.createNew("Re-Add processors", new AbsRunnable() { + @Override + public void run() { + ProcessingQueue que = ProcessingQueue.getInstance(); + for (Processor processor : processors) { + que.addToQueue(processor); + } + cancel(); + } + }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L); + } else { + Log.info("Processing unprocessed processors. (" + processors.size() + ")"); + for (Processor processor : processors) { + processor.process(); + } + } + } + /** * Used to add Processor object to be processed. * diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/Permissions.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Permissions.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/settings/Permissions.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/Permissions.java index 05eb804c7b..8bba3e14af 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/Permissions.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Permissions.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.settings; +package com.djrapitops.plan.system.settings; /** * Permissions class is used easily check every permission node. diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/settings/Settings.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index ae1eeca8b4..0b38a1eeec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -1,6 +1,7 @@ -package com.djrapitops.plan.settings; +package com.djrapitops.plan.system.settings; -import com.djrapitops.plan.systems.file.config.ConfigSystem; +import com.djrapitops.plan.settings.ServerSpecificSettings; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.config.Config; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/config/PlanConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java similarity index 60% rename from Plan/src/main/java/com/djrapitops/plan/systems/file/config/PlanConfigSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java index 61959f718e..23aedbdb11 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/config/PlanConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java @@ -2,10 +2,11 @@ * 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.file.config; +package com.djrapitops.plan.system.settings.config; -import com.djrapitops.plan.systems.file.FileSystem; +import com.djrapitops.plan.system.file.FileSystem; +import java.io.File; import java.io.IOException; /** @@ -13,7 +14,11 @@ * * @author Rsl1122 */ -public class PlanConfigSystem extends ConfigSystem { +public class BukkitConfigSystem extends ConfigSystem { + + public BukkitConfigSystem(File configFile) { + super(configFile); + } @Override protected void copyDefaults() throws IOException { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/config/PlanBungeeConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java similarity index 61% rename from Plan/src/main/java/com/djrapitops/plan/systems/file/config/PlanBungeeConfigSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java index 50b925f7aa..1948bd052d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/config/PlanBungeeConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java @@ -2,10 +2,11 @@ * 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.file.config; +package com.djrapitops.plan.system.settings.config; -import com.djrapitops.plan.systems.file.FileSystem; +import com.djrapitops.plan.system.file.FileSystem; +import java.io.File; import java.io.IOException; /** @@ -13,7 +14,11 @@ * * @author Rsl1122 */ -public class PlanBungeeConfigSystem extends ConfigSystem { +public class BungeeConfigSystem extends ConfigSystem { + + public BungeeConfigSystem(File configFile) { + super(configFile); + } @Override protected void copyDefaults() throws IOException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java new file mode 100644 index 0000000000..426931bc8d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -0,0 +1,81 @@ +/* + * 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.settings.config; + +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.settings.locale.Locale; +import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.systems.Systems; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.config.Config; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.io.File; +import java.io.IOException; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public abstract class ConfigSystem implements SubSystem { + + protected final Config config; + protected final Locale locale; + protected final Theme theme; + + public ConfigSystem(File configFile) { + config = new Config(configFile); + locale = new Locale(); + theme = new Theme(); + } + + public static ConfigSystem getInstance() { + ConfigSystem configSystem = Systems.getInstance().getConfigSystem(); + NullCheck.check(configSystem, new IllegalStateException("Config System has not been initialized.")); + return configSystem; + } + + public Theme getThemeSystem() { + return theme; + } + + public Config getConfig() { + return config; + } + + @Override + public void enable() throws EnableException { + try { + copyDefaults(); + config.save(); + } catch (IOException e) { + throw new EnableException("Failed to save default config.", e); + } + locale.loadLocale(); + theme.enable(); + } + + protected abstract void copyDefaults() throws IOException; + + @Override + public void disable() { + theme.disable(); + locale.unload(); + } + + public void reload() { + try { + config.read(); + } catch (IOException e) { + Log.toLog(ConfigSystem.class, e); + } + } + + public Locale getLocale() { + return locale; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/update/VersionCheckSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java similarity index 78% rename from Plan/src/main/java/com/djrapitops/plan/systems/update/VersionCheckSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java index cc2a384761..488dcc1b7c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/update/VersionCheckSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java @@ -2,10 +2,11 @@ * 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.update; +package com.djrapitops.plan.system.update; -import com.djrapitops.plan.systems.SubSystem; -import com.djrapitops.plan.systems.Systems; +import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Priority; import com.djrapitops.plugin.api.systems.NotificationCenter; import com.djrapitops.plugin.api.utility.Version; @@ -28,11 +29,13 @@ public VersionCheckSystem(String currentVersion) { } public static VersionCheckSystem getInstance() { - return Systems.getInstance().getVersionCheckSystem(); + VersionCheckSystem versionCheckSystem = PlanSystem.getInstance().getVersionCheckSystem(); + NullCheck.check(versionCheckSystem, new IllegalStateException("Version Check system has not been initialized.")); + return versionCheckSystem; } @Override - public void init() { + public void enable() { checkForNewVersion(); } @@ -45,7 +48,7 @@ private void checkForNewVersion() { if (newVersionAvailable) { String newVersionNotification = "New Version is available at " + spigotUrl; Log.infoColor("§a----------------------------------------"); - Log.infoColor("§a"+newVersionNotification); + Log.infoColor("§a" + newVersionNotification); Log.infoColor("§a----------------------------------------"); NotificationCenter.addNotification(Priority.HIGH, newVersionNotification); } else { @@ -57,7 +60,7 @@ private void checkForNewVersion() { } @Override - public void close() { + public void disable() { /* Does not need to be closed */ } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/SubSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/SubSystem.java deleted file mode 100644 index b859580455..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/SubSystem.java +++ /dev/null @@ -1,20 +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; - -import com.djrapitops.plan.api.exceptions.PlanEnableException; - -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ -public interface SubSystem { - - void init() throws PlanEnableException; - - void close(); - -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java index 2abdfcf124..2cd84c3587 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java @@ -7,17 +7,18 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.systems.file.FileSystem; -import com.djrapitops.plan.systems.file.config.ConfigSystem; -import com.djrapitops.plan.systems.file.config.PlanBungeeConfigSystem; -import com.djrapitops.plan.systems.file.config.PlanConfigSystem; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; +import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.file.database.PlanBungeeDBSystem; import com.djrapitops.plan.systems.file.database.PlanDBSystem; import com.djrapitops.plan.systems.tasks.PlanBungeeTaskSystem; import com.djrapitops.plan.systems.tasks.PlanTaskSystem; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.systems.update.VersionCheckSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; @@ -48,7 +49,7 @@ public class Systems { */ public Systems(Plan plugin) { fileSystem = new FileSystem(plugin); - configSystem = new PlanConfigSystem(); + configSystem = new BukkitConfigSystem(); databaseSystem = new PlanDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); @@ -65,7 +66,7 @@ public Systems(Plan plugin) { */ public Systems(PlanBungee plugin) { fileSystem = new FileSystem(plugin); - configSystem = new PlanBungeeConfigSystem(); + configSystem = new BungeeConfigSystem(); databaseSystem = new PlanBungeeDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); @@ -92,7 +93,7 @@ public void close() { ArrayUtils.reverse(subSystems); for (SubSystem subSystem : subSystems) { try { - subSystem.close(); + subSystem.disable(); } catch (Exception e) { Log.toLog(Systems.class, e); } @@ -100,7 +101,7 @@ public void close() { } public static Systems getInstance() { - return MiscUtils.getIPlan().getSystems(); + return PlanPlugin.getInstance().getSystems(); } public FileSystem getFileSystem() { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java index 2c58f3d38e..c2829d6b33 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java @@ -29,7 +29,7 @@ */ public class GeolocationCache { - private static File geolocationDB = new File(MiscUtils.getIPlan().getDataFolder(), "GeoIP.dat"); + private static File geolocationDB = new File(PlanPlugin.getInstance().getDataFolder(), "GeoIP.dat"); private static final Cache geolocationCache = CacheBuilder.newBuilder() .build(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/file/config/ConfigSystem.java deleted file mode 100644 index 6bb45d30d4..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/config/ConfigSystem.java +++ /dev/null @@ -1,58 +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.file.config; - -import com.djrapitops.plan.api.exceptions.PlanEnableException; -import com.djrapitops.plan.systems.SubSystem; -import com.djrapitops.plan.systems.Systems; -import com.djrapitops.plan.systems.file.FileSystem; -import com.djrapitops.plugin.api.config.Config; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.io.IOException; - -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ -public abstract class ConfigSystem implements SubSystem { - - protected Config config; - - public static ConfigSystem getInstance() { - return Systems.getInstance().getConfigSystem(); - } - - public Config getConfig() { - return config; - } - - @Override - public void init() throws PlanEnableException { - try { - config = new Config(FileSystem.getConfigFile()); - copyDefaults(); - config.save(); - } catch (IOException e) { - throw new PlanEnableException("Config Subsystem failed to initialize", e); - } - } - - protected abstract void copyDefaults() throws IOException; - - @Override - public void close() { - - } - - public static void reload() { - try { - getInstance().config.read(); - } catch (IOException e) { - Log.toLog(ConfigSystem.class, e); - } - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/file/database/DBSystem.java index 148db067e5..afadcb9810 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/file/database/DBSystem.java @@ -5,12 +5,12 @@ package com.djrapitops.plan.systems.file.database; import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.api.exceptions.PlanEnableException; +import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.database.Database; import com.djrapitops.plan.database.databases.SQLDB; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.systems.SubSystem; +import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; @@ -39,7 +39,7 @@ public static DBSystem getInstance() { } @Override - public void init() throws PlanEnableException { + public void enable() throws EnableException { try { Benchmark.start("Init Database"); Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString()); @@ -48,7 +48,7 @@ public void init() throws PlanEnableException { Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName())); Benchmark.stop("Systems", "Init Database"); } catch (DatabaseInitException e) { - throw new PlanEnableException(db.getName() + "-Database failed to initialize", e); + throw new EnableException(db.getName() + "-Database failed to initialize", e); } } @@ -63,7 +63,7 @@ public void setDatabases(Set databases) { } @Override - public void close() { + public void disable() { try { if (db != null) { db.close(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanDBSystem.java index d367247b1f..e84c33a5e8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanDBSystem.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.database.databases.MySQLDB; import com.djrapitops.plan.database.databases.SQLiteDB; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; /** * //TODO Class Javadoc Comment 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 index 0702d00787..914c62ec3c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -11,7 +11,7 @@ import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.parsing.AnalysisPageParser; 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 index 9fba8fa477..14054cc07e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.parsing.NetworkPageParser; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; @@ -368,7 +368,7 @@ public void analysisReady(UUID serverUUID) { @Override public void updateNetworkPageContent() { - UUID serverUUID = MiscUtils.getIPlan().getServerUuid(); + UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); PageCache.cachePage(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(this)); if (Settings.ANALYSIS_EXPORT.isTrue()) { HtmlExport.exportServer(plugin, serverUUID); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java index 0dc2b98d44..44ccce54b8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.utilities.file.FileUtil; @@ -23,9 +23,9 @@ public class AnalysisPageParser extends PageParser { private final AnalysisData data; - private final IPlan plugin; + private final PlanPlugin plugin; - public AnalysisPageParser(AnalysisData analysisData, IPlan plugin) { + public AnalysisPageParser(AnalysisData analysisData, PlanPlugin plugin) { this.data = analysisData; this.plugin = plugin; } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index 81d167ad7f..4c417534e6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -4,14 +4,14 @@ */ package com.djrapitops.plan.systems.info.parsing; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; @@ -46,9 +46,9 @@ public class InspectPageParser extends PageParser { private final UUID uuid; - private final IPlan plugin; + private final PlanPlugin plugin; - public InspectPageParser(UUID uuid, IPlan plugin) { + public InspectPageParser(UUID uuid, PlanPlugin plugin) { this.uuid = uuid; this.plugin = plugin; } @@ -65,7 +65,7 @@ public String parse() throws ParseException { if (profile == null) { throw new IllegalStateException("Player profile was null!"); } - UUID serverUUID = MiscUtils.getIPlan().getServerUuid(); + UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); Map serverNames = db.getServerTable().getServerNames(); Benchmark.stop("Inspect Parse, Fetch"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java index 55aabe8d8e..d441d49ce2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.systems.info.BungeeInformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java index 247cf590c0..f4cd81ecef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java @@ -7,10 +7,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.ServerVariableHolder; -import com.djrapitops.plan.api.exceptions.PlanEnableException; +import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.database.Database; import com.djrapitops.plan.database.tables.ServerTable; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; import java.io.IOException; @@ -32,7 +32,7 @@ public class BukkitServerInfoManager { private ServerInfoFile serverInfoFile; private final ServerTable serverTable; - public BukkitServerInfoManager(Plan plugin) throws PlanEnableException { + public BukkitServerInfoManager(Plan plugin) throws EnableException { this.plugin = plugin; Database db = plugin.getDB(); serverTable = db.getServerTable(); @@ -40,7 +40,7 @@ public BukkitServerInfoManager(Plan plugin) throws PlanEnableException { try { serverInfoFile = new ServerInfoFile(plugin); } catch (IOException e) { - throw new PlanEnableException("Failed to read ServerInfoFile.yml", e); + throw new EnableException("Failed to read ServerInfoFile.yml", e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index 179ccf8d01..971e05026a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.ServerVariableHolder; -import com.djrapitops.plan.api.exceptions.PlanEnableException; +import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.database.Database; import com.djrapitops.plan.database.tables.ServerTable; @@ -45,7 +45,7 @@ public BungeeServerInfoManager(PlanBungee plugin) { onlineServers = new HashSet<>(); } - public void loadServerInfo() throws PlanEnableException { + public void loadServerInfo() throws EnableException { try { Optional bungeeInfo = db.getServerTable().getBungeeInfo(); if (bungeeInfo.isPresent()) { @@ -59,11 +59,11 @@ public void loadServerInfo() throws PlanEnableException { serverInfo = registerBungeeInfo(); } } catch (SQLException e) { - throw new PlanEnableException("Failed to read Database for ServerInfo"); + throw new EnableException("Failed to read Database for ServerInfo"); } } - private ServerInfo registerBungeeInfo() throws SQLException, PlanEnableException { + private ServerInfo registerBungeeInfo() throws SQLException, EnableException { ServerVariableHolder variable = plugin.getVariable(); UUID serverUUID = generateNewUUID(variable); String accessAddress = plugin.getWebServer().getAccessAddress(); @@ -76,7 +76,7 @@ private ServerInfo registerBungeeInfo() throws SQLException, PlanEnableException if (bungeeInfo.isPresent()) { return bungeeInfo.get(); } - throw new PlanEnableException("BungeeCord registration failed (DB)"); + throw new EnableException("BungeeCord registration failed (DB)"); } private UUID generateNewUUID(ServerVariableHolder variableHolder) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java index 9d83293a70..e134d503d3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.systems.listeners; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Permissions; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.processing.CommandProcessor; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.command.Command; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java index 6529d5dddd..0e870716b0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java @@ -4,6 +4,8 @@ */ package com.djrapitops.plan.systems.processing; +import com.djrapitops.plan.system.processing.ProcessingQueue; + /** * Abstract class for processing different objects using Generics. * @@ -21,4 +23,12 @@ public Processor(T object) { public T getObject() { return object; } + + public void que() { + que(this); + } + + public static void que(Processor processor) { + ProcessingQueue.getInstance().addToQueue(processor); + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java index 2d00ca66d7..942136a922 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java @@ -36,7 +36,7 @@ public void process() { TPS tps = new TPS(lastDate, averageTPS, averagePlayersOnline, averageCPUUsage, averageUsedMemory, averageEntityCount, averageChunksLoaded); try { - MiscUtils.getIPlan().getDB().getTpsTable().insertTPS(tps); + PlanPlugin.getInstance().getDB().getTpsTable().insertTPS(tps); } catch (SQLException e) { Log.toLog(this.getClass().getName(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java index 506fb4808d..053e3cc3cf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.systems.processing.info; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.cache.DataCache; @@ -34,7 +34,7 @@ public InspectCacheRequestProcessor(UUID uuid, ISender sender, String playerName @Override public void process() { - IPlan plugin = MiscUtils.getIPlan(); + PlanPlugin plugin = PlanPlugin.getInstance(); plugin.getInfoManager().cachePlayer(getUUID()); DataCache dataCache = plugin.getInfoManager().getDataCache(); if (dataCache != null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java index f77cc8e579..74bbb617d6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java @@ -17,7 +17,7 @@ public class PlanBungeeTaskSystem extends TaskSystem { @Override - public void init() { + public void enable() { registerTasks(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java index fe30f7b49f..03280b2b86 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.systems.tasks; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.info.InformationManager; @@ -28,7 +28,7 @@ public class PlanTaskSystem extends TaskSystem { private ITask bootAnalysisTask; @Override - public void init() { + public void enable() { registerTasks(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java index d8979029e8..a950016ef5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.systems.processing.TPSInsertProcessor; import com.djrapitops.plan.utilities.MiscUtils; @@ -25,7 +25,7 @@ */ public class TPSCountTimer extends AbsRunnable { - private final IPlan plugin; + private final PlanPlugin plugin; private final List history; private long lastCheckNano; @@ -33,7 +33,7 @@ public class TPSCountTimer extends AbsRunnable { private int latestPlayersOnline = 0; - public TPSCountTimer(IPlan plugin) { + public TPSCountTimer(PlanPlugin plugin) { super("TPSCountTimer"); lastCheckNano = -1; this.plugin = plugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java index 487c20709f..7459d12d77 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.tasks; -import com.djrapitops.plan.systems.SubSystem; +import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.systems.TaskCenter; @@ -35,8 +35,8 @@ protected IRunnable registerTask(String name, AbsRunnable runnable) { } @Override - public void close() { - TaskCenter.cancelAllKnownTasks(MiscUtils.getIPlan().getClass()); + public void disable() { + TaskCenter.cancelAllKnownTasks(PlanPlugin.getInstance().getClass()); } public TPSCountTimer getTpsCountTimer() { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIRequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIRequestHandler.java index c0e6c79a6a..c4d5032aca 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIRequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIRequestHandler.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; import com.djrapitops.plugin.api.Benchmark; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java index cd31e3e45d..325d2dab58 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java @@ -55,7 +55,7 @@ Response getAPIResponse(Request request) throws IOException { } if (args.length < 2 || !"api".equals(args[1])) { - String address = MiscUtils.getIPlan().getInfoManager().getWebServerAddress() + target; + String address = PlanPlugin.getInstance().getInfoManager().getWebServerAddress() + target; String link = Html.LINK.parse(address, address); return PageCache.loadPage(PageId.ERROR.of("Non-API Request"), () -> new NotFoundResponse("WebServer is in WebAPI-only mode, " + "connect to the Bungee server instead: " + link)); @@ -121,7 +121,7 @@ Response getAPIResponse(Request request) throws IOException { return PageCache.loadPage(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); } - Response response = api.processRequest(MiscUtils.getIPlan(), variables); + Response response = api.processRequest(PlanPlugin.getInstance(), variables); Log.debug("Response: " + response.getResponse().split("\r\n")[0]); @@ -152,7 +152,7 @@ private boolean checkKey(String sender) { } try { - List uuids = MiscUtils.getIPlan().getDB().getServerTable().getServerUUIDs(); + List uuids = PlanPlugin.getInstance().getDB().getServerTable().getServerUUIDs(); UUID keyUUID = UUID.fromString(sender); return uuids.contains(keyUUID); } catch (SQLException | IllegalArgumentException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/RequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/RequestHandler.java index 8959da89de..94fb92858e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/RequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/RequestHandler.java @@ -4,8 +4,8 @@ */ package com.djrapitops.plan.systems.webserver; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.webserver.response.PromptAuthorizationResponse; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plugin.api.Benchmark; @@ -25,7 +25,7 @@ public class RequestHandler implements HttpHandler { private final ResponseHandler responseHandler; - RequestHandler(IPlan plugin, WebServer webServer) { + RequestHandler(PlanPlugin plugin, WebServer webServer) { responseHandler = new ResponseHandler(plugin, webServer); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java index 5ab8363e62..5ce3ef38cd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.data.WebUser; @@ -29,11 +29,11 @@ */ public class ResponseHandler extends APIResponseHandler { - private final IPlan plugin; + private final PlanPlugin plugin; private final boolean usingHttps; - public ResponseHandler(IPlan plugin, WebServer webServer) { + public ResponseHandler(PlanPlugin plugin, WebServer webServer) { super(webServer.getWebAPI()); this.plugin = plugin; this.usingHttps = webServer.isUsingHTTPS(); @@ -57,7 +57,7 @@ public Response getResponse(Request request) { return PageCache.loadPage(PageId.JS.of(target), () -> new JavaScriptResponse(target)); } - UUID serverUUID = MiscUtils.getIPlan().getServerUuid(); + UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); if (usingHttps) { if (!request.hasAuth()) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java index 22d1cb7ca8..d516b58a91 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.systems.webserver; -import com.djrapitops.plan.api.IPlan; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; @@ -36,7 +36,7 @@ */ public class WebServer { - private final IPlan plugin; + private final PlanPlugin plugin; private final WebAPIManager webAPI; private final int port; @@ -45,7 +45,7 @@ public class WebServer { private boolean usingHttps = false; - public WebServer(IPlan plugin) { + public WebServer(PlanPlugin plugin) { this.plugin = plugin; this.port = Settings.WEBSERVER_PORT.getNumber(); webAPI = new WebAPIManager(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServerSystem.java index 31d58cf46a..9bb59907a1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServerSystem.java @@ -4,8 +4,8 @@ */ package com.djrapitops.plan.systems.webserver; -import com.djrapitops.plan.api.exceptions.PlanEnableException; -import com.djrapitops.plan.systems.SubSystem; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Check; @@ -28,16 +28,16 @@ public static WebServerSystem getInstance() { } @Override - public void init() throws PlanEnableException { - webServer = new WebServer(MiscUtils.getIPlan()); + public void enable() throws EnableException { + webServer = new WebServer(PlanPlugin.getInstance()); webServer.initServer(); if (Check.isBungeeAvailable() && !webServer.isEnabled()) { - throw new PlanEnableException("WebServer did not initialize!"); + throw new EnableException("WebServer did not initialize!"); } } @Override - public void close() { + public void disable() { // TODO Remove after WebServer setting requirement is gone. if (webServer != null) { webServer.stop(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/DebugPageResponse.java index 153cc0affd..77d77563de 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/DebugPageResponse.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.ServerVariableHolder; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; @@ -63,7 +63,7 @@ private String buildParagraph() { } private void appendServerInformation(StringBuilder content) { - IPlan plugin = MiscUtils.getIPlan(); + PlanPlugin plugin = PlanPlugin.getInstance(); ServerVariableHolder variable = plugin.getVariable(); content.append("

### Server Information
") @@ -111,7 +111,7 @@ private void appendServerInformation(StringBuilder content) { private void appendConfig(StringBuilder content) { try { - File configFile = new File(MiscUtils.getIPlan().getDataFolder(), "config.yml"); + File configFile = new File(PlanPlugin.getInstance().getDataFolder(), "config.yml"); if (configFile.exists()) { content.append("
### config.yml
```
"); FileUtil.lines(configFile, Charset.forName("UTF-8")) @@ -169,7 +169,7 @@ private void appendLoggedErrors(StringBuilder content) { try { content.append("
### Logged Errors
"); - TreeMap> errors = MiscUtils.getIPlan().getInfoManager().getErrors(); + TreeMap> errors = PlanPlugin.getInstance().getInfoManager().getErrors(); if (!errors.isEmpty()) { List errorLines = new ArrayList<>(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java index 941cfc8f06..02db10151f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java @@ -1,12 +1,12 @@ package com.djrapitops.plan.systems.webserver.response; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; @@ -32,7 +32,7 @@ public class PlayersPageResponse extends Response { public PlayersPageResponse() { super.setHeader("HTTP/1.1 200 OK"); try { - IPlan plugin = MiscUtils.getIPlan(); + PlanPlugin plugin = PlanPlugin.getInstance(); List names = new ArrayList<>(plugin.getDB().getUsersTable().getPlayerNames().values()); Collections.sort(names); Map replace = new HashMap<>(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java index 29ff404010..de07ebcc4a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java @@ -4,9 +4,9 @@ */ package com.djrapitops.plan.systems.webserver.webapi; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.*; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.webserver.pagecache.PageCache; import com.djrapitops.plan.systems.webserver.pagecache.PageId; import com.djrapitops.plan.systems.webserver.response.NotFoundResponse; @@ -42,7 +42,7 @@ public WebAPI() { this.variables = new HashMap<>(); } - public Response processRequest(IPlan plugin, Map variables) { + public Response processRequest(PlanPlugin plugin, Map variables) { String sender = variables.get("sender"); if (sender == null) { Log.debug(getClass().getSimpleName() + ": Sender not Found"); @@ -58,7 +58,7 @@ public Response processRequest(IPlan plugin, Map variables) { return onRequest(plugin, variables); } - public abstract Response onRequest(IPlan plugin, Map variables); + public abstract Response onRequest(PlanPlugin plugin, Map variables); public void sendRequest(String address) throws WebAPIException { Verify.nullCheck(address); @@ -183,7 +183,7 @@ protected Response badRequest(String error) { private String parseVariables() { StringBuilder parameters = new StringBuilder(); - String serverUUID = MiscUtils.getIPlan().getServerUuid().toString(); + String serverUUID = PlanPlugin.getInstance().getServerUuid().toString(); parameters.append("sender=").append(serverUUID); for (Map.Entry entry : variables.entrySet()) { parameters.append(";&variable;").append(entry.getKey()).append("=").append(entry.getValue()); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalysisReadyWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalysisReadyWebAPI.java index c8af2ab5cf..cd156f4d86 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalysisReadyWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalysisReadyWebAPI.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver.webapi.bukkit; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plan.systems.webserver.webapi.WebAPI; @@ -17,7 +17,7 @@ */ public class AnalysisReadyWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { String serverUUIDS = variables.get("serverUUID"); if (serverUUIDS == null) { return badRequest("serverUUID was not present"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalyzeWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalyzeWebAPI.java index da92785a83..cc2033a69f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalyzeWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalyzeWebAPI.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver.webapi.bukkit; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plan.systems.webserver.webapi.WebAPI; @@ -17,7 +17,7 @@ */ public class AnalyzeWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { String serverUUIDS = variables.get("serverUUID"); if (serverUUIDS == null) { return badRequest("serverUUID was not present"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/ConfigurationWebAPI.java index 41fad84034..1228dfd8be 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -6,10 +6,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.settings.ServerSpecificSettings; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; @@ -26,7 +26,7 @@ public class ConfigurationWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { if (!Check.isBukkitAvailable()) { Log.debug("Called a wrong server type"); return badRequest("Called a Bungee Server"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/InspectWebAPI.java index d25d65e35a..e335d5a8d1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/InspectWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/InspectWebAPI.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver.webapi.bukkit; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plan.systems.webserver.webapi.WebAPI; @@ -17,7 +17,7 @@ */ public class InspectWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { String uuidS = variables.get("uuid"); if (uuidS == null) { return badRequest("UUID not included"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/IsOnlineWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/IsOnlineWebAPI.java index e4badd9cb7..10aa37e81b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/IsOnlineWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/IsOnlineWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.systems.webserver.webapi.bukkit; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plan.systems.webserver.webapi.WebAPI; @@ -19,7 +19,7 @@ */ public class IsOnlineWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { String uuidS = variables.get("uuid"); if (uuidS == null) { return badRequest("UUID not included"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java index 716760529f..7fe7034c90 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver.webapi.bukkit; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.webserver.response.Response; @@ -28,7 +28,7 @@ public class RequestInspectPluginsTabBukkitWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { if (!Check.isBukkitAvailable()) { return badRequest("Called a Bungee Server"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/IsCachedWebAPI.java index de5ed9e3d5..2f94b412fe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/IsCachedWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/IsCachedWebAPI.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver.webapi.bungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; import com.djrapitops.plan.systems.info.InformationManager; @@ -22,7 +22,7 @@ public class IsCachedWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { try { String target = variables.get("target"); InformationManager infoManager = plugin.getInfoManager(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostHtmlWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostHtmlWebAPI.java index 18a8569f41..4c473f6814 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostHtmlWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostHtmlWebAPI.java @@ -4,9 +4,9 @@ */ package com.djrapitops.plan.systems.webserver.webapi.bungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.webserver.pagecache.PageCache; import com.djrapitops.plan.systems.webserver.pagecache.PageId; @@ -30,7 +30,7 @@ public class PostHtmlWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { try { String htmlVariable = variables.get("html"); if (htmlVariable == null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java index efb6f3ef2c..b82d80d928 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.webserver.webapi.bungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.webserver.response.Response; @@ -25,7 +25,7 @@ */ public class PostInspectPluginsTabWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { String uuidS = variables.get("uuid"); if (uuidS == null) { return badRequest("uuid not included"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java index 835bf735e8..5bc53cd01c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.systems.webserver.webapi.bungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.webserver.response.Response; @@ -22,7 +22,7 @@ */ public class PostNetworkPageContentWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { if (Check.isBukkitAvailable()) { return badRequest("Called a Bukkit server."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java index 764dd1bbfa..fe6299d793 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java @@ -6,9 +6,9 @@ import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.webserver.response.Response; import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; @@ -26,7 +26,7 @@ public class PostOriginalBukkitSettingsWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { if (Check.isBukkitAvailable()) { return badRequest("Called a Bukkit Server"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index dd6adaf368..b6ef7c6b9b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.systems.webserver.webapi.bungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.systems.processing.Processor; @@ -33,7 +33,7 @@ */ public class RequestPluginsTabWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { if (!Check.isBungeeAvailable()) { return badRequest("Called a Bukkit Server"); } @@ -58,7 +58,7 @@ public void sendRequest(String address, UUID uuid) throws WebAPIException { super.sendRequest(address); } - public void sendRequestsToBukkitServers(IPlan plugin, UUID uuid) { + public void sendRequestsToBukkitServers(PlanPlugin plugin, UUID uuid) { plugin.addToProcessQueue(new Processor(uuid) { @Override public void process() { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestSetupWebAPI.java index 6e05413bad..6f8f88b1d2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.systems.webserver.response.ForbiddenResponse; @@ -28,7 +28,7 @@ public class RequestSetupWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { if (!Check.isBungeeAvailable()) { return badRequest("Called a Bukkit server."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/universal/PingWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/universal/PingWebAPI.java index 9717887dd9..8412914e96 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/universal/PingWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/universal/PingWebAPI.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.webserver.response.Response; @@ -25,7 +25,7 @@ */ public class PingWebAPI extends WebAPI { @Override - public Response onRequest(IPlan plugin, Map variables) { + public Response onRequest(PlanPlugin plugin, Map variables) { if (Check.isBungeeAvailable()) { if (!((PlanBungee) plugin).getServerInfoManager().serverConnected(UUID.fromString(variables.get("sender")))) { return fail("Server info not found from the database"); @@ -57,7 +57,7 @@ public void sendRequest(String address) throws WebAPIException { public void sendRequest(String address, String accessCode) throws WebAPIException { addVariable("accessKey", accessCode); - addVariable("version", MiscUtils.getIPlan().getVersion()); + addVariable("version", PlanPlugin.getInstance().getVersion()); sendRequest(address); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index a53f38463b..a6306a4355 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.utilities; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.utilities.Format; import org.apache.commons.lang3.StringUtils; import org.bukkit.Location; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index d96406674e..8619c2e06f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Permissions; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plugin.api.Check; @@ -96,7 +96,7 @@ public static String getPlayerName(String[] args, ISender sender, Permissions pe * @return Alphabetically sorted list of matching player names. */ public static List getMatchingPlayerNames(String search) { - Database db = getIPlan().getDB(); + Database db = PlanPlugin.getInstance().getDB(); List matches; try { matches = db.getUsersTable().getMatchingNames(search); @@ -143,12 +143,4 @@ public static String getPlanVersion() { return PlanBungee.getInstance().getDescription().getVersion(); } } - - public static IPlan getIPlan() { - if (Check.isBukkitAvailable()) { - return Plan.getInstance(); - } else { - return PlanBungee.getInstance(); - } - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java b/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java new file mode 100644 index 0000000000..54bf636fda --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java @@ -0,0 +1,22 @@ +/* + * 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.utilities; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class NullCheck { + + private NullCheck() {} + + public static void check(Object toCheck, T throwIfNull) throws T { + if (toCheck == null) { + throw throwIfNull; + } + } + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index fcc1b951b7..83b6b6c723 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.data.plugin.BanData; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.cache.DataCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index e6a36458d1..7b043c7c58 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.utilities.analysis; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.StickyData; @@ -141,7 +141,7 @@ public static void addMissingWorlds(WorldTimes worldTimes) { try { // Add 0 time for worlds not present. Set nonZeroWorlds = worldTimes.getWorldTimes().keySet(); - IPlan plugin = MiscUtils.getIPlan(); + PlanPlugin plugin = PlanPlugin.getInstance(); for (String world : plugin.getDB().getWorldTable().getWorldNames(plugin.getServerUuid())) { if (nonZeroWorlds.contains(world)) { continue; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java index f45d67eeb3..0a8319700a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.utilities.file; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -24,14 +24,14 @@ private FileUtil() { public static String getStringFromResource(String fileName) throws IOException { StringBuilder html = new StringBuilder(); - IPlan plugin = MiscUtils.getIPlan(); + PlanPlugin plugin = PlanPlugin.getInstance(); - lines(MiscUtils.getIPlan(), new File(plugin.getDataFolder(), fileName.replace("/", File.separator)), fileName) + lines(PlanPlugin.getInstance(), new File(plugin.getDataFolder(), fileName.replace("/", File.separator)), fileName) .forEach(line -> html.append(line).append("\r\n")); return html.toString(); } - public static List lines(IPlan plugin, File savedFile, String defaults) throws IOException { + public static List lines(PlanPlugin plugin, File savedFile, String defaults) throws IOException { if (savedFile.exists()) { return lines(savedFile); } else { @@ -72,7 +72,7 @@ private static File attemptToFind(String fileName, File dataFolder) { return null; } - public static List lines(IPlan plugin, String resource) throws IOException { + public static List lines(PlanPlugin plugin, String resource) throws IOException { List lines = new ArrayList<>(); Scanner scanner = null; try (InputStream inputStream = plugin.getResource(resource)) { 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 5d171327e6..2c3b9f3947 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 @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.utilities.file.export; -import com.djrapitops.plan.api.IPlan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; @@ -26,14 +26,14 @@ */ public class HtmlExport extends SpecificExport { - private final IPlan plugin; + private final PlanPlugin plugin; - public HtmlExport(IPlan plugin) { + public HtmlExport(PlanPlugin plugin) { super("HtmlExportTask"); this.plugin = plugin; } - public static void exportServer(IPlan plugin, UUID serverUUID) { + public static void exportServer(PlanPlugin plugin, UUID serverUUID) { try { Optional serverName = plugin.getDB().getServerTable().getServerName(serverUUID); serverName.ifPresent(s -> RunnableFactory.createNew(new AnalysisExport(serverUUID, s)).runTaskAsynchronously()); @@ -42,7 +42,7 @@ public static void exportServer(IPlan plugin, UUID serverUUID) { } } - public static void exportPlayer(IPlan plugin, UUID playerUUID) { + public static void exportPlayer(PlanPlugin plugin, UUID playerUUID) { try { String playerName = plugin.getDB().getUsersTable().getPlayerName(playerUUID); if (playerName != null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index 212f94786e..ff3ef68bc3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.utilities.file.export; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.webserver.pagecache.PageCache; import com.djrapitops.plan.systems.webserver.pagecache.PageId; import com.djrapitops.plan.systems.webserver.response.Response; @@ -51,7 +51,7 @@ protected File getFolder() { } return folder; } - File dataFolder = MiscUtils.getIPlan().getDataFolder(); + File dataFolder = PlanPlugin.getInstance().getDataFolder(); File folder = new File(dataFolder, path); folder.mkdirs(); return folder; @@ -104,7 +104,7 @@ protected void exportAvailableServerPage(UUID serverUUID, String serverName) thr File htmlLocation = null; if (usingBungee) { - if (serverUUID.equals(MiscUtils.getIPlan().getServerUuid())) { + if (serverUUID.equals(PlanPlugin.getInstance().getServerUuid())) { htmlLocation = new File(outputFolder, "network"); } else { htmlLocation = new File(getServerFolder(), serverName.replace(" ", "%20").replace(".", "%2E")); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index ca66fc41f0..ce16eef5dc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraph; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java index 1f21d0e252..c96508c5a7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.utilities.html; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.MiscUtils; import org.apache.commons.lang3.text.StrSubstitutor; @@ -45,13 +45,13 @@ public static String getIP() { if (Settings.SHOW_ALTERNATIVE_IP.isTrue()) { ip = Settings.ALTERNATIVE_IP.toString().replace("%port%", String.valueOf(port)); } else { - ip = MiscUtils.getIPlan().getVariable().getIp() + ":" + port; + ip = PlanPlugin.getInstance().getVariable().getIp() + ":" + port; } return ip; } public static String getProtocol() { - return MiscUtils.getIPlan().getWebServer().getProtocol(); + return PlanPlugin.getInstance().getWebServer().getProtocol(); } public static String getRelativeInspectUrl(String playerName) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java index d15ff8076f..fead86ff2a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.WorldAliasSettings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index 59f6928bcf..02a5ccd83f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java index 50e267a45e..49b02d5815 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java @@ -5,7 +5,7 @@ import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.html.Html; @@ -35,7 +35,7 @@ public static String createTable(List players) { StringBuilder html = new StringBuilder(); long now = MiscUtils.getTime(); - UUID serverUUID = MiscUtils.getIPlan().getServerUuid(); + UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); int i = 0; int maxPlayers = Settings.MAX_PLAYERS.getNumber(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index 08362a0c82..a1c74ba6aa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.WorldAliasSettings; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; 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 b278f043e6..8b60034768 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,7 +2,7 @@ import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java index d33fde4253..4384dd4e1d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java @@ -35,7 +35,7 @@ private UUIDUtility() { */ public static UUID getUUIDOf(String playerName) { try { - return getUUIDOf(playerName, MiscUtils.getIPlan().getDB()); + return getUUIDOf(playerName, PlanPlugin.getInstance().getDB()); } catch (Exception e) { return null; } diff --git a/Plan/test/main/java/com/djrapitops/plan/PermissionsTest.java b/Plan/test/main/java/com/djrapitops/plan/PermissionsTest.java index cc3bad2d10..fc23be670e 100644 --- a/Plan/test/main/java/com/djrapitops/plan/PermissionsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/PermissionsTest.java @@ -5,7 +5,7 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.settings.Permissions; +import com.djrapitops.plan.system.settings.Permissions; import org.junit.Test; import test.utilities.TestUtils; diff --git a/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java b/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java index e8e9246002..f152fe19ff 100644 --- a/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java @@ -5,7 +5,7 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; import org.junit.Test; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java b/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java index 9ebcd87f7f..c87610e857 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.data; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import org.bukkit.plugin.java.JavaPlugin; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java index dbf3ae1656..224a6f8e56 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java @@ -37,7 +37,7 @@ public void checkAvailability() throws Exception { TestInit.init(); Thread thread = new Thread(() -> { - StaticHolder.saveInstance(this.getClass(), MiscUtils.getIPlan().getClass()); + StaticHolder.saveInstance(this.getClass(), PlanPlugin.getInstance().getClass()); try { Hastebin.upload(RandomData.randomString(10)); } catch (IOException e) { diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index 5b2be68ede..6bae629038 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.ServerVariableHolder; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; diff --git a/Plan/test/test/java/utils/DBTestSuite.java b/Plan/test/test/java/utils/DBTestSuite.java deleted file mode 100644 index f44d301e3b..0000000000 --- a/Plan/test/test/java/utils/DBTestSuite.java +++ /dev/null @@ -1,51 +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 test.java.utils; - -import main.java.com.djrapitops.plan.database.DatabaseTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -import java.io.File; -import java.io.IOException; - -/** - * @author Fuzzlemann - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({DatabaseTest.class}) -public class DBTestSuite { - @BeforeClass - public static void setUp() throws IOException { - clean(); - } - - @AfterClass - public static void tearDown() throws IOException { - clean(); - } - - private static void clean() { - File testFolder = TestInit.getTestFolder(); - - if (!testFolder.exists() || !testFolder.isDirectory()) { - return; - } - - File[] files = testFolder.listFiles(); - - if (files == null) { - return; - } - - for (File f : files) { - if (!f.delete()) { - f.deleteOnExit(); - } - } - } -} diff --git a/Plan/test/test/java/utils/MockUtils.java b/Plan/test/test/java/utils/MockUtils.java deleted file mode 100644 index 26aeffe2f9..0000000000 --- a/Plan/test/test/java/utils/MockUtils.java +++ /dev/null @@ -1,216 +0,0 @@ -package test.java.utils; - -import com.sun.net.httpserver.*; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; - -import java.io.*; -import java.net.InetSocketAddress; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.Charset; -import java.util.*; -import java.util.zip.GZIPInputStream; - -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Rsl1122 - */ -public class MockUtils { - - public static World mockWorld() { - World mockWorld = Mockito.mock(World.class); - when(mockWorld.toString()).thenReturn("World"); - return mockWorld; - } - - public static Player mockPlayer() { - Player p = PowerMockito.mock(Player.class); - when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); - when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); - when(p.getFirstPlayed()).thenReturn(1234567L); - World mockWorld = mockWorld(); - when(p.getLocation()).thenReturn(new Location(mockWorld, 0, 0, 0)); - when(p.isOp()).thenReturn(true); - when(p.isBanned()).thenReturn(true); - when(p.isOnline()).thenReturn(true); - when(p.getName()).thenReturn("TestName"); - when(p.hasPermission("plan.inspect.other")).thenReturn(true); - return p; - } - - public static UUID getPlayerUUID() { - return UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"); - } - - public static Player mockPlayer2() { - Player p = PowerMockito.mock(Player.class); - when(p.getGameMode()).thenReturn(GameMode.SPECTATOR); - when(p.getUniqueId()).thenReturn(UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80")); - when(p.getFirstPlayed()).thenReturn(3423434L); - World mockWorld = mockWorld(); - when(p.getLocation()).thenReturn(new Location(mockWorld, 1, 0, 1)); - when(p.isOp()).thenReturn(false); - when(p.isBanned()).thenReturn(false); - when(p.isOnline()).thenReturn(false); - when(p.hasPermission("plan.inspect.other")).thenReturn(false); - when(p.getName()).thenReturn("TestName2"); - return p; - } - - public static UUID getPlayer2UUID() { - return UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80"); - } - - public static Set getUUIDs() { - Set uuids = new HashSet<>(); - uuids.add(getPlayerUUID()); - uuids.add(getPlayer2UUID()); - return uuids; - } - - public static Player mockBrokenPlayer() { - Player p = PowerMockito.mock(Player.class); - when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); - when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); - when(p.getFirstPlayed()).thenReturn(1234567L); - World mockWorld = mockWorld(); - when(p.getLocation()).thenReturn(new Location(mockWorld, 0, 0, 0)); - when(p.isOp()).thenReturn(true); - when(p.isBanned()).thenThrow(Exception.class); - when(p.isOnline()).thenReturn(true); - when(p.getName()).thenReturn("TestName"); - return p; - } - - public static CommandSender mockConsoleSender() { - return PowerMockito.mock(CommandSender.class); - } - - public static HttpServer mockHTTPServer() { - HttpServer httpServer = PowerMockito.mock(HttpServer.class); - when(httpServer.getAddress()).thenReturn(new InetSocketAddress(80)); - when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received")); - return httpServer; - } - - public static HttpExchange getHttpExchange(String requestMethod, String requestURI, String body, Map> responseHeaders) { - return new HttpExchange() { - private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - @Override - public Headers getRequestHeaders() { - Headers headers = new Headers(); - headers.put("Authorization", new ArrayList<>()); - return headers; - } - - @Override - public Headers getResponseHeaders() { - Headers headers = new Headers(); - headers.putAll(responseHeaders); - return headers; - } - - @Override - public URI getRequestURI() { - try { - return new URI(requestURI); - } catch (URISyntaxException e) { - return null; - } - } - - @Override - public String getRequestMethod() { - return requestMethod; - } - - @Override - public HttpContext getHttpContext() { - return null; - } - - @Override - public void close() { - - } - - @Override - public InputStream getRequestBody() { - return new ByteArrayInputStream(body.getBytes(Charset.forName("UTF-8"))); - } - - @Override - public OutputStream getResponseBody() { - return outputStream; - } - - @Override - public InetSocketAddress getRemoteAddress() { - return null; - } - - @Override - public InetSocketAddress getLocalAddress() { - return null; - } - - @Override - public String getProtocol() { - return null; - } - - @Override - public Object getAttribute(String name) { - return null; - } - - @Override - public void sendResponseHeaders(int i, long l) throws IOException { - - } - - @Override - public int getResponseCode() { - return 0; - } - - @Override - public void setAttribute(String s, Object o) { - - } - - @Override - public void setStreams(InputStream inputStream, OutputStream outputStream) { - - } - - @Override - public HttpPrincipal getPrincipal() { - return null; - } - }; - } - - public static String getResponseStream(HttpExchange requestExchange) throws IOException { - InputStream in = new GZIPInputStream( - new ByteArrayInputStream(( - (ByteArrayOutputStream) requestExchange.getResponseBody() - ).toByteArray()) - ); - try (Scanner scanner = new Scanner(in)) { - StringBuilder s = new StringBuilder(); - while (scanner.hasNextLine()) { - s.append(scanner.nextLine()).append("\n"); - } - return s.toString(); - } - } -} diff --git a/Plan/test/test/java/utils/RandomData.java b/Plan/test/test/java/utils/RandomData.java deleted file mode 100644 index 37292fb981..0000000000 --- a/Plan/test/test/java/utils/RandomData.java +++ /dev/null @@ -1,77 +0,0 @@ -package test.java.utils; - -import main.java.com.djrapitops.plan.data.WebUser; -import main.java.com.djrapitops.plan.data.container.Session; -import main.java.com.djrapitops.plan.data.container.TPS; -import main.java.com.djrapitops.plan.data.container.UserInfo; -import main.java.com.djrapitops.plan.utilities.PassEncryptUtil; -import main.java.com.djrapitops.plan.utilities.analysis.Point; -import org.apache.commons.lang3.RandomStringUtils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; - -public class RandomData { - - private static final Random r = new Random(); - - public static int randomInt(int rangeStart, int rangeEnd) { - return ThreadLocalRandom.current().nextInt(rangeStart, rangeEnd); - } - - public static String randomString(int size) { - return RandomStringUtils.randomAlphanumeric(size); - } - - public static List randomWebUsers() throws PassEncryptUtil.CannotPerformOperationException { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - test.add(new WebUser(randomString(5), PassEncryptUtil.createHash(randomString(7)), r.nextInt())); - } - return test; - } - - public static List randomTPS() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - int randInt = r.nextInt(); - long randLong = r.nextLong(); - test.add(new TPS(randLong, randLong, randInt, randLong, randLong, randInt, randInt)); - } - return test; - } - - public static List randomSessions() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - test.add(new Session(1, r.nextLong(), r.nextLong(), 0, 0)); - } - return test; - } - - public static List randomPoints() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - test.add(new Point(r.nextLong(), r.nextLong())); - } - return test; - } - - public static T randomEnum(Class clazz) { - int x = r.nextInt(clazz.getEnumConstants().length); - return clazz.getEnumConstants()[x]; - } - - public static List randomUserData() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - UserInfo info = new UserInfo(UUID.randomUUID(), randomString(10), r.nextLong(), r.nextBoolean(), r.nextBoolean()); - info.setLastSeen(r.nextLong()); - test.add(info); - } - return test; - } -} diff --git a/Plan/test/test/java/utils/TestInit.java b/Plan/test/test/java/utils/TestInit.java deleted file mode 100644 index 9b85006117..0000000000 --- a/Plan/test/test/java/utils/TestInit.java +++ /dev/null @@ -1,297 +0,0 @@ -package test.java.utils; - -import com.djrapitops.plugin.IPlugin; -import com.djrapitops.plugin.StaticHolder; -import com.djrapitops.plugin.api.config.Config; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.settings.ColorScheme; -import com.djrapitops.plugin.task.RunnableFactory; -import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.ServerVariableHolder; -import main.java.com.djrapitops.plan.settings.Settings; -import main.java.com.djrapitops.plan.settings.locale.Locale; -import main.java.com.djrapitops.plan.systems.cache.DataCache; -import main.java.com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; -import main.java.com.djrapitops.plan.utilities.file.FileUtil; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.Conversation; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; -import org.bukkit.plugin.Plugin; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Set; -import java.util.UUID; -import java.util.logging.Logger; - -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Rsl1122 - */ -public class TestInit { - - private static final UUID serverUUID = UUID.fromString("9a27457b-f1a2-4b71-be7f-daf2170a1b66"); - private Plan planMock; - - /** - * Init locale with empty messages. - *

- * Does not load any messages from anywhere because that would cause exceptions. - */ - public static void initEmptyLocale() { - new Locale(); - } - - /** - * Init locale with mocked Plan. - *

- * requires getDataFolder mock. - * - * @param plan Mocked Plan - */ - public static void initLocale(Plan plan) { - new Locale().loadLocale(); - } - - public static TestInit init() throws Exception { - TestInit t = new TestInit(); - t.setUp(); - return t; - } - - static File getTestFolder() { - File testFolder = new File("temporaryTestFolder"); - testFolder.mkdir(); - return testFolder; - } - - public static UUID getServerUUID() { - return serverUUID; - } - - private void setUp() throws Exception { - planMock = PowerMockito.mock(Plan.class); - - StaticHolder.register(Plan.class, planMock); - StaticHolder.register(planMock); - - // Hacks to make APF find classes - StaticHolder.register(IPlugin.class, planMock); - StaticHolder.saveInstance(this.getClass(), Plan.class); - StaticHolder.saveInstance(PowerMockRunner.class, Plan.class); - - Log.setDebugMode("console"); - - File testFolder = getTestFolder(); - when(planMock.getDataFolder()).thenReturn(testFolder); - - // Files - File config = new File(getClass().getResource("/config.yml").getPath()); - when(planMock.getResource("config.yml")).thenReturn(new FileInputStream(config)); - File analysis = new File(getClass().getResource("/web/server.html").getPath()); - when(planMock.getResource("/web/server.html")).thenReturn(new FileInputStream(analysis)); - File player = new File(getClass().getResource("/web/player.html").getPath()); - when(planMock.getResource("/web/player.html")).thenReturn(new FileInputStream(player)); - - File tempConfigFile = new File(planMock.getDataFolder(), "config.yml"); - Config iConfig = new Config(tempConfigFile, FileUtil.lines(planMock, "config.yml")) { - @Override - public void save() throws IOException { - } - }; - when(planMock.getMainConfig()).thenReturn(iConfig); - - Server mockServer = mockServer(); - - when(planMock.getServer()).thenReturn(mockServer); - - // Test log settings - when(planMock.getLogger()).thenReturn(Logger.getGlobal()); - Settings.DEBUG.setValue(true); - - ServerVariableHolder serverVariableHolder = new ServerVariableHolder(mockServer); - - when(planMock.getVariable()).thenReturn(serverVariableHolder); - BukkitServerInfoManager bukkitServerInfoManager = PowerMockito.mock(BukkitServerInfoManager.class); - - DataCache dataCache = new DataCache(planMock) { - @Override - public String getName(UUID uuid) { - return ""; - } - }; - when(planMock.getDataCache()).thenReturn(dataCache); - - when(bukkitServerInfoManager.getServerUUID()).thenReturn(serverUUID); - when(planMock.getServerUuid()).thenReturn(serverUUID); - when(planMock.getServerInfoManager()).thenReturn(bukkitServerInfoManager); - ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK); - when(planMock.getColorScheme()).thenReturn(cs); - initLocale(null); - - RunnableFactory.activateTestMode(); - } - - private Server mockServer() { - Server mockServer = PowerMockito.mock(Server.class); - - OfflinePlayer[] ops = new OfflinePlayer[]{MockUtils.mockPlayer(), MockUtils.mockPlayer2()}; - - when(mockServer.getIp()).thenReturn("0.0.0.0"); - when(mockServer.getMaxPlayers()).thenReturn(20); - when(mockServer.getName()).thenReturn("Bukkit"); - when(mockServer.getOfflinePlayers()).thenReturn(ops); - ConsoleCommandSender sender = mockServerCmdSender(); - when(mockServer.getConsoleSender()).thenReturn(sender); - return mockServer; - } - - private ConsoleCommandSender mockServerCmdSender() { - return new ConsoleCommandSender() { - @Override - public void sendMessage(String s) { - System.out.println("Log: " + s); - } - - @Override - public void sendMessage(String[] strings) { - for (String string : strings) { - sendMessage(string); - } - } - - @Override - public Server getServer() { - return null; - } - - @Override - public String getName() { - return null; - } - - @Override - public Spigot spigot() { - return null; - } - - @Override - public boolean isConversing() { - return false; - } - - @Override - public void acceptConversationInput(String s) { - - } - - @Override - public boolean beginConversation(Conversation conversation) { - return false; - } - - @Override - public void abandonConversation(Conversation conversation) { - - } - - @Override - public void abandonConversation(Conversation conversation, ConversationAbandonedEvent conversationAbandonedEvent) { - - } - - @Override - public void sendRawMessage(String s) { - - } - - @Override - public boolean isPermissionSet(String s) { - return false; - } - - @Override - public boolean isPermissionSet(Permission permission) { - return false; - } - - @Override - public boolean hasPermission(String s) { - return false; - } - - @Override - public boolean hasPermission(Permission permission) { - return false; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, int i) { - return null; - } - - @Override - public void removeAttachment(PermissionAttachment permissionAttachment) { - - } - - @Override - public void recalculatePermissions() { - - } - - @Override - public Set getEffectivePermissions() { - return null; - } - - @Override - public boolean isOp() { - return false; - } - - @Override - public void setOp(boolean b) { - - } - }; - } - - private YamlConfiguration mockConfig() throws IOException, InvalidConfigurationException { - File configFile = new File(getClass().getResource("/config.yml").getPath()); - YamlConfiguration configuration = new YamlConfiguration(); - configuration.load(configFile.getAbsolutePath()); - return configuration; - } - - public Plan getPlanMock() { - return planMock; - } -} diff --git a/Plan/test/test/java/utils/TestUtils.java b/Plan/test/test/java/utils/TestUtils.java deleted file mode 100644 index 09e3be2bf1..0000000000 --- a/Plan/test/test/java/utils/TestUtils.java +++ /dev/null @@ -1,18 +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 test.java.utils; - -import java.lang.reflect.Field; - -/** - * @author Fuzzlemann - */ -public class TestUtils { - public static String getStringFieldValue(Enum enumeration, String modifier) throws NoSuchFieldException, IllegalAccessException { - Field field = enumeration.getClass().getDeclaredField(modifier); - field.setAccessible(true); - return (String) field.get(enumeration); - } -} From b5f16a44000ad7429a1bc377516b7e7a8969d51d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 11 Jan 2018 16:26:12 +0200 Subject: [PATCH 002/166] Removed Google Guava from PageCache #218 --- .../webserver/pagecache/PageCache.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageCache.java index 583cb448f9..3f29bffba9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageCache.java @@ -2,9 +2,8 @@ import com.djrapitops.plan.systems.webserver.response.InspectPageResponse; import com.djrapitops.plan.systems.webserver.response.Response; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; +import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; @@ -14,16 +13,13 @@ * It caches all Responses with their matching identifiers. * This reduces CPU cycles and the time to wait for loading the pages. * This is especially useful in situations where multiple clients are accessing the server. - *

- * This cache uses the Google Guava {@link Cache}. * * @author Fuzzlemann * @since 3.6.0 */ public class PageCache { - private static final Cache pageCache = CacheBuilder.newBuilder() - .build(); + private static final Map pageCache = new HashMap<>(); /** * Constructor used to hide the public constructor @@ -65,7 +61,7 @@ public static Response loadPage(String identifier, PageLoader loader) { * @return The Response that was cached or {@code null} if it wasn't */ public static Response loadPage(String identifier) { - return pageCache.getIfPresent(identifier); + return pageCache.get(identifier); } /** @@ -104,7 +100,7 @@ public static void cachePage(String identifier, PageLoader loader) { * @return true if the page is cached */ public static boolean isCached(String identifier) { - return pageCache.asMap().containsKey(identifier); + return pageCache.containsKey(identifier); } /** @@ -113,11 +109,9 @@ public static boolean isCached(String identifier) { * @param filter a predicate which returns true for entries to be removed */ public static void removeIf(Predicate filter) { - Map pageCacheMap = pageCache.asMap(); - - for (String identifier : pageCacheMap.keySet()) { + for (String identifier : pageCache.keySet()) { if (filter.test(identifier)) { - pageCache.invalidate(identifier); + pageCache.remove(identifier); } } } @@ -126,6 +120,6 @@ public static void removeIf(Predicate filter) { * Clears the cache from all its contents. */ public static void clearCache() { - pageCache.invalidateAll(); + pageCache.clear(); } } From 96def3ddbb1f5faf1604c14970378a94d7f6be1d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 11 Jan 2018 16:27:53 +0200 Subject: [PATCH 003/166] Removed Google Guava from GeolocationCache #218 --- .../plan/systems/cache/GeolocationCache.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java index c2829d6b33..4a642989d0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java @@ -1,8 +1,7 @@ package com.djrapitops.plan.systems.cache; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.PlanPlugin; import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; import com.maxmind.geoip2.DatabaseReader; import com.maxmind.geoip2.exception.GeoIp2Exception; import com.maxmind.geoip2.model.CountryResponse; @@ -15,6 +14,8 @@ import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; +import java.util.HashMap; +import java.util.Map; import java.util.zip.GZIPInputStream; /** @@ -31,8 +32,7 @@ public class GeolocationCache { private static File geolocationDB = new File(PlanPlugin.getInstance().getDataFolder(), "GeoIP.dat"); - private static final Cache geolocationCache = CacheBuilder.newBuilder() - .build(); + private static final Map geolocationCache = new HashMap<>(); /** * Constructor used to hide the public constructor @@ -124,7 +124,7 @@ public static void checkDB() throws IOException { * @return The cached country, {@code null} if the country is not cached */ private static String getCachedCountry(String ipAddress) { - return geolocationCache.getIfPresent(ipAddress); + return geolocationCache.get(ipAddress); } /** @@ -134,13 +134,13 @@ private static String getCachedCountry(String ipAddress) { * @return true if the IP Address is cached */ public static boolean isCached(String ipAddress) { - return geolocationCache.asMap().containsKey(ipAddress); + return geolocationCache.containsKey(ipAddress); } /** * Clears the cache */ public static void clearCache() { - geolocationCache.invalidateAll(); + geolocationCache.clear(); } } From f524568c392b40753bab4cc0308818d34e2ca9a3 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 11 Jan 2018 16:29:02 +0200 Subject: [PATCH 004/166] Bukkit & Bungee systems --- .../djrapitops/plan/system/BukkitSystem.java | 24 +++++++++++++++++++ .../djrapitops/plan/system/BungeeSystem.java | 24 +++++++++++++++++++ .../settings/config/BukkitConfigSystem.java | 5 ---- .../settings/config/BungeeConfigSystem.java | 5 ---- .../system/settings/config/ConfigSystem.java | 6 ++--- 5 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java new file mode 100644 index 0000000000..af6032991d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -0,0 +1,24 @@ +/* + * 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; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; + +/** + * Represents PlanSystem for Plan. + * + * @author Rsl1122 + */ +public class BukkitSystem extends PlanSystem { + + public BukkitSystem(Plan plugin) { + versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); + fileSystem = new FileSystem(plugin); + configSystem = new BukkitConfigSystem(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java new file mode 100644 index 0000000000..d516d5f7df --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -0,0 +1,24 @@ +/* + * 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; + +import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; + +/** + * Represents PlanSystem for PlanBungee. + * + * @author Rsl1122 + */ +public class BungeeSystem extends PlanSystem { + + public BungeeSystem(PlanBungee plugin) { + versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); + fileSystem = new FileSystem(plugin); + configSystem = new BungeeConfigSystem(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java index 23aedbdb11..509141b312 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java @@ -6,7 +6,6 @@ import com.djrapitops.plan.system.file.FileSystem; -import java.io.File; import java.io.IOException; /** @@ -16,10 +15,6 @@ */ public class BukkitConfigSystem extends ConfigSystem { - public BukkitConfigSystem(File configFile) { - super(configFile); - } - @Override protected void copyDefaults() throws IOException { config.copyDefaults(FileSystem.readFromResource("config.yml")); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java index 1948bd052d..2b0d31671e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java @@ -6,7 +6,6 @@ import com.djrapitops.plan.system.file.FileSystem; -import java.io.File; import java.io.IOException; /** @@ -16,10 +15,6 @@ */ public class BungeeConfigSystem extends ConfigSystem { - public BungeeConfigSystem(File configFile) { - super(configFile); - } - @Override protected void copyDefaults() throws IOException { config.copyDefaults(FileSystem.readFromResource("bungeeconfig.yml")); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index 426931bc8d..368f2ba627 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -8,12 +8,12 @@ import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; -import java.io.File; import java.io.IOException; /** @@ -27,8 +27,8 @@ public abstract class ConfigSystem implements SubSystem { protected final Locale locale; protected final Theme theme; - public ConfigSystem(File configFile) { - config = new Config(configFile); + public ConfigSystem() { + config = new Config(FileSystem.getConfigFile()); locale = new Locale(); theme = new Theme(); } From 11cb29f7f832fd69de281c2a718f285e6c8e05a5 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 11 Jan 2018 16:37:16 +0200 Subject: [PATCH 005/166] Started refactoring WebServer --- .../main/java/com/djrapitops/plan/Plan.java | 16 ++-- .../java/com/djrapitops/plan/PlanBungee.java | 12 +-- .../java/com/djrapitops/plan/PlanPlugin.java | 3 +- .../plan/command/commands/DevCommand.java | 4 +- .../commands/manage/ManageSetupCommand.java | 6 +- .../webserver/APIRequestHandler.java | 6 +- .../webserver/APIResponseHandler.java | 17 ++-- .../webserver/Request.java | 2 +- .../webserver/RequestHandler.java | 11 ++- .../webserver/ResponseHandler.java | 20 ++--- .../webserver/WebServer.java | 87 +++++++++---------- .../webserver/WebServerSystem.java | 3 +- .../webserver/pagecache/PageCache.java | 6 +- .../webserver/pagecache/PageId.java | 2 +- .../webserver/pagecache/PageLoader.java | 4 +- .../response/AnalysisPageResponse.java | 2 +- .../webserver/response/CSSResponse.java | 2 +- .../webserver/response/DebugPageResponse.java | 5 +- .../webserver/response/ErrorResponse.java | 2 +- .../webserver/response/FileResponse.java | 2 +- .../webserver/response/ForbiddenResponse.java | 2 +- .../response/InspectPageResponse.java | 2 +- .../response/InternalErrorResponse.java | 2 +- .../response/JavaScriptResponse.java | 2 +- .../webserver/response/NotFoundResponse.java | 2 +- .../response/PlayersPageResponse.java | 5 +- .../response/PromptAuthorizationResponse.java | 2 +- .../webserver/response/RedirectResponse.java | 2 +- .../webserver/response/Response.java | 2 +- .../webserver/response/ResponseType.java | 2 +- .../response/api/BadRequestResponse.java | 4 +- .../webserver/response/api/JsonResponse.java | 6 +- .../response/api/SuccessResponse.java | 4 +- .../webserver/webapi/WebAPI.java | 15 ++-- .../webserver/webapi/WebAPIManager.java | 2 +- .../webapi/bukkit/AnalysisReadyWebAPI.java | 6 +- .../webapi/bukkit/AnalyzeWebAPI.java | 6 +- .../webapi/bukkit/ConfigurationWebAPI.java | 6 +- .../webapi/bukkit/InspectWebAPI.java | 6 +- .../webapi/bukkit/IsOnlineWebAPI.java | 6 +- .../RequestInspectPluginsTabBukkitWebAPI.java | 6 +- .../webapi/bungee/IsCachedWebAPI.java | 6 +- .../webapi/bungee/PostHtmlWebAPI.java | 14 +-- .../bungee/PostInspectPluginsTabWebAPI.java | 6 +- .../bungee/PostNetworkPageContentWebAPI.java | 6 +- .../PostOriginalBukkitSettingsWebAPI.java | 6 +- .../bungee/RequestPluginsTabWebAPI.java | 8 +- .../webapi/bungee/RequestSetupWebAPI.java | 8 +- .../webapi/universal/PingWebAPI.java | 7 +- .../com/djrapitops/plan/systems/Systems.java | 9 +- .../info/BukkitInformationManager.java | 24 ++--- .../info/BungeeInformationManager.java | 19 ++-- .../plan/systems/info/InformationManager.java | 4 +- .../info/server/BungeeServerInfoManager.java | 4 +- .../plan/utilities/analysis/Analysis.java | 6 +- .../utilities/file/export/HtmlExport.java | 4 +- .../utilities/file/export/SpecificExport.java | 7 +- .../plan/data/cache/PageCacheTest.java | 6 +- .../webserver/WebServerTest.java | 2 +- 59 files changed, 215 insertions(+), 233 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/APIRequestHandler.java (90%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/APIResponseHandler.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/Request.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/RequestHandler.java (82%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/ResponseHandler.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/WebServer.java (78%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/WebServerSystem.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/pagecache/PageCache.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/pagecache/PageId.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/pagecache/PageLoader.java (60%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/AnalysisPageResponse.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/CSSResponse.java (85%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/DebugPageResponse.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/ErrorResponse.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/FileResponse.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/ForbiddenResponse.java (91%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/InspectPageResponse.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/InternalErrorResponse.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/JavaScriptResponse.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/NotFoundResponse.java (91%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/PlayersPageResponse.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/PromptAuthorizationResponse.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/RedirectResponse.java (81%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/Response.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/ResponseType.java (90%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/api/BadRequestResponse.java (75%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/api/JsonResponse.java (71%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/response/api/SuccessResponse.java (74%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/WebAPI.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/WebAPIManager.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bukkit/AnalysisReadyWebAPI.java (86%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bukkit/AnalyzeWebAPI.java (86%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bukkit/ConfigurationWebAPI.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bukkit/InspectWebAPI.java (85%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bukkit/IsOnlineWebAPI.java (87%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java (89%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bungee/IsCachedWebAPI.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bungee/PostHtmlWebAPI.java (88%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java (91%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java (88%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java (91%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bungee/RequestPluginsTabWebAPI.java (90%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/bungee/RequestSetupWebAPI.java (89%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/webserver/webapi/universal/PingWebAPI.java (89%) rename Plan/test/main/java/com/djrapitops/plan/{systems => system}/webserver/WebServerTest.java (96%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index b0d311b8bb..a66d7aa30f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -24,16 +24,21 @@ import com.djrapitops.plan.command.PlanCommand; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.config.ConfigSystem; +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.system.webserver.pagecache.PageCache; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.GeolocationCache; -import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.ImporterManager; @@ -42,12 +47,7 @@ import com.djrapitops.plan.systems.listeners.*; import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plan.systems.processing.importing.importers.OfflinePlayerImporter; -import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; -import com.djrapitops.plan.systems.webserver.WebServer; -import com.djrapitops.plan.systems.webserver.WebServerSystem; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index a521c7d9ef..23010b2904 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -6,25 +6,25 @@ import com.djrapitops.plan.command.PlanBungeeCommand; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; +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.Systems; import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.listeners.BungeePlayerListener; import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; -import com.djrapitops.plan.systems.webserver.WebServer; -import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index efc80648f8..ab4e7b5147 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -6,10 +6,10 @@ import com.djrapitops.plan.database.Database; import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.systems.webserver.WebServer; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.config.Config; @@ -25,6 +25,7 @@ * @author Rsl1122 */ public interface PlanPlugin extends IPlugin { + @Deprecated Database getDB(); ServerVariableHolder getVariable(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index a56ae6a5bb..ec5a068d11 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -8,8 +8,8 @@ import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebAPI; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI; 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/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index f31722cd7e..5f3b0bcff2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -3,11 +3,11 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPIForbiddenException; -import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.systems.webserver.webapi.bungee.RequestSetupWebAPI; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.webapi.bungee.RequestSetupWebAPI; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIRequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIRequestHandler.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java index c4d5032aca..a5c515bc3d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIRequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java @@ -2,11 +2,11 @@ * 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.webserver; +package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPIManager; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; import com.sun.net.httpserver.Headers; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java index 325d2dab58..3369474df3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/APIResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java @@ -2,15 +2,14 @@ * 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.webserver; - -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; -import com.djrapitops.plan.systems.webserver.response.*; -import com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; -import com.djrapitops.plan.utilities.MiscUtils; +package com.djrapitops.plan.system.webserver; + +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.response.*; +import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.webapi.WebAPIManager; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/Request.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/Request.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java index 4057f70c28..6b344f02b3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/Request.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.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.systems.webserver; +package com.djrapitops.plan.system.webserver; import com.djrapitops.plugin.utilities.Verify; import com.sun.net.httpserver.Headers; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/RequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java similarity index 82% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/RequestHandler.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java index 94fb92858e..6bf5bba0dd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/RequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java @@ -2,12 +2,11 @@ * 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.webserver; +package com.djrapitops.plan.system.webserver; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.webserver.response.PromptAuthorizationResponse; -import com.djrapitops.plan.systems.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.PromptAuthorizationResponse; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; import com.sun.net.httpserver.Headers; @@ -25,8 +24,8 @@ public class RequestHandler implements HttpHandler { private final ResponseHandler responseHandler; - RequestHandler(PlanPlugin plugin, WebServer webServer) { - responseHandler = new ResponseHandler(plugin, webServer); + RequestHandler(WebServer webServer) { + responseHandler = new ResponseHandler(webServer); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 5ce3ef38cd..15dbe26f6f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -2,17 +2,16 @@ * 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.webserver; +package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; -import com.djrapitops.plan.systems.webserver.response.*; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.response.*; import com.djrapitops.plan.utilities.PassEncryptUtil; import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plugin.api.utility.log.Log; @@ -29,13 +28,10 @@ */ public class ResponseHandler extends APIResponseHandler { - private final PlanPlugin plugin; - private final boolean usingHttps; - public ResponseHandler(PlanPlugin plugin, WebServer webServer) { - super(webServer.getWebAPI()); - this.plugin = plugin; + public ResponseHandler(WebServer webServer) { + super(); this.usingHttps = webServer.isUsingHTTPS(); } @@ -90,7 +86,7 @@ public Response getResponse(Request request) { case "server": if (args.length > 2) { try { - Optional serverUUIDOptional = plugin.getDB().getServerTable().getServerUUID(args[2].replace("%20", " ")); + Optional serverUUIDOptional = PlanPlugin.getInstance().getDB().getServerTable().getServerUUID(args[2].replace("%20", " ")); if (serverUUIDOptional.isPresent()) { serverUUID = serverUUIDOptional.get(); } @@ -134,7 +130,7 @@ private WebUser getUser(String auth) throws SQLException, PassEncryptUtil.Invali String user = userInfo[0]; String passwordRaw = userInfo[1]; - SecurityTable securityTable = plugin.getDB().getSecurityTable(); + SecurityTable securityTable = PlanPlugin.getInstance().getDB().getSecurityTable(); if (!securityTable.userExists(user)) { throw new WebUserAuthException("User Doesn't exist"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java similarity index 78% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index d516b58a91..4a18fc6b59 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -1,13 +1,11 @@ -package com.djrapitops.plan.systems.webserver; +package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.*; -import com.djrapitops.plan.systems.webserver.webapi.bungee.*; -import com.djrapitops.plan.systems.webserver.webapi.universal.PingWebAPI; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Check; @@ -34,51 +32,56 @@ /** * @author Rsl1122 */ -public class WebServer { - - private final PlanPlugin plugin; - private final WebAPIManager webAPI; +public class WebServer implements SubSystem { - private final int port; + private int port; private boolean enabled = false; private HttpServer server; private boolean usingHttps = false; - public WebServer(PlanPlugin plugin) { - this.plugin = plugin; + @Override + public void enable() { this.port = Settings.WEBSERVER_PORT.getNumber(); - webAPI = new WebAPIManager(); - registerWebAPIs(); + PlanPlugin plugin = PlanPlugin.getInstance(); StaticHolder.saveInstance(APIRequestHandler.class, plugin.getClass()); StaticHolder.saveInstance(RequestHandler.class, plugin.getClass()); StaticHolder.saveInstance(ResponseHandler.class, plugin.getClass()); StaticHolder.saveInstance(APIResponseHandler.class, plugin.getClass()); + + initServer(); } - private void registerWebAPIs() { - webAPI.registerNewAPI( - new AnalysisReadyWebAPI(), - new AnalyzeWebAPI(), - new ConfigurationWebAPI(), - new InspectWebAPI(), - new IsOnlineWebAPI(), - new RequestInspectPluginsTabBukkitWebAPI(), - new PingWebAPI() - ); - - webAPI.registerNewAPI( - new IsCachedWebAPI(), - new PostHtmlWebAPI(), - new PostInspectPluginsTabWebAPI(), - new PostNetworkPageContentWebAPI(), - new PostOriginalBukkitSettingsWebAPI(), - new RequestPluginsTabWebAPI(), - new RequestSetupWebAPI() - ); + @Override + public void disable() { + stop(); } + // TODO WebAPIPageHandler +// private void registerWebAPIs() { +// webAPI.registerNewAPI( +// new AnalysisReadyWebAPI(), +// new AnalyzeWebAPI(), +// new ConfigurationWebAPI(), +// new InspectWebAPI(), +// new IsOnlineWebAPI(), +// new RequestInspectPluginsTabBukkitWebAPI(), +// new PingWebAPI() +// ); +// +// webAPI.registerNewAPI( +// new IsCachedWebAPI(), +// new PostHtmlWebAPI(), +// new PostInspectPluginsTabWebAPI(), +// new PostNetworkPageContentWebAPI(), +// new PostOriginalBukkitSettingsWebAPI(), +// new RequestPluginsTabWebAPI(), +// new RequestSetupWebAPI() +// ); +// } + //Log.infoColor("§aWebServer Running in WebAPI-only Mode"); + /** * Starts up the WebServer in a new Thread Pool. */ @@ -103,12 +106,8 @@ public void initServer() { Log.infoColor("§eUser Authorization Disabled! (Not possible over http)"); server = HttpServer.create(new InetSocketAddress(Settings.WEBSERVER_IP.toString(), port), 10); } - if (plugin.getInfoManager().isUsingAnotherWebServer()) { - server.createContext("/", new APIRequestHandler(getWebAPI())); - Log.infoColor("§aWebServer Running in WebAPI-only Mode"); - } else { - server.createContext("/", new RequestHandler(plugin, this)); - } + + server.createContext("/", new RequestHandler(this)); server.setExecutor(new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100))); server.start(); @@ -125,7 +124,7 @@ public void initServer() { private boolean startHttpsServer() { String keyStorePath = Settings.WEBSERVER_CERTIFICATE_PATH.toString(); if (!Paths.get(keyStorePath).isAbsolute()) { - keyStorePath = plugin.getDataFolder() + File.separator + keyStorePath; + keyStorePath = FileSystem.getDataFolder() + File.separator + keyStorePath; } char[] storepass = Settings.WEBSERVER_CERTIFICATE_STOREPASS.toString().toCharArray(); @@ -214,8 +213,4 @@ public boolean isAuthRequired() { public String getAccessAddress() { return isEnabled() ? getProtocol() + "://" + HtmlUtils.getIP() : Settings.EXTERNAL_WEBSERVER_LINK.toString(); } - - public WebAPIManager getWebAPI() { - return webAPI; - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServerSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java index 9bb59907a1..b581b5fde9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java @@ -2,12 +2,11 @@ * 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.webserver; +package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.systems.Systems; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Check; /** diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageCache.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageCache.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageCache.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageCache.java index 3f29bffba9..d9adebf4d9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageCache.java @@ -1,7 +1,7 @@ -package com.djrapitops.plan.systems.webserver.pagecache; +package com.djrapitops.plan.system.webserver.pagecache; -import com.djrapitops.plan.systems.webserver.response.InspectPageResponse; -import com.djrapitops.plan.systems.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.InspectPageResponse; +import com.djrapitops.plan.system.webserver.response.Response; import java.util.HashMap; import java.util.Map; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageId.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageId.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java index 51d12471c8..35d5fefeb7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageId.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.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.systems.webserver.pagecache; +package com.djrapitops.plan.system.webserver.pagecache; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageLoader.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageLoader.java similarity index 60% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageLoader.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageLoader.java index dff2a8e92d..4c60ce917b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/pagecache/PageLoader.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageLoader.java @@ -1,6 +1,6 @@ -package com.djrapitops.plan.systems.webserver.pagecache; +package com.djrapitops.plan.system.webserver.pagecache; -import com.djrapitops.plan.systems.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.Response; /** * This interface is used for providing the method to load the page. diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/AnalysisPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/AnalysisPageResponse.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/AnalysisPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/AnalysisPageResponse.java index 9af6991c2c..df7e21c40f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/AnalysisPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/AnalysisPageResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.AnalysisData; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/CSSResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java similarity index 85% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/CSSResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java index 247ff3ef49..a58e24e9fd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/CSSResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.settings.theme.Theme; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DebugPageResponse.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/DebugPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DebugPageResponse.java index 77d77563de..20e32ffc79 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DebugPageResponse.java @@ -2,14 +2,13 @@ * 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.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.info.server.ServerInfo; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.Benchmark; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ErrorResponse.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ErrorResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ErrorResponse.java index a3ec460f09..8924eed88b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ErrorResponse.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.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/FileResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/FileResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java index 6d6dd04141..5b3cadd23f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/FileResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.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.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ForbiddenResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ForbiddenResponse.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ForbiddenResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ForbiddenResponse.java index ebf1a42ddd..739dda270f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ForbiddenResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ForbiddenResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/InspectPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InspectPageResponse.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/InspectPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InspectPageResponse.java index 1a12057dba..36cfa3582b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/InspectPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InspectPageResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.settings.theme.Theme; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/InternalErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InternalErrorResponse.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/InternalErrorResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InternalErrorResponse.java index 2531158cee..f9496b88fd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/InternalErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InternalErrorResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/JavaScriptResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/JavaScriptResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java index 04cfef747d..e9e15ad0dc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/JavaScriptResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/NotFoundResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/NotFoundResponse.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/NotFoundResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/NotFoundResponse.java index e32dd3d6ad..f083edec7a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/NotFoundResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/NotFoundResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PlayersPageResponse.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PlayersPageResponse.java index 02db10151f..71819569ff 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PlayersPageResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.GeoInfo; @@ -6,10 +6,9 @@ import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; import com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PromptAuthorizationResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PromptAuthorizationResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java index ae1de29f72..f15892e74b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PromptAuthorizationResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/RedirectResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/RedirectResponse.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/RedirectResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/RedirectResponse.java index 1b72a2621a..e29e566a0c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/RedirectResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/RedirectResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; /** * @author Rsl1122 diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/Response.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/Response.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java index b5e07411b8..5c00e6438d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/Response.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ResponseType.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ResponseType.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java index 78bc835853..4cbb01aabb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/ResponseType.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.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.systems.webserver.response; +package com.djrapitops.plan.system.webserver.response; /** * //TODO Class Javadoc Comment diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/BadRequestResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java similarity index 75% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/BadRequestResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java index 18c96c5631..fd29437d35 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/BadRequestResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.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.webserver.response.api; +package com.djrapitops.plan.system.webserver.response.api; -import com.djrapitops.plan.systems.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.Response; /** * @author Fuzzlemann diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/JsonResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/JsonResponse.java similarity index 71% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/JsonResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/JsonResponse.java index fd4694a1cf..396f09c0a0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/JsonResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/JsonResponse.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.systems.webserver.response.api; +package com.djrapitops.plan.system.webserver.response.api; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.response.ResponseType; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.ResponseType; import com.google.gson.Gson; /** diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/SuccessResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/SuccessResponse.java similarity index 74% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/SuccessResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/SuccessResponse.java index c69435c30c..97c9c209ef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/api/SuccessResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/SuccessResponse.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.webserver.response.api; +package com.djrapitops.plan.system.webserver.response.api; -import com.djrapitops.plan.systems.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.Response; /** * @author Fuzzlemann diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index de07ebcc4a..a17d1a7985 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -2,18 +2,17 @@ * 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.webserver.webapi; +package com.djrapitops.plan.system.webserver.webapi; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.*; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; -import com.djrapitops.plan.systems.webserver.response.NotFoundResponse; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse; -import com.djrapitops.plan.systems.webserver.response.api.SuccessResponse; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.response.NotFoundResponse; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; +import com.djrapitops.plan.system.webserver.response.api.SuccessResponse; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPIManager.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPIManager.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java index 2048afac5f..2887562ac0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPIManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.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.systems.webserver.webapi; +package com.djrapitops.plan.system.webserver.webapi; import com.djrapitops.plan.utilities.PassEncryptUtil; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalysisReadyWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java similarity index 86% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalysisReadyWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java index cd156f4d86..eff3e7889f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalysisReadyWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java @@ -2,12 +2,12 @@ * 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.webserver.webapi.bukkit; +package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import java.util.Map; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalyzeWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java similarity index 86% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalyzeWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java index cc2033a69f..b5047045a6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/AnalyzeWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java @@ -2,12 +2,12 @@ * 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.webserver.webapi.bukkit; +package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import java.util.Map; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/ConfigurationWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index 1228dfd8be..1b2bf7ab2c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.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.systems.webserver.webapi.bukkit; +package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; @@ -10,8 +10,8 @@ import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.settings.ServerSpecificSettings; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java similarity index 85% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/InspectWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java index e335d5a8d1..7985c5a1d0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/InspectWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java @@ -2,12 +2,12 @@ * 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.webserver.webapi.bukkit; +package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import java.util.Map; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/IsOnlineWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java similarity index 87% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/IsOnlineWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java index 10aa37e81b..6aa8c70411 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/IsOnlineWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java @@ -2,13 +2,13 @@ * 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.webserver.webapi.bukkit; +package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import org.bukkit.entity.Player; import java.util.Map; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java similarity index 89% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java index 7fe7034c90..5fa25b9507 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java @@ -2,13 +2,13 @@ * 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.webserver.webapi.bukkit; +package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BukkitInformationManager; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; import java.util.Map; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/IsCachedWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java index 2f94b412fe..a5b5586462 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/IsCachedWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java @@ -2,14 +2,14 @@ * 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.webserver.webapi.bungee; +package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import java.util.Map; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostHtmlWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java similarity index 88% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostHtmlWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java index 4c473f6814..c257d0b080 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostHtmlWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java @@ -2,18 +2,18 @@ * 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.webserver.webapi.bungee; +package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.response.AnalysisPageResponse; +import com.djrapitops.plan.system.webserver.response.InspectPageResponse; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; -import com.djrapitops.plan.systems.webserver.response.AnalysisPageResponse; -import com.djrapitops.plan.systems.webserver.response.InspectPageResponse; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.lang3.text.StrSubstitutor; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java index b82d80d928..1d89cf8786 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java @@ -2,13 +2,13 @@ * 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.webserver.webapi.bungee; +package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BungeeInformationManager; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import java.util.Map; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java similarity index 88% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java index 5bc53cd01c..f874266a73 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java @@ -2,14 +2,14 @@ * 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.webserver.webapi.bungee; +package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BungeeInformationManager; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; import java.util.Map; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java index fe6299d793..3300ad5862 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java @@ -2,15 +2,15 @@ * 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.webserver.webapi.bungee; +package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index b6ef7c6b9b..465029b0c5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -2,16 +2,16 @@ * 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.webserver.webapi.bungee; +package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; +import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java similarity index 89% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestSetupWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index 6f8f88b1d2..35326754df 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -2,17 +2,17 @@ * 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.webserver.webapi.bungee; +package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.system.webserver.response.ForbiddenResponse; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.server.ServerInfo; -import com.djrapitops.plan.systems.webserver.response.ForbiddenResponse; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/universal/PingWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java similarity index 89% rename from Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/universal/PingWebAPI.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java index 8412914e96..c3afc031f4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/universal/PingWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java @@ -2,17 +2,16 @@ * 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.webserver.webapi.universal; +package com.djrapitops.plan.system.webserver.webapi.universal; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BukkitInformationManager; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.systems.webserver.webapi.WebAPI; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java index 2cd84c3587..a2b4b41a90 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java @@ -9,18 +9,17 @@ import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; +import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; +import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.file.database.PlanBungeeDBSystem; import com.djrapitops.plan.systems.file.database.PlanDBSystem; import com.djrapitops.plan.systems.tasks.PlanBungeeTaskSystem; import com.djrapitops.plan.systems.tasks.PlanTaskSystem; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; -import com.djrapitops.plan.systems.webserver.WebServerSystem; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.lang3.ArrayUtils; 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 index 914c62ec3c..f6492a00c0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -11,23 +11,23 @@ import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.system.settings.Settings; 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.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.response.*; +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.bukkit.RequestInspectPluginsTabBukkitWebAPI; +import com.djrapitops.plan.system.webserver.webapi.bungee.*; +import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.parsing.AnalysisPageParser; import com.djrapitops.plan.systems.info.parsing.InspectPageParser; import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.systems.webserver.WebServer; -import com.djrapitops.plan.systems.webserver.WebServerSystem; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; -import com.djrapitops.plan.systems.webserver.response.*; -import com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.AnalysisReadyWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.AnalyzeWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bungee.*; -import com.djrapitops.plan.systems.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.file.export.HtmlExport; 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 index 14054cc07e..e28a1e1a01 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -10,20 +10,19 @@ import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.response.*; +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.bukkit.InspectWebAPI; +import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI; +import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.parsing.NetworkPageParser; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.info.server.ServerInfo; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; -import com.djrapitops.plan.systems.webserver.response.*; -import com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.AnalysisReadyWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.AnalyzeWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.IsOnlineWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.bungee.RequestPluginsTabWebAPI; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plugin.api.utility.log.ErrorLogger; 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 index bfd2d64f1b..8c6991a1a6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -5,10 +5,10 @@ package com.djrapitops.plan.systems.info; import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; import com.djrapitops.plugin.command.ISender; import java.io.IOException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index 971e05026a..b44f561018 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -10,8 +10,8 @@ import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.database.Database; import com.djrapitops.plan.database.tables.ServerTable; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.ConfigurationWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.universal.PingWebAPI; +import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI; +import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 83b6b6c723..d121b5c87e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -8,17 +8,17 @@ import com.djrapitops.plan.data.plugin.BanData; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.response.ErrorResponse; +import com.djrapitops.plan.system.webserver.response.InternalErrorResponse; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.tasks.PlanTaskSystem; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.systems.webserver.response.ErrorResponse; -import com.djrapitops.plan.systems.webserver.response.InternalErrorResponse; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; 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 2c3b9f3947..f7088db5bc 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 @@ -8,8 +8,8 @@ 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.systems.webserver.response.PlayersPageResponse; -import com.djrapitops.plan.systems.webserver.webapi.bungee.PostHtmlWebAPI; +import com.djrapitops.plan.system.webserver.response.PlayersPageResponse; +import com.djrapitops.plan.system.webserver.webapi.bungee.PostHtmlWebAPI; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.RunnableFactory; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index ff3ef68bc3..f51cf8fc97 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -5,10 +5,9 @@ package com.djrapitops.plan.utilities.file.export; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; -import com.djrapitops.plan.systems.webserver.response.Response; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/PageCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/PageCacheTest.java index 1efd781d8b..5918c40594 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/PageCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/PageCacheTest.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.data.cache; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageLoader; -import com.djrapitops.plan.systems.webserver.response.Response; +import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.PageLoader; +import com.djrapitops.plan.system.webserver.response.Response; import org.junit.Test; import test.utilities.RandomData; diff --git a/Plan/test/main/java/com/djrapitops/plan/systems/webserver/WebServerTest.java b/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java similarity index 96% rename from Plan/test/main/java/com/djrapitops/plan/systems/webserver/WebServerTest.java rename to Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java index 08b657f65b..7887e2c15a 100644 --- a/Plan/test/main/java/com/djrapitops/plan/systems/webserver/WebServerTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.webserver; +package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.Plan; import com.sun.net.httpserver.HttpExchange; From 4d5f2b79b9665105644e28bc689beeae092ea95f Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 12 Jan 2018 11:02:32 +0200 Subject: [PATCH 006/166] Progress on WebServer refactoring --- .../main/java/com/djrapitops/plan/Plan.java | 4 +- .../java/com/djrapitops/plan/PlanPlugin.java | 1 + .../java/com/djrapitops/plan/api/API.java | 14 +- .../java/com/djrapitops/plan/api/PlanAPI.java | 21 +++ .../api/exceptions/WebUserAuthException.java | 22 ++- .../system/webserver/APIResponseHandler.java | 23 +-- .../plan/system/webserver/Request.java | 25 +-- .../plan/system/webserver/RequestHandler.java | 19 +++ .../system/webserver/ResponseHandler.java | 158 +++++++++--------- .../system/webserver/auth/Authentication.java | 18 ++ .../webserver/auth/BasicAuthentication.java | 67 ++++++++ .../system/webserver/auth/FailReason.java | 27 +++ .../system/webserver/pagecache/PageId.java | 2 +- .../{PageCache.java => ResponseCache.java} | 36 ++-- .../webserver/pages/DebugPageHandler.java | 24 +++ .../webserver/pages/DefaultResponses.java | 33 ++++ .../system/webserver/pages/PageHandler.java | 26 +++ .../webserver/pages/PlayerPageHandler.java | 67 ++++++++ .../webserver/pages/PlayersPageHandler.java | 30 ++++ .../webserver/pages/ServerPageHandler.java | 27 +++ .../webserver/pages/TreePageHandler.java | 53 ++++++ .../webserver/response/FileResponse.java | 1 + .../response/PromptAuthorizationResponse.java | 42 ++++- .../response/{ => errors}/ErrorResponse.java | 3 +- .../{ => errors}/ForbiddenResponse.java | 2 +- .../{ => errors}/InternalErrorResponse.java | 2 +- .../{ => errors}/NotFoundResponse.java | 2 +- .../{ => pages}/AnalysisPageResponse.java | 4 +- .../{ => pages}/DebugPageResponse.java | 3 +- .../{ => pages}/InspectPageResponse.java | 3 +- .../{ => pages}/PlayersPageResponse.java | 4 +- .../plan/system/webserver/webapi/WebAPI.java | 10 +- .../webapi/bungee/PostHtmlWebAPI.java | 10 +- .../webapi/bungee/RequestSetupWebAPI.java | 2 +- .../info/BukkitInformationManager.java | 17 +- .../info/BungeeInformationManager.java | 16 +- .../plan/systems/info/InformationManager.java | 4 +- .../info/InspectCacheRequestProcessor.java | 2 +- .../plan/utilities/FormatUtils.java | 27 +++ .../plan/utilities/analysis/Analysis.java | 4 +- .../utilities/file/export/AnalysisExport.java | 2 +- .../utilities/file/export/HtmlExport.java | 2 +- .../utilities/file/export/SpecificExport.java | 6 +- ...eCacheTest.java => ResponseCacheTest.java} | 26 +-- 44 files changed, 687 insertions(+), 204 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java rename Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/{PageCache.java => ResponseCache.java} (74%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => errors}/ErrorResponse.java (92%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => errors}/ForbiddenResponse.java (90%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => errors}/InternalErrorResponse.java (96%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => errors}/NotFoundResponse.java (90%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => pages}/AnalysisPageResponse.java (90%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => pages}/DebugPageResponse.java (98%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => pages}/InspectPageResponse.java (93%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/response/{ => pages}/PlayersPageResponse.java (96%) rename Plan/test/main/java/com/djrapitops/plan/data/cache/{PageCacheTest.java => ResponseCacheTest.java} (60%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index a66d7aa30f..29b72beff7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -35,7 +35,7 @@ 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.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.GeolocationCache; @@ -237,7 +237,7 @@ public ColorScheme getColorScheme() { @Override public void onDisable() { //Clears the page cache - PageCache.clearCache(); + ResponseCache.clearCache(); // Processes unprocessed processors if (processingQueue != null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index ab4e7b5147..902145f993 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -32,6 +32,7 @@ public interface PlanPlugin extends IPlugin { UUID getServerUuid(); + @Deprecated InformationManager getInfoManager(); WebServer getWebServer(); diff --git a/Plan/src/main/java/com/djrapitops/plan/api/API.java b/Plan/src/main/java/com/djrapitops/plan/api/API.java index 306f29e0a5..c47595ddb4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/API.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/API.java @@ -89,7 +89,7 @@ public String getPlayerInspectPageLink(String name) { } /** - * Condition if Players's Inspect page is cached to PageCache. + * Condition if Players's Inspect page is cached to ResponseCache. * * @param uuid UUID of the player. * @return true/false @@ -101,10 +101,10 @@ public boolean isPlayersDataInspectCached(UUID uuid) { } /** - * Condition if Players's Inspect page is cached to PageCache of the providing WebServer. + * Condition if Players's Inspect page is cached to ResponseCache of the providing WebServer. *

- * Using BungeeCord: Will send a {@code IsCachedWebAPI} request to check if the page is in Bungee's PageCache. - * Only Bukkit: Checks PageCache for page. + * Using BungeeCord: Will send a {@code IsCachedWebAPI} request to check if the page is in Bungee's ResponseCache. + * Only Bukkit: Checks ResponseCache for page. * * @param uuid UUID of the player. * @return true/false @@ -114,7 +114,7 @@ public boolean isPlayerHtmlCached(UUID uuid) { } /** - * Cache Players's Inspect page to the PageCache of the providing WebServer. + * Cache Players's Inspect page to the ResponseCache of the providing WebServer. * * @param uuid UUID of the player. * @deprecated use {@code cachePlayerHtml} @@ -125,10 +125,10 @@ public void cacheUserDataToInspectCache(UUID uuid) { } /** - * Cache Players's Inspect page to the PageCache of the providing WebServer. + * Cache Players's Inspect page to the ResponseCache of the providing WebServer. *

* Using BungeeCord: Will send a {@code PostHtmlWebAPI} request after calculating the inspect page. - * Only Bukkit: Calculates inspect page and places it in the PageCache. + * Only Bukkit: Calculates inspect page and places it in the ResponseCache. * * @param uuid UUID of the player. * @deprecated use {@code cachePlayerHtml} diff --git a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java new file mode 100644 index 0000000000..e6c36f03a3 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java @@ -0,0 +1,21 @@ +/* + * 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.data.plugin.PluginData; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public interface PlanAPI { + + static PlanAPI getInstance() { + throw new IllegalAccessError("Not yet implemented"); // TODO + } + + void registerPluginData(PluginData pluginData); +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java index 892bc46811..1616a186e9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java @@ -1,27 +1,31 @@ -/* +/* * 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.exceptions; +import com.djrapitops.plan.system.webserver.auth.FailReason; + /** * Thrown when WebUser can not be authorized (WebServer). * * @author Rsl1122 */ public class WebUserAuthException extends Exception { - public WebUserAuthException() { - } - public WebUserAuthException(String message) { - super(message); - } + private final FailReason failReason; - public WebUserAuthException(String message, Throwable cause) { - super(message, cause); + public WebUserAuthException(FailReason failReason) { + super(failReason.getReason()); + this.failReason = failReason; } public WebUserAuthException(Throwable cause) { - super(cause); + super(FailReason.ERROR.getReason(), cause); + this.failReason = FailReason.ERROR; + } + + public FailReason getFailReason() { + return failReason; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java index 3369474df3..005db193b9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java @@ -4,10 +4,13 @@ */ package com.djrapitops.plan.system.webserver; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.response.*; import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; +import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; +import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.system.webserver.webapi.WebAPIManager; import com.djrapitops.plan.utilities.html.Html; @@ -40,29 +43,29 @@ Response getAPIResponse(Request request) throws IOException { String[] args = target.split("/"); if ("/favicon.ico".equalsIgnoreCase(target)) { - return PageCache.loadPage(PageId.FAVICON_REDIRECT.id(), () -> new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); + return ResponseCache.loadResponse(PageId.FAVICON_REDIRECT.id(), () -> new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); } if ("/debug".equalsIgnoreCase(target)) { return new DebugPageResponse(); } if (target.endsWith(".css")) { - return PageCache.loadPage(PageId.CSS.of(target), () -> new CSSResponse(target)); + return ResponseCache.loadResponse(PageId.CSS.of(target), () -> new CSSResponse(target)); } if (target.endsWith(".js")) { - return PageCache.loadPage(PageId.JS.of(target), () -> new JavaScriptResponse(target)); + return ResponseCache.loadResponse(PageId.JS.of(target), () -> new JavaScriptResponse(target)); } if (args.length < 2 || !"api".equals(args[1])) { String address = PlanPlugin.getInstance().getInfoManager().getWebServerAddress() + target; String link = Html.LINK.parse(address, address); - return PageCache.loadPage(PageId.ERROR.of("Non-API Request"), () -> new NotFoundResponse("WebServer is in WebAPI-only mode, " + + return ResponseCache.loadResponse(PageId.ERROR.of("Non-API Request"), () -> new NotFoundResponse("WebServer is in WebAPI-only mode, " + "connect to the Bungee server instead: " + link)); } if (args.length < 3) { String error = "API Method not specified"; - return PageCache.loadPage(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); + return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); } String method = args[2]; @@ -74,7 +77,7 @@ Response getAPIResponse(Request request) throws IOException { if (requestBody == null) { String error = "Error at reading the POST request." + "Note that the Encoding must be ISO-8859-1."; - return PageCache.loadPage(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); + return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); } Map variables = WebAPI.readVariables(requestBody); @@ -93,7 +96,7 @@ Response getAPIResponse(Request request) throws IOException { if (!checkKey(sender)) { String error = "Server Key not given or invalid"; Log.debug("Request had invalid Server key: " + sender); - return PageCache.loadPage(PageId.ERROR.of(error), () -> { + return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> { ForbiddenResponse forbidden = new ForbiddenResponse(); forbidden.setContent(error); return forbidden; @@ -103,7 +106,7 @@ Response getAPIResponse(Request request) throws IOException { if (!webAPI.isAuthorized(accessKey)) { String error = "Access Key invalid"; Log.debug("Request had invalid Access key: " + accessKey); - return PageCache.loadPage(PageId.ERROR.of(error), () -> { + return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> { ForbiddenResponse forbidden = new ForbiddenResponse(); forbidden.setContent(error); return forbidden; @@ -117,7 +120,7 @@ Response getAPIResponse(Request request) throws IOException { if (api == null) { String error = "API Method not found"; Log.debug(error); - return PageCache.loadPage(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); + return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); } Response response = api.processRequest(PlanPlugin.getInstance(), variables); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java index 6b344f02b3..f7825e0308 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java @@ -4,12 +4,14 @@ */ package com.djrapitops.plan.system.webserver; +import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plugin.utilities.Verify; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import java.io.InputStream; import java.util.List; +import java.util.Optional; /** * Represents a HttpExchange Request. @@ -19,7 +21,7 @@ * @author Rsl1122 */ public class Request { - private String auth; + private Authentication auth; private final String requestMethod; private final String target; @@ -30,27 +32,14 @@ public Request(HttpExchange exchange) { this.target = exchange.getRequestURI().toString(); this.exchange = exchange; - setAuth(exchange.getRequestHeaders()); } - public String getAuth() { - return auth; + public Optional getAuth() { + return Optional.ofNullable(auth); } - public void setAuth(Headers requestHeaders) { - List authorization = requestHeaders.get("Authorization"); - if (Verify.isEmpty(authorization)) { - return; - } - - String authLine = authorization.get(0); - if (authLine.contains("Basic ")) { - auth = authLine.split(" ")[1]; - } - } - - public boolean hasAuth() { - return auth != null; + public void setAuth(Authentication authentication) { + auth = authentication; } public String getRequestMethod() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java index 6bf5bba0dd..5b6082e80d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java @@ -5,15 +5,19 @@ package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.auth.Authentication; +import com.djrapitops.plan.system.webserver.auth.BasicAuthentication; import com.djrapitops.plan.system.webserver.response.PromptAuthorizationResponse; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.utilities.Verify; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import java.io.IOException; +import java.util.List; /** * HttpHandler for WebServer request management. @@ -30,8 +34,11 @@ public class RequestHandler implements HttpHandler { @Override public void handle(HttpExchange exchange) { + Headers requestHeaders = exchange.getRequestHeaders(); Headers responseHeaders = exchange.getResponseHeaders(); Request request = new Request(exchange); + request.setAuth(getAuthorization(requestHeaders)); + String requestString = request.toString(); Benchmark.start("", requestString); int responseCode = -1; @@ -55,5 +62,17 @@ public void handle(HttpExchange exchange) { } } + private Authentication getAuthorization(Headers requestHeaders) { + List authorization = requestHeaders.get("Authorization"); + if (Verify.isEmpty(authorization)) { + return null; + } + + String authLine = authorization.get(0); + if (authLine.contains("Basic ")) { + return new BasicAuthentication(authLine.split(" ")[1]); + } + return null; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 15dbe26f6f..81e24d2b6f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -9,49 +9,104 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.auth.Authentication; +import com.djrapitops.plan.system.webserver.auth.FailReason; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pages.*; import com.djrapitops.plan.system.webserver.response.*; +import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; +import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; +import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; +import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse; +import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; +import com.djrapitops.plan.system.webserver.response.pages.PlayersPageResponse; import com.djrapitops.plan.utilities.PassEncryptUtil; import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; -import java.util.Base64; -import java.util.Optional; -import java.util.UUID; +import java.util.*; /** * Handles choosing of the correct response to a request. * * @author Rsl1122 */ -public class ResponseHandler extends APIResponseHandler { +public class ResponseHandler extends TreePageHandler { + + private final boolean authRequired; private final boolean usingHttps; public ResponseHandler(WebServer webServer) { - super(); + authRequired = webServer.isAuthRequired(); this.usingHttps = webServer.isUsingHTTPS(); } + public void registerDefaultPages() { + registerPage("favicon.ico", new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); + registerPage("debug", new DebugPageHandler()); + registerPage("players", new PlayersPageHandler()); + registerPage("player", new PlayerPageHandler()); + + ServerPageHandler serverPageHandler = new ServerPageHandler(); + registerPage("network", serverPageHandler); + registerPage("server", serverPageHandler); + } + + public void registerWebAPIPages() { + + } + public Response getResponse(Request request) { - String target = request.getTarget(); - String[] args = target.split("/"); + String targetString = request.getTarget(); + List target = Arrays.asList(targetString.split("/")); + target.remove(0); + try { + Optional authentication = Optional.empty(); + if (authRequired) { + authentication = request.getAuth(); + if (!authentication.isPresent() && usingHttps) { + return DefaultResponses.BASIC_AUTH.get(); + } + + if (authentication.isPresent() && !authentication.get().isAuthorized(null)) { + return forbiddenResponse(0, 0); + } + } + + PageHandler pageHandler = getPageHandler(target); + if (pageHandler == null) { + if (targetString.endsWith(".css")) { + return ResponseCache.loadResponse(PageId.CSS.of(targetString), () -> new CSSResponse(targetString)); + } + if (targetString.endsWith(".js")) { + return ResponseCache.loadResponse(PageId.JS.of(targetString), () -> new JavaScriptResponse(targetString)); + } + return DefaultResponses.NOT_FOUND.get(); + } else { + if (authentication.isPresent() && authentication.get().isAuthorized(pageHandler.getPermission())) { + return forbiddenResponse(0, 0); + } + return pageHandler.getResponse(request, target); + } + } catch (WebUserAuthException e) { + return PromptAuthorizationResponse.getBasicAuthResponse(e); + } catch (Exception e) { + Log.toLog(this.getClass().getName(), e); + return new InternalErrorResponse(e, request.getTarget()); + } + try { - if ("/favicon.ico".equals(target)) { - return PageCache.loadPage(PageId.FAVICON_REDIRECT.id(), () -> new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); + if ("/favicon.ico".equals(targetString)) { + return ResponseCache.loadResponse(PageId.FAVICON_REDIRECT.id(), () -> new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); } if (request.isAPIRequest()) { return getAPIResponse(request); } - if (target.endsWith(".css")) { - return PageCache.loadPage(PageId.CSS.of(target), () -> new CSSResponse(target)); - } - if (target.endsWith(".js")) { - return PageCache.loadPage(PageId.JS.of(target), () -> new JavaScriptResponse(target)); - } UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); @@ -61,7 +116,7 @@ public Response getResponse(Request request) { } WebUser user = getUser(request.getAuth()); - int required = getRequiredPermLevel(target, user.getName()); + int required = getRequiredPermLevel(targetString, user.getName()); int permLevel = user.getPermLevel(); if (!isAuthorized(required, permLevel)) { @@ -79,7 +134,7 @@ public Response getResponse(Request request) { case "debug": return new DebugPageResponse(); case "players": - return PageCache.loadPage(PageId.PLAYERS.id(), PlayersPageResponse::new); + return ResponseCache.loadResponse(PageId.PLAYERS.id(), PlayersPageResponse::new); case "player": return playerResponse(args); case "network": @@ -100,7 +155,7 @@ public Response getResponse(Request request) { } } catch (WebUserAuthException e) { - return PageCache.loadPage(PageId.AUTH_PROMPT.id(), PromptAuthorizationResponse::new); + return ResponseCache.loadResponse(PageId.AUTH_PROMPT.id(), PromptAuthorizationResponse::getBasicAuthResponse); } catch (Exception e) { Log.toLog(this.getClass().getName(), e); return new InternalErrorResponse(e, request.getTarget()); @@ -108,7 +163,7 @@ public Response getResponse(Request request) { } private Response forbiddenResponse(int required, int permLevel) { - return PageCache.loadPage(PageId.FORBIDDEN.id(), () -> + return ResponseCache.loadResponse(PageId.FORBIDDEN.of(required + "/" + permLevel), () -> new ForbiddenResponse("Unauthorized User.
" + "Make sure your user has the correct access level.
" + "This page requires permission level of " + required + ",
" @@ -119,31 +174,6 @@ private boolean isAuthorized(int requiredPermLevel, int permLevel) { return permLevel <= requiredPermLevel; } - private WebUser getUser(String auth) throws SQLException, PassEncryptUtil.InvalidHashException, PassEncryptUtil.CannotPerformOperationException, WebUserAuthException { - Base64.Decoder decoder = Base64.getDecoder(); - byte[] decoded = decoder.decode(auth); - String[] userInfo = new String(decoded).split(":"); - if (userInfo.length != 2) { - throw new WebUserAuthException("User and Password not specified"); - } - - String user = userInfo[0]; - String passwordRaw = userInfo[1]; - - SecurityTable securityTable = PlanPlugin.getInstance().getDB().getSecurityTable(); - if (!securityTable.userExists(user)) { - throw new WebUserAuthException("User Doesn't exist"); - } - - WebUser webUser = securityTable.getWebUser(user); - - boolean correctPass = PassEncryptUtil.verifyPassword(passwordRaw, webUser.getSaltedPassHash()); - if (!correctPass) { - throw new WebUserAuthException("User and Password do not match"); - } - return webUser; - } - private int getRequiredPermLevel(String target, String user) { String[] t = target.split("/"); if (t.length < 2) { @@ -180,7 +210,7 @@ private Response rootPageResponse(WebUser user, UUID serverUUID) { case 0: return serverResponse(serverUUID); case 1: - return PageCache.loadPage(PageId.PLAYERS.id(), PlayersPageResponse::new); + return ResponseCache.loadResponse(PageId.PLAYERS.id(), PlayersPageResponse::new); case 2: return playerResponse(new String[]{"", "", user.getName()}); default: @@ -189,44 +219,12 @@ private Response rootPageResponse(WebUser user, UUID serverUUID) { } private Response serverResponse(UUID serverUUID) { - return PageCache.loadPage(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(plugin.getInfoManager())); - } - - private Response playerResponse(String[] args) { - if (args.length < 3) { - return PageCache.loadPage(PageId.NOT_FOUND.id(), NotFoundResponse::new); - } - - String playerName = args[2].trim(); - UUID uuid = UUIDUtility.getUUIDOf(playerName); - - if (uuid == null) { - String error = "Player has no UUID"; - return PageCache.loadPage(PageId.NOT_FOUND.of(error), () -> new NotFoundResponse(error)); - } - - if (plugin.getDB().wasSeenBefore(uuid)) { - plugin.getInfoManager().cachePlayer(uuid); - Response response = PageCache.loadPage(PageId.PLAYER.of(uuid)); - // TODO Create a new method that places NotFoundResponse to PageCache instead. - if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) { - PageCache.cachePage(PageId.PLAYER.of(uuid), () -> { - try { - return new InspectPageResponse(plugin.getInfoManager(), uuid); - } catch (ParseException e) { - return new InternalErrorResponse(e, this.getClass().getName()); - } - }); - response = PageCache.loadPage(PageId.PLAYER.of(uuid)); - } - return response; - } - return new NotFoundResponse("Player has not played on this server."); + return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(plugin.getInfoManager())); } private Response notFoundResponse() { String error = "404 Not Found"; - return PageCache.loadPage(PageId.NOT_FOUND.of("Wrong Page"), () -> { + return ResponseCache.loadResponse(PageId.NOT_FOUND.of("Wrong Page"), () -> { String url = plugin.getInfoManager().getWebServerAddress(); return new NotFoundResponse("Make sure you're accessing a link given by a command, Examples:

" + "

" + url + "/player/Playername
" + diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java new file mode 100644 index 0000000000..55a459c106 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java @@ -0,0 +1,18 @@ +/* + * 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.webserver.auth; + +import com.djrapitops.plan.api.exceptions.WebUserAuthException; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public interface Authentication { + + boolean isAuthorized(String permission) throws WebUserAuthException; + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java new file mode 100644 index 0000000000..d0f141f8a3 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java @@ -0,0 +1,67 @@ +/* + * 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.webserver.auth; + +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.data.WebUser; +import com.djrapitops.plan.database.tables.SecurityTable; +import com.djrapitops.plan.utilities.PassEncryptUtil; + +import java.util.Base64; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class BasicAuthentication implements Authentication { + + private String authenticationString; + + private WebUser user; + + public BasicAuthentication(String authenticationString) { + this.authenticationString = authenticationString; + } + + @Override + public boolean isAuthorized(String permission) throws WebUserAuthException { + if (user == null) { + user = getUser(); + return user.hasPermission(permission); + } + return false; + } + + public WebUser getUser() throws WebUserAuthException { + Base64.Decoder decoder = Base64.getDecoder(); + byte[] decoded = decoder.decode(authenticationString); + String[] userInfo = new String(decoded).split(":"); + if (userInfo.length != 2) { + throw new WebUserAuthException(FailReason.USER_AND_PASS_NOT_SPECIFIED); + } + + String user = userInfo[0]; + String passwordRaw = userInfo[1]; + + try { + SecurityTable securityTable = PlanPlugin.getInstance().getDB().getSecurityTable(); + if (!securityTable.userExists(user)) { + throw new WebUserAuthException(FailReason.USER_DOES_NOT_EXIST); + } + + WebUser webUser = securityTable.getWebUser(user); + + boolean correctPass = PassEncryptUtil.verifyPassword(passwordRaw, webUser.getSaltedPassHash()); + if (!correctPass) { + throw new WebUserAuthException(FailReason.USER_PASS_MISMATCH); + } + return webUser; + } catch (Exception e) { + throw new WebUserAuthException(e); + } + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java new file mode 100644 index 0000000000..a3273dea43 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java @@ -0,0 +1,27 @@ +/* + * 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.webserver.auth; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public enum FailReason { + USER_AND_PASS_NOT_SPECIFIED("User and Password not specified"), + USER_DOES_NOT_EXIST("User does not exist"), + USER_PASS_MISMATCH("User and Password did not match"), + ERROR("Authentication failed due to error"); + + private final String reason; + + FailReason(String reason) { + this.reason = reason; + } + + public String getReason() { + return reason; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java index 35d5fefeb7..8359fe57af 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java @@ -7,7 +7,7 @@ import java.util.UUID; /** - * Enum class for "magic" PageCache identifier values. + * Enum class for "magic" ResponseCache identifier values. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageCache.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java similarity index 74% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageCache.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java index d9adebf4d9..9e32b912fe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.webserver.pagecache; -import com.djrapitops.plan.system.webserver.response.InspectPageResponse; +import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import com.djrapitops.plan.system.webserver.response.Response; import java.util.HashMap; @@ -17,14 +17,14 @@ * @author Fuzzlemann * @since 3.6.0 */ -public class PageCache { +public class ResponseCache { - private static final Map pageCache = new HashMap<>(); + private static final Map cache = new HashMap<>(); /** * Constructor used to hide the public constructor */ - private PageCache() { + private ResponseCache() { throw new IllegalStateException("Utility class"); } @@ -40,8 +40,8 @@ private PageCache() { * @param loader The {@link PageLoader} (How should it load the page if it's not cached) * @return The Response that was cached or created by the {@link PageLoader loader} */ - public static Response loadPage(String identifier, PageLoader loader) { - Response response = loadPage(identifier); + public static Response loadResponse(String identifier, PageLoader loader) { + Response response = loadResponse(identifier); if (response != null) { return response; @@ -49,7 +49,7 @@ public static Response loadPage(String identifier, PageLoader loader) { response = loader.createResponse(); - pageCache.put(identifier, response); + cache.put(identifier, response); return response; } @@ -60,8 +60,8 @@ public static Response loadPage(String identifier, PageLoader loader) { * @param identifier The identifier of the page * @return The Response that was cached or {@code null} if it wasn't */ - public static Response loadPage(String identifier) { - return pageCache.get(identifier); + public static Response loadResponse(String identifier) { + return cache.get(identifier); } /** @@ -70,10 +70,10 @@ public static Response loadPage(String identifier) { * Currently supported copyable responses: InspectPageResponse * * @param identifier The identifier of the page - * @return Copied Response of loadPage, so that cache contents are not changed. + * @return Copied Response of loadResponse, so that cache contents are not changed. */ - public static Response copyPage(String identifier, PageLoader loader) { - Response response = loadPage(identifier, loader); + public static Response copyResponse(String identifier, PageLoader loader) { + Response response = loadResponse(identifier, loader); if (response instanceof InspectPageResponse) { return InspectPageResponse.copyOf((InspectPageResponse) response); } @@ -88,9 +88,9 @@ public static Response copyPage(String identifier, PageLoader loader) { * @param identifier The identifier of the page * @param loader The {@link PageLoader} (How it should load the page) */ - public static void cachePage(String identifier, PageLoader loader) { + public static void cacheResponse(String identifier, PageLoader loader) { Response response = loader.createResponse(); - pageCache.put(identifier, response); + cache.put(identifier, response); } /** @@ -100,7 +100,7 @@ public static void cachePage(String identifier, PageLoader loader) { * @return true if the page is cached */ public static boolean isCached(String identifier) { - return pageCache.containsKey(identifier); + return cache.containsKey(identifier); } /** @@ -109,9 +109,9 @@ public static boolean isCached(String identifier) { * @param filter a predicate which returns true for entries to be removed */ public static void removeIf(Predicate filter) { - for (String identifier : pageCache.keySet()) { + for (String identifier : cache.keySet()) { if (filter.test(identifier)) { - pageCache.remove(identifier); + cache.remove(identifier); } } } @@ -120,6 +120,6 @@ public static void removeIf(Predicate filter) { * Clears the cache from all its contents. */ public static void clearCache() { - pageCache.clear(); + cache.clear(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java new file mode 100644 index 0000000000..785d85acbb --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java @@ -0,0 +1,24 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse; + +import java.util.List; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class DebugPageHandler extends PageHandler { + + @Override + public Response getResponse(Request request, List target) { + return new DebugPageResponse(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java new file mode 100644 index 0000000000..b43c9951cc --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java @@ -0,0 +1,33 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; +import com.djrapitops.plan.system.webserver.response.PromptAuthorizationResponse; +import com.djrapitops.plan.system.webserver.response.Response; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public enum DefaultResponses { + NOT_FOUND( + new NotFoundResponse("Make sure you're accessing a link given by a command, Examples:

" + + "

/player/PlayerName
" + + "/server/ServerName

") + ), + BASIC_AUTH(PromptAuthorizationResponse.getBasicAuthResponse()); + + private final Response response; + + DefaultResponses(Response response) { + this.response = response; + } + + public Response get() { + return response; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java new file mode 100644 index 0000000000..a87d788a67 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java @@ -0,0 +1,26 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.List; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public abstract class PageHandler { + + protected String permission = "*"; + + public abstract Response getResponse(Request request, List target); + + public String getPermission() { + return permission; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java new file mode 100644 index 0000000000..3b3bb0bbd1 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java @@ -0,0 +1,67 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; +import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; +import com.djrapitops.plan.utilities.uuid.UUIDUtility; + +import java.util.List; +import java.util.UUID; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class PlayerPageHandler extends PageHandler { + + public PlayerPageHandler() { + permission = "special_player"; + } + + @Override + public Response getResponse(Request request, List target) { + if (target.isEmpty()) { + return DefaultResponses.NOT_FOUND.get(); + } + + String playerName = target.get(0); + UUID uuid = UUIDUtility.getUUIDOf(playerName); + + if (uuid == null) { + return notFound("Player has no UUID"); + } + + if (PlanPlugin.getInstance().getDB().wasSeenBefore(uuid)) { + PlanPlugin.getInstance().getInfoManager().cachePlayer(uuid); + Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); + // TODO Create a new method that places NotFoundResponse to ResponseCache instead. + if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) { + ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> { + try { + return new InspectPageResponse(PlanPlugin.getInstance().getInfoManager(), uuid); + } catch (ParseException e) { + return new InternalErrorResponse(e, this.getClass().getName()); + } + }); + response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); + } + return response; + } + return notFound("Player has not played on this server."); + } + + private Response notFound(String error) { + return ResponseCache.loadResponse(PageId.NOT_FOUND.of(error), () -> new NotFoundResponse(error)); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java new file mode 100644 index 0000000000..9104b12f40 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java @@ -0,0 +1,30 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.PlayersPageResponse; + +import java.util.List; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class PlayersPageHandler extends PageHandler { + + public PlayersPageHandler() { + permission = "players"; + } + + @Override + public Response getResponse(Request request, List target) { + return ResponseCache.loadResponse(PageId.PLAYERS.id(), PlayersPageResponse::new); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..f4af237c3c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/ServerPageHandler.java @@ -0,0 +1,27 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.List; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class ServerPageHandler extends PageHandler { + + public ServerPageHandler() { + permission = "server"; + } + + @Override + public Response getResponse(Request request, List target) { + return null; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java new file mode 100644 index 0000000000..b647094e02 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java @@ -0,0 +1,53 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public abstract class TreePageHandler extends PageHandler { + + private Map pages; + + public TreePageHandler() { + pages = new HashMap<>(); + } + + public void registerPage(String targetPage, PageHandler handler) { + pages.put(targetPage, handler); + } + + public void registerPage(String targetPage, Response response) { + pages.put(targetPage, new PageHandler() { + @Override + public Response getResponse(Request request, List target) { + return response; + } + }); + } + + @Override + public Response getResponse(Request request, List target) { + PageHandler pageHandler = getPageHandler(target); + return pageHandler != null + ? pageHandler.getResponse(request, target) + : DefaultResponses.NOT_FOUND.get(); + } + + public PageHandler getPageHandler(List target) { + String targetPage = target.get(0); + target.remove(0); + return pages.get(targetPage); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java index 5b3cadd23f..d8ad5ef780 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.system.webserver.response; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java index f15892e74b..eb84815203 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java @@ -1,5 +1,9 @@ package com.djrapitops.plan.system.webserver.response; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.system.webserver.auth.FailReason; +import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; +import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.html.Html; /** @@ -8,15 +12,43 @@ */ public class PromptAuthorizationResponse extends ErrorResponse { - public PromptAuthorizationResponse() { - super.setHeader("HTTP/1.1 401 Access Denied\r\n" + private PromptAuthorizationResponse() { + super.setTitle(Html.FONT_AWESOME_ICON.parse("lock") + " 401 Unauthorized"); + } + + public static PromptAuthorizationResponse getBasicAuthResponse() { + PromptAuthorizationResponse response = new PromptAuthorizationResponse(); + response.setHeader("HTTP/1.1 401 Access Denied\r\n" + "WWW-Authenticate: Basic realm=\"/\";"); - super.setTitle(Html.FONT_AWESOME_ICON.parse("lock")+" 401 Unauthorized"); - super.setParagraph("Authentication Failed.
" + response.setParagraph("Authentication Failed.
" + "- Ensure you have registered a user with /plan register
" + "- Check that the username and password are correct
" + "- Username and password are case-sensitive
" + "
If you have forgotten your password, ask a staff member to delete your old user and re-register."); - super.replacePlaceholders(); + response.replacePlaceholders(); + return response; + } + + public static PromptAuthorizationResponse getBasicAuthResponse(WebUserAuthException e) { + PromptAuthorizationResponse response = new PromptAuthorizationResponse(); + response.setHeader("HTTP/1.1 401 Access Denied\r\n" + + "WWW-Authenticate: Basic realm=\"/\";"); + + FailReason failReason = e.getFailReason(); + String reason = failReason.getReason(); + + if (failReason == FailReason.ERROR) { + StringBuilder errorBuilder = new StringBuilder("

");
+            for (String line : FormatUtils.getStackTrace(e.getCause())) {
+                errorBuilder.append(line);
+            }
+            errorBuilder.append("
"); + + reason += errorBuilder.toString(); + } + + response.setParagraph("Authentication Failed.
Reason: " + reason); + response.replacePlaceholders(); + return response; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ErrorResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java index 8924eed88b..3f509c9e9c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java @@ -2,9 +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.webserver.response; +package com.djrapitops.plan.system.webserver.response.errors; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ForbiddenResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ForbiddenResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java index 739dda270f..347a0b514c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ForbiddenResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.webserver.response; +package com.djrapitops.plan.system.webserver.response.errors; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InternalErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/InternalErrorResponse.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InternalErrorResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/InternalErrorResponse.java index f9496b88fd..e9cf480e47 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InternalErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/InternalErrorResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.webserver.response; +package com.djrapitops.plan.system.webserver.response.errors; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/NotFoundResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/NotFoundResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java index f083edec7a..429fd1ea5a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/NotFoundResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.webserver.response; +package com.djrapitops.plan.system.webserver.response.errors; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/AnalysisPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/AnalysisPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java index df7e21c40f..8ef5faeae2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/AnalysisPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java @@ -1,7 +1,9 @@ -package com.djrapitops.plan.system.webserver.response; +package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.AnalysisData; +import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plugin.task.AbsRunnable; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DebugPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 20e32ffc79..855ee3cd8d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -2,11 +2,12 @@ * 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.webserver.response; +package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.ServerVariableHolder; +import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.utilities.file.FileUtil; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InspectPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InspectPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java index 36cfa3582b..7a548b6750 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/InspectPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java @@ -1,7 +1,8 @@ -package com.djrapitops.plan.system.webserver.response; +package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.systems.info.InformationManager; import org.apache.commons.lang3.text.StrSubstitutor; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PlayersPageResponse.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java index 71819569ff..e9220fecb7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.webserver.response; +package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.GeoInfo; @@ -8,6 +8,8 @@ import com.djrapitops.plan.database.Database; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index a17d1a7985..0eaa1b8855 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.*; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.response.NotFoundResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.api.SuccessResponse; @@ -165,11 +165,11 @@ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, Strin }; protected Response success() { - return PageCache.loadPage(PageId.TRUE.id(), SuccessResponse::new); + return ResponseCache.loadResponse(PageId.TRUE.id(), SuccessResponse::new); } protected Response fail(String reason) { - return PageCache.loadPage(PageId.FALSE.id(), () -> { + return ResponseCache.loadResponse(PageId.FALSE.id(), () -> { NotFoundResponse notFoundResponse = new NotFoundResponse(""); notFoundResponse.setContent(reason); return notFoundResponse; @@ -177,7 +177,7 @@ protected Response fail(String reason) { } protected Response badRequest(String error) { - return PageCache.loadPage(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); + return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); } private String parseVariables() { 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 c257d0b080..8466905942 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 @@ -7,10 +7,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.response.AnalysisPageResponse; -import com.djrapitops.plan.system.webserver.response.InspectPageResponse; +import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; +import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.InformationManager; @@ -55,14 +55,14 @@ public Response onRequest(PlanPlugin plugin, Map variables) { Map map = new HashMap<>(); map.put("networkName", Settings.BUNGEE_NETWORK_NAME.toString()); - PageCache.cachePage(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(infoManager, UUID.fromString(uuid), StrSubstitutor.replace(html, map))); + ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(infoManager, UUID.fromString(uuid), StrSubstitutor.replace(html, map))); if (Settings.ANALYSIS_EXPORT.isTrue()) { HtmlExport.exportPlayer(plugin, UUID.fromString(uuid)); } break; case "analysisPage": String sender = variables.get("sender"); - PageCache.cachePage(PageId.SERVER.of(sender), () -> new AnalysisPageResponse(html)); + ResponseCache.cacheResponse(PageId.SERVER.of(sender), () -> new AnalysisPageResponse(html)); if (Settings.ANALYSIS_EXPORT.isTrue()) { HtmlExport.exportServer(plugin, UUID.fromString(sender)); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index 35326754df..74e2c5d8b5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.system.webserver.response.ForbiddenResponse; +import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.server.ServerInfo; 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 index f6492a00c0..679f968af2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -15,9 +15,14 @@ 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.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.response.*; +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.errors.NotFoundResponse; +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.WebAPIManager; import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalysisReadyWebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI; @@ -41,7 +46,7 @@ import java.util.*; /** - * Manages the Information going to the PageCache. + * 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. * @@ -115,7 +120,7 @@ public void cachePlayer(UUID uuid) { } } } else { - PageCache.cachePage(PageId.PLAYER.of(uuid), () -> { + ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> { try { return new InspectPageResponse(this, uuid); } catch (ParseException e) { @@ -188,7 +193,7 @@ public void cacheInspectPluginsTab(UUID uuid, String[] contents) { } } else { pluginsTabContents.put(uuid, contents); - Response inspectResponse = PageCache.loadPage(PageId.PLAYER.of(uuid)); + Response inspectResponse = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); if (inspectResponse != null && inspectResponse instanceof InspectPageResponse) { ((InspectPageResponse) inspectResponse).setInspectPagePluginsTab(contents); } @@ -231,7 +236,7 @@ public boolean isAnalysisCached(UUID serverUUID) { return isAnalysisCached(serverUUID); } } - return PageCache.isCached(PageId.SERVER.of(serverUUID)); + return ResponseCache.isCached(PageId.SERVER.of(serverUUID)); } private WebAPIManager getWebAPI() { @@ -306,7 +311,7 @@ public void cacheAnalysisHtml(String html) { } } else { UUID serverUUID = Plan.getServerUUID(); - PageCache.cachePage(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); + ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); if (Settings.ANALYSIS_EXPORT.isTrue()) { HtmlExport.exportServer(plugin, serverUUID); } 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 index e28a1e1a01..085d73d079 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -10,9 +10,13 @@ import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.response.*; +import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; +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.WebAPIManager; import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalysisReadyWebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI; @@ -35,7 +39,7 @@ import java.util.stream.Collectors; /** - * Manages information going to the PageCache from Bukkit servers. + * Manages information going to the ResponseCache from Bukkit servers. * * @author Rsl1122 */ @@ -233,7 +237,7 @@ public boolean attemptConnection() { */ @Override public boolean isAnalysisCached(UUID serverUUID) { - return PageCache.isCached(PageId.SERVER.of(serverUUID)); + return ResponseCache.isCached(PageId.SERVER.of(serverUUID)); } /** @@ -246,7 +250,7 @@ public boolean isAnalysisCached(UUID serverUUID) { */ @Override public String getPlayerHtml(UUID uuid) { - Response response = PageCache.copyPage(PageId.PLAYER.of(uuid), + Response response = ResponseCache.copyResponse(PageId.PLAYER.of(uuid), () -> new NotFoundResponse("No Bukkit Servers were online to process this request")); if (response instanceof InspectPageResponse) { ((InspectPageResponse) response).setInspectPagePluginsTab(getPluginsTabContent(uuid)); @@ -310,7 +314,7 @@ public void cachePluginsTabContent(UUID serverUUID, UUID uuid, String[] html) { Map perServerPluginsTab = pluginsTabContent.getOrDefault(uuid, new HashMap<>()); perServerPluginsTab.put(serverUUID, html); pluginsTabContent.put(uuid, perServerPluginsTab); - Response inspectResponse = PageCache.loadPage(PageId.PLAYER.of(uuid)); + Response inspectResponse = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); if (inspectResponse != null && inspectResponse instanceof InspectPageResponse) { ((InspectPageResponse) inspectResponse).setInspectPagePluginsTab(getPluginsTabContent(uuid)); } @@ -368,7 +372,7 @@ public void analysisReady(UUID serverUUID) { @Override public void updateNetworkPageContent() { UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); - PageCache.cachePage(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(this)); + ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(this)); if (Settings.ANALYSIS_EXPORT.isTrue()) { HtmlExport.exportServer(plugin, serverUUID); } 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 index 8c6991a1a6..3904741eec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.systems.info; import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; @@ -47,7 +47,7 @@ public SessionCache getSessionCache() { } public boolean isCached(UUID uuid) { - return PageCache.isCached(PageId.PLAYER.of(uuid)); + return ResponseCache.isCached(PageId.PLAYER.of(uuid)); } public abstract String getPlayerHtml(UUID uuid) throws ParseException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java index 053e3cc3cf..dd841d3520 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java @@ -17,7 +17,7 @@ import java.util.UUID; /** - * Sends a request to cache players inspect page to the PageCache on the appropriate WebServer. + * Sends a request to cache players inspect page to the ResponseCache on the appropriate WebServer. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index a6306a4355..092809fd0f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -6,6 +6,8 @@ import org.bukkit.Location; import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; /** * @author Rsl1122 @@ -241,4 +243,29 @@ public static String formatIP(String ip) { return b.append("xx").toString(); } + + /** + * Gets lines for stack trace recursively. + * + * @param throwable + * @return + */ + public static List getStackTrace(Throwable throwable) { + List stackTrace = new ArrayList<>(); + stackTrace.add(throwable.toString()); + for (StackTraceElement element : throwable.getStackTrace()) { + stackTrace.add(" " + element.toString()); + } + + Throwable cause = throwable.getCause(); + if (cause != null) { + List causeTrace = getStackTrace(cause); + if (!causeTrace.isEmpty()) { + causeTrace.set(0, "Caused by: " + causeTrace.get(0)); + stackTrace.addAll(causeTrace); + } + } + + return stackTrace; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index d121b5c87e..05baae732d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -11,8 +11,8 @@ import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.response.ErrorResponse; -import com.djrapitops.plan.system.webserver.response.InternalErrorResponse; +import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; +import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java index 896efa2cd3..40719156db 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java @@ -11,7 +11,7 @@ import java.util.UUID; /** - * Task that exports a single Analysis page if it is in PageCache. + * Task that exports a single Analysis page if it is in ResponseCache. * * @author Rsl1122 */ 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 f7088db5bc..ff16542943 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 @@ -8,7 +8,7 @@ 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.webserver.response.PlayersPageResponse; +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.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index f51cf8fc97..2f23feb418 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.utilities.file.export; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plugin.api.Check; @@ -73,7 +73,7 @@ protected File getPlayerFolder() { } protected void exportAvailablePlayerPage(UUID uuid, String name) throws IOException { - Response response = PageCache.loadPage(PageId.PLAYER.of(uuid)); + Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); if (response == null) { return; } @@ -90,7 +90,7 @@ protected void exportAvailablePlayerPage(UUID uuid, String name) throws IOExcept protected void exportAvailableServerPage(UUID serverUUID, String serverName) throws IOException { - Response response = PageCache.loadPage(PageId.SERVER.of(serverUUID)); + Response response = ResponseCache.loadResponse(PageId.SERVER.of(serverUUID)); if (response == null) { return; } diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/PageCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java similarity index 60% rename from Plan/test/main/java/com/djrapitops/plan/data/cache/PageCacheTest.java rename to Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java index 5918c40594..73ce5d6ced 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/PageCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.data.cache; -import com.djrapitops.plan.system.webserver.pagecache.PageCache; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageLoader; import com.djrapitops.plan.system.webserver.response.Response; import org.junit.Test; @@ -11,7 +11,7 @@ /** * @author Fuzzlemann */ -public class PageCacheTest { +public class ResponseCacheTest { private final String IDENTIFIER = RandomData.randomString(10); private final String RESPONSE_STRING = RandomData.randomString(10); private final Response RESPONSE = new Response() { @@ -34,29 +34,29 @@ public void testCreateResponse() { public void testCache() { Response expResponse = LOADER.createResponse(); - assertFalse(PageCache.isCached(IDENTIFIER)); + assertFalse(ResponseCache.isCached(IDENTIFIER)); - Response response = PageCache.loadPage(IDENTIFIER, LOADER); - assertTrue(PageCache.isCached(IDENTIFIER)); + Response response = ResponseCache.loadResponse(IDENTIFIER, LOADER); + assertTrue(ResponseCache.isCached(IDENTIFIER)); assertEquals(expResponse, response); } @Test public void testClearCache() { - PageCache.cachePage(IDENTIFIER, LOADER); - assertTrue(PageCache.isCached(IDENTIFIER)); + ResponseCache.cacheResponse(IDENTIFIER, LOADER); + assertTrue(ResponseCache.isCached(IDENTIFIER)); - PageCache.clearCache(); - assertFalse(PageCache.isCached(IDENTIFIER)); + ResponseCache.clearCache(); + assertFalse(ResponseCache.isCached(IDENTIFIER)); } @Test public void testRemoveIf() { - PageCache.cachePage(IDENTIFIER, LOADER); - assertTrue(PageCache.isCached(IDENTIFIER)); + ResponseCache.cacheResponse(IDENTIFIER, LOADER); + assertTrue(ResponseCache.isCached(IDENTIFIER)); - PageCache.removeIf(identifier -> identifier.equals(IDENTIFIER)); - assertFalse(PageCache.isCached(IDENTIFIER)); + ResponseCache.removeIf(identifier -> identifier.equals(IDENTIFIER)); + assertFalse(ResponseCache.isCached(IDENTIFIER)); } } From cd95a0a68ee8161883f38b2fdb0149bbedd634bb Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 12:54:37 +0200 Subject: [PATCH 007/166] Refactored ActivityIndex to a new class. --- .../command/commands/QInspectCommand.java | 7 +- .../djrapitops/plan/data/PlayerProfile.java | 91 ++---------- .../plan/data/container/StickyData.java | 2 +- .../plan/data/element/ActivityIndex.java | 131 ++++++++++++++++++ .../plan/data/element/HealthNotes.java | 2 +- .../info/parsing/InspectPageParser.java | 12 +- .../plan/utilities/FormatUtils.java | 14 -- .../utilities/analysis/AnalysisUtils.java | 11 +- .../html/tables/PlayersTableCreator.java | 10 +- .../plan/data/PlayerProfileTest.java | 6 +- 10 files changed, 167 insertions(+), 119 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java index adc69d7348..ed249757ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java @@ -2,9 +2,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; @@ -100,9 +101,9 @@ private void sendMsgs(ISender sender, PlayerProfile profile) { sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT).toString() + ": " + colT + profile.getName()); - double activityIndex = profile.getActivityIndex(now); + ActivityIndex activityIndex = profile.getActivityIndex(now); - sender.sendMessage(colT + ball + " " + colM + " Activity Index: " + colS + FormatUtils.cutDecimals(activityIndex) + " | " + FormatUtils.readableActivityIndex(activityIndex)[1]); + sender.sendMessage(colT + ball + " " + colM + " Activity Index: " + colS + activityIndex.getFormattedValue() + " | " + activityIndex.getColor()); sender.sendMessage(colT + ball + " " + colM + " Registered: " + colS + FormatUtils.formatTimeStampYear(profile.getRegistered())); sender.sendMessage(colT + ball + " " + colM + " Last Seen: " + colS + FormatUtils.formatTimeStampYear(profile.getLastSeen())); sender.sendMessage(colT + ball + " " + colM + " Logged in from: " + colS + profile.getMostRecentGeoInfo().getGeolocation()); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index 3ff1165f01..eda9fc2ab1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -4,16 +4,16 @@ */ package com.djrapitops.plan.data; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.comparators.ActionComparator; import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; -import com.djrapitops.plugin.api.TimeAmount; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.OfflinePlayer; @@ -57,7 +57,7 @@ public class PlayerProfile implements OfflinePlayer { private Map pluginReplaceMap; // Value that requires lot of processing - private Map activityIndex; + private Map activityIndexCache; public PlayerProfile(UUID uuid, String name, long registered) { this.uuid = uuid; @@ -76,88 +76,17 @@ public PlayerProfile(UUID uuid, String name, long registered) { geoInformation = new ArrayList<>(); pluginReplaceMap = new HashMap<>(); - activityIndex = new HashMap<>(); + activityIndexCache = new HashMap<>(); } // Calculating Getters - public double getActivityIndex(long date) { - Double activityIndx = activityIndex.get(date); - if (activityIndx != null) { - return activityIndx; + public ActivityIndex getActivityIndex(long date) { + ActivityIndex index = activityIndexCache.get(date); + if (index == null) { + index = new ActivityIndex(this, date); + activityIndexCache.put(date, index); } - - long week = TimeAmount.WEEK.ms(); - long weekAgo = date - week; - long twoWeeksAgo = date - 2L * week; - long threeWeeksAgo = date - 3L * week; - - long activePlayThreshold = Settings.ACTIVE_PLAY_THRESHOLD.getNumber() * TimeAmount.MINUTE.ms(); - if (activePlayThreshold <= 0) { - activePlayThreshold = 1; - } - int activeLoginThreshold = Settings.ACTIVE_LOGIN_THRESHOLD.getNumber(); - if (activeLoginThreshold <= 0) { - activeLoginThreshold = 1; - } - - List sessionsWeek = getSessions(weekAgo, date).collect(Collectors.toList()); - List sessionsWeek2 = getSessions(twoWeeksAgo, weekAgo).collect(Collectors.toList()); - List sessionsWeek3 = getSessions(threeWeeksAgo, twoWeeksAgo).collect(Collectors.toList()); - - // Playtime per week multipliers, max out to avoid too high values. - double max = 4.0; - - long playtimeWeek = PlayerProfile.getPlaytime(sessionsWeek.stream()); - double weekPlay = (playtimeWeek * 1.0 / activePlayThreshold); - if (weekPlay > max) { - weekPlay = max; - } - long playtimeWeek2 = PlayerProfile.getPlaytime(sessionsWeek2.stream()); - double week2Play = (playtimeWeek2 * 1.0 / activePlayThreshold); - if (week2Play > max) { - week2Play = max; - } - long playtimeWeek3 = PlayerProfile.getPlaytime(sessionsWeek3.stream()); - double week3Play = (playtimeWeek3 * 1.0 / activePlayThreshold); - if (week3Play > max) { - week3Play = max; - } - - double playtimeMultiplier = 1.0; - if (playtimeWeek + playtimeWeek2 + playtimeWeek3 > activeLoginThreshold * 3.0) { - playtimeMultiplier = 1.25; - } - - // Reduce the harshness for new players and players who have had a vacation - if (weekPlay > 1 && week3Play > 1 && week2Play == 0.0) { - week2Play = 0.5; - } - if (weekPlay > 1 && week2Play == 0.0) { - week2Play = 0.6; - } - if (weekPlay > 1 && week3Play == 0.0) { - week3Play = 0.75; - } - - double playAvg = (weekPlay + week2Play + week3Play) / 3.0; - - double weekLogin = sessionsWeek.size() >= activeLoginThreshold ? 1.0 : 0.5; - double week2Login = sessionsWeek2.size() >= activeLoginThreshold ? 1.0 : 0.5; - double week3Login = sessionsWeek3.size() >= activeLoginThreshold ? 1.0 : 0.5; - - double loginMultiplier = 1.0; - double loginTotal = weekLogin + week2Login + week3Login; - double loginAvg = loginTotal / 3.0; - - if (loginTotal <= 2.0) { - // Reduce index for players that have not logged in the threshold amount for 2 weeks - loginMultiplier = 0.75; - } - - activityIndx = playAvg * loginAvg * loginMultiplier * playtimeMultiplier; - activityIndex.put(date, activityIndx); - - return activityIndx; + return index; } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java b/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java index d5cdaa9287..45590026b2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java @@ -15,7 +15,7 @@ public class StickyData { private Integer onlineOnJoin; public StickyData(PlayerProfile player) { - activityIndex = player.getActivityIndex(player.getRegistered() + TimeAmount.DAY.ms()); + activityIndex = player.getActivityIndex(player.getRegistered() + TimeAmount.DAY.ms()).getValue(); for (Action action : player.getActions()) { if (messagesSent == null && action.getDoneAction() == Actions.FIRST_LOGOUT) { String additionalInfo = action.getAdditionalInfo(); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java new file mode 100644 index 0000000000..d79102c61d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java @@ -0,0 +1,131 @@ +package com.djrapitops.plan.data.element; + +import com.djrapitops.plan.data.PlayerProfile; +import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.utilities.FormatUtils; +import com.djrapitops.plugin.api.TimeAmount; + +import java.util.List; +import java.util.stream.Collectors; + +public class ActivityIndex { + + private static long loadSetting(long value) { + return value < 0 ? 1 : value; + } + + private final double value; + + public ActivityIndex(PlayerProfile player, long date) { + value = calculate(player, date); + } + + private double calculate(PlayerProfile player, long date) { + long week = TimeAmount.WEEK.ms(); + long weekAgo = date - week; + long twoWeeksAgo = date - 2L * week; + long threeWeeksAgo = date - 3L * week; + + long activePlayThreshold = Settings.ACTIVE_PLAY_THRESHOLD.getNumber() * TimeAmount.MINUTE.ms(); + if (activePlayThreshold <= 0) { + activePlayThreshold = 1; + } + int activeLoginThreshold = Settings.ACTIVE_LOGIN_THRESHOLD.getNumber(); + if (activeLoginThreshold <= 0) { + activeLoginThreshold = 1; + } + + List sessionsWeek = player.getSessions(weekAgo, date).collect(Collectors.toList()); + List sessionsWeek2 = player.getSessions(twoWeeksAgo, weekAgo).collect(Collectors.toList()); + List sessionsWeek3 = player.getSessions(threeWeeksAgo, twoWeeksAgo).collect(Collectors.toList()); + + // Playtime per week multipliers, max out to avoid too high values. + double max = 4.0; + + long playtimeWeek = PlayerProfile.getPlaytime(sessionsWeek.stream()); + double weekPlay = (playtimeWeek * 1.0 / activePlayThreshold); + if (weekPlay > max) { + weekPlay = max; + } + long playtimeWeek2 = PlayerProfile.getPlaytime(sessionsWeek2.stream()); + double week2Play = (playtimeWeek2 * 1.0 / activePlayThreshold); + if (week2Play > max) { + week2Play = max; + } + long playtimeWeek3 = PlayerProfile.getPlaytime(sessionsWeek3.stream()); + double week3Play = (playtimeWeek3 * 1.0 / activePlayThreshold); + if (week3Play > max) { + week3Play = max; + } + + double playtimeMultiplier = 1.0; + if (playtimeWeek + playtimeWeek2 + playtimeWeek3 > activePlayThreshold * 3.0) { + playtimeMultiplier = 1.25; + } + + // Reduce the harshness for new players and players who have had a vacation + if (weekPlay > 1 && week3Play > 1 && week2Play == 0.0) { + week2Play = 0.5; + } + if (weekPlay > 1 && week2Play == 0.0) { + week2Play = 0.6; + } + if (weekPlay > 1 && week3Play == 0.0) { + week3Play = 0.75; + } + + double playAvg = (weekPlay + week2Play + week3Play) / 3.0; + + double weekLogin = sessionsWeek.size() >= activeLoginThreshold ? 1.0 : 0.5; + double week2Login = sessionsWeek2.size() >= activeLoginThreshold ? 1.0 : 0.5; + double week3Login = sessionsWeek3.size() >= activeLoginThreshold ? 1.0 : 0.5; + + double loginMultiplier = 1.0; + double loginTotal = weekLogin + week2Login + week3Login; + double loginAvg = loginTotal / 3.0; + + if (loginTotal <= 2.0) { + // Reduce index for players that have not logged in the threshold amount for 2 weeks + loginMultiplier = 0.75; + } + + return playAvg * loginAvg * loginMultiplier * playtimeMultiplier; + } + + public double getValue() { + return value; + } + + public String getFormattedValue() { + return FormatUtils.cutDecimals(value); + } + + public String getGroup() { + if (value >= 3.5) { + return "Very Active"; + } else if (value >= 1.75) { + return "Active"; + } else if (value >= 1.0) { + return "Regular"; + } else if (value >= 0.5) { + return "Irregular"; + } else { + return "Inactive"; + } + } + + public String getColor() { + if (value >= 3.5) { + return "green"; + } else if (value >= 1.75) { + return "green"; + } else if (value >= 1.0) { + return "lime"; + } else if (value >= 0.5) { + return "amber"; + } else { + return "blue-gray"; + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java b/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java index 710942da5e..7959596401 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java @@ -155,7 +155,7 @@ private void newPlayerNote() { private void activePlayerPlaytimeChange() { List currentActivePlayers = analysisData.getPlayers().stream() - .filter(player -> player.getActivityIndex(now) >= 1.75) + .filter(player -> player.getActivityIndex(now).getValue() >= 1.75) .collect(Collectors.toList()); long twoWeeksAgo = now - TimeAmount.WEEK.ms() * 2L; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index 4c417534e6..9aa8ad4d9c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -9,11 +9,12 @@ import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; @@ -225,12 +226,11 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("mobKillCount", mobKillCount); addValue("deathCount", deathCount); - double activityIndex = profile.getActivityIndex(now); - String[] activityIndexFormat = FormatUtils.readableActivityIndex(activityIndex); + ActivityIndex activityIndex = profile.getActivityIndex(now); - addValue("activityIndexNumber", FormatUtils.cutDecimals(activityIndex)); - addValue("activityIndexColor", activityIndexFormat[0]); - addValue("activityIndex", activityIndexFormat[1]); + addValue("activityIndexNumber", activityIndex.getFormattedValue()); + addValue("activityIndexColor", activityIndex.getColor()); + addValue("activityIndex", activityIndex.getGroup()); addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp())); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index a6306a4355..bbbfc1ed93 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -212,20 +212,6 @@ public static String cutDecimals(double d) { return df.format(d); } - public static String[] readableActivityIndex(double activityIndex) { - if (activityIndex >= 3.5) { - return new String[]{"green", "Very Active"}; - } else if (activityIndex >= 1.75) { - return new String[]{"green", "Active"}; - } else if (activityIndex >= 1.0) { - return new String[]{"lime", "Regular"}; - } else if (activityIndex >= 0.5) { - return new String[]{"amber", "Irregular"}; - } else { - return new String[]{"blue-gray", "Inactive"}; - } - } - public static String formatIP(String ip) { StringBuilder b = new StringBuilder(); int i = 0; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index 7b043c7c58..b4a99a730c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -4,10 +4,9 @@ import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.StickyData; +import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -219,13 +218,13 @@ public static TreeMap>> turnToActivityDataMap(long t if (!players.isEmpty()) { for (PlayerProfile player : players) { for (long date = time; date >= time - TimeAmount.MONTH.ms() * 2L; date -= TimeAmount.WEEK.ms()) { - double activityIndex = player.getActivityIndex(date); - String index = FormatUtils.readableActivityIndex(activityIndex)[1]; + ActivityIndex activityIndex = player.getActivityIndex(date); + String activityGroup = activityIndex.getGroup(); Map> map = activityData.getOrDefault(date, new HashMap<>()); - Set uuids = map.getOrDefault(index, new HashSet<>()); + Set uuids = map.getOrDefault(activityGroup, new HashSet<>()); uuids.add(player.getUuid()); - map.put(index, uuids); + map.put(activityGroup, uuids); activityData.put(date, map); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java index 49b02d5815..877ec3f852 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java @@ -1,7 +1,9 @@ package com.djrapitops.plan.utilities.html.tables; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.PlayerProfile; +import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.PluginData; @@ -55,10 +57,10 @@ public static String createTable(List players) { long lastSeen = profile.getLastSeen(); - double activityIndex = profile.getActivityIndex(now); - String readableIndex = FormatUtils.readableActivityIndex(activityIndex)[1]; - String activityString = FormatUtils.cutDecimals(activityIndex) - + (isBanned ? " (Banned)" : " (" + readableIndex + ")"); + ActivityIndex activityIndex = profile.getActivityIndex(now); + String activityGroup = activityIndex.getGroup(); + String activityString = activityIndex.getFormattedValue() + + (isBanned ? " (Banned)" : " (" + activityGroup + ")"); String geoLocation = profile.getMostRecentGeoInfo().getGeolocation(); html.append(Html.TABLELINE_PLAYERS.parse( diff --git a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java b/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java index c87610e857..3152f32805 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java @@ -53,7 +53,7 @@ public void testMaxActivityIndex() { } p.setSessions(null, sessions); - assertEquals(5.0, p.getActivityIndex(date)); + assertEquals(5.0, p.getActivityIndex(date).getValue()); } @Test @@ -77,7 +77,7 @@ public void testMaxActivityIndex2() { } p.setSessions(null, sessions); - assertEquals(5.0, p.getActivityIndex(date)); + assertEquals(5.0, p.getActivityIndex(date).getValue()); } @Test @@ -101,7 +101,7 @@ public void testActivityIndexOne() { } p.setSessions(null, sessions); - assertTrue(2.0 <= p.getActivityIndex(date)); + assertTrue(2.0 <= p.getActivityIndex(date).getValue()); } @Test(timeout = 500) From 3cc84bb6f45bf81a530d043be6fae966508efbfc Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 13:12:49 +0200 Subject: [PATCH 008/166] Moved Database to another package --- .../main/java/com/djrapitops/plan/Plan.java | 14 +-- .../java/com/djrapitops/plan/PlanBungee.java | 12 +- .../java/com/djrapitops/plan/PlanPlugin.java | 2 +- .../com/djrapitops/plan/ShutdownHook.java | 6 +- .../command/commands/RegisterCommand.java | 4 +- .../commands/manage/ManageBackupCommand.java | 4 +- .../commands/manage/ManageClearCommand.java | 4 +- .../commands/manage/ManageHotswapCommand.java | 6 +- .../commands/manage/ManageMoveCommand.java | 4 +- .../commands/manage/ManageRestoreCommand.java | 6 +- .../commands/webuser/WebCheckCommand.java | 4 +- .../commands/webuser/WebDeleteCommand.java | 4 +- .../plan/data/container/Action.java | 2 +- .../plan/data/container/PlayerKill.java | 2 +- .../plan/data/container/StickyData.java | 2 +- .../djrapitops/plan/database/Container.java | 43 ------- .../com/djrapitops/plan/database/DBUtils.java | 110 ------------------ .../djrapitops/plan/system/PlanSystem.java | 11 +- .../database/BukkitDBSystem.java} | 8 +- .../database/BungeeDBSystem.java} | 9 +- .../file => system}/database/DBSystem.java | 15 ++- .../database/databases}/Database.java | 5 +- .../database/databases/MySQLDB.java | 2 +- .../database/databases/SQLDB.java | 7 +- .../database/databases/SQLiteDB.java | 2 +- .../database/processing/ExecStatement.java | 4 +- .../processing/QueryAllStatement.java | 4 +- .../database/processing/QueryStatement.java | 4 +- .../{ => system}/database/sql/Insert.java | 2 +- .../{ => system}/database/sql/Select.java | 2 +- .../plan/{ => system}/database/sql/Sql.java | 2 +- .../{ => system}/database/sql/SqlParser.java | 2 +- .../database/sql/TableSqlParser.java | 2 +- .../{ => system}/database/sql/Update.java | 4 +- .../database/sql/WhereParser.java | 4 +- .../{ => system}/database/tables/Actions.java | 4 +- .../database/tables/ActionsTable.java | 18 +-- .../database/tables/CommandUseTable.java | 16 +-- .../database/tables/IPsTable.java | 16 +-- .../database/tables/KillsTable.java | 14 +-- .../database/tables/NicknamesTable.java | 14 +-- .../database/tables/SecurityTable.java | 18 +-- .../database/tables/ServerTable.java | 12 +- .../database/tables/SessionsTable.java | 16 +-- .../database/tables/TPSTable.java | 16 +-- .../{ => system}/database/tables/Table.java | 8 +- .../database/tables/UserIDTable.java | 6 +- .../database/tables/UserInfoTable.java | 19 ++- .../database/tables/UsersTable.java | 12 +- .../database/tables/VersionTable.java | 14 +-- .../database/tables/WorldTable.java | 15 ++- .../database/tables/WorldTimesTable.java | 14 +-- .../tables/move/BatchOperationTable.java | 12 +- .../tables/move/Version8TransferTable.java | 6 +- .../com/djrapitops/plan/systems/Systems.java | 17 ++- .../plan/systems/cache/DataCache.java | 2 +- .../info/parsing/InspectPageParser.java | 2 +- .../info/parsing/NetworkPageParser.java | 4 +- .../info/server/BukkitServerInfoManager.java | 4 +- .../info/server/BungeeServerInfoManager.java | 4 +- .../processing/NewNickActionProcessor.java | 2 +- .../importing/importers/Importer.java | 2 +- .../player/BungeePlayerRegisterProcessor.java | 2 +- .../player/FirstLeaveProcessor.java | 2 +- .../processing/player/NameProcessor.java | 4 +- .../processing/player/RegisterProcessor.java | 8 +- .../systems/webserver/ResponseHandler.java | 3 +- .../response/PlayersPageResponse.java | 5 +- .../plan/utilities/ManageUtils.java | 8 +- .../djrapitops/plan/utilities/MiscUtils.java | 6 +- .../plan/utilities/analysis/Analysis.java | 4 +- .../plan/utilities/html/HtmlStructure.java | 2 +- .../plan/utilities/uuid/UUIDUtility.java | 3 +- .../plan/data/cache/DataCacheTest.java | 2 +- .../djrapitops/plan/database/DBUtilsTest.java | 80 ------------- .../{ => system}/database/DatabaseTest.java | 11 +- .../database/tables/ActionsTest.java | 2 +- .../plan/utilities/MiscUtilsTest.java | 6 +- .../main/java/test/utilities/DBTestSuite.java | 2 +- 79 files changed, 262 insertions(+), 493 deletions(-) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/database/Container.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/database/DBUtils.java rename Plan/src/main/java/com/djrapitops/plan/{systems/file/database/PlanDBSystem.java => system/database/BukkitDBSystem.java} (74%) rename Plan/src/main/java/com/djrapitops/plan/{systems/file/database/PlanBungeeDBSystem.java => system/database/BungeeDBSystem.java} (74%) rename Plan/src/main/java/com/djrapitops/plan/{systems/file => system}/database/DBSystem.java (81%) rename Plan/src/main/java/com/djrapitops/plan/{database => system/database/databases}/Database.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/databases/MySQLDB.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/databases/SQLDB.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/databases/SQLiteDB.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/processing/ExecStatement.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/processing/QueryAllStatement.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/processing/QueryStatement.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/sql/Insert.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/sql/Select.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/sql/Sql.java (89%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/sql/SqlParser.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/sql/TableSqlParser.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/sql/Update.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/sql/WhereParser.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/Actions.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/ActionsTable.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/CommandUseTable.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/IPsTable.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/KillsTable.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/NicknamesTable.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/SecurityTable.java (89%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/ServerTable.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/SessionsTable.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/TPSTable.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/Table.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/UserIDTable.java (83%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/UserInfoTable.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/UsersTable.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/VersionTable.java (83%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/WorldTable.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/WorldTimesTable.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/move/BatchOperationTable.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/database/tables/move/Version8TransferTable.java (97%) delete mode 100644 Plan/test/main/java/com/djrapitops/plan/database/DBUtilsTest.java rename Plan/test/main/java/com/djrapitops/plan/{ => system}/database/DatabaseTest.java (98%) rename Plan/test/main/java/com/djrapitops/plan/{ => system}/database/tables/ActionsTest.java (83%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index b0d311b8bb..b1e4f8e8a8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -23,18 +23,20 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.command.PlanCommand; import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.database.DBSystem; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.GeolocationCache; -import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.systems.info.InformationManager; @@ -42,9 +44,7 @@ import com.djrapitops.plan.systems.listeners.*; import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plan.systems.processing.importing.importers.OfflinePlayerImporter; -import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.webserver.WebServer; import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plan.systems.webserver.pagecache.PageCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index a521c7d9ef..971cec842f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -5,24 +5,24 @@ package com.djrapitops.plan; import com.djrapitops.plan.command.PlanBungeeCommand; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.systems.Systems; +import com.djrapitops.plan.system.database.DBSystem; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.systems.file.database.DBSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; +import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.listeners.BungeePlayerListener; import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.webserver.WebServer; import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index efc80648f8..683012ca40 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.database.Database; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.InformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index f8757d6b12..4d54088658 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.tables.Actions; -import com.djrapitops.plan.database.tables.SessionsTable; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.tables.Actions; +import com.djrapitops.plan.system.database.tables.SessionsTable; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index 60dd3f858b..08f54df604 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.tables.SecurityTable; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.PassEncryptUtil; import com.djrapitops.plugin.api.Check; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java index 19543b7c46..bbbbca7501 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index ded89d2c69..18162f16c5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -3,10 +3,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.Condition; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index 162b61acef..4a5112cb9a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -1,11 +1,11 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plugin.api.config.Config; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java index 9195b96a8a..f3f93c5de9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java @@ -1,10 +1,10 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index 6e2219a37e..4f3bab355e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -1,11 +1,11 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.databases.SQLiteDB; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.SQLiteDB; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java index 1c328ca843..18dcb5f9c1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.tables.SecurityTable; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java index d24a2a8d2b..b1190782ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java @@ -1,10 +1,10 @@ package com.djrapitops.plan.command.commands.webuser; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.database.tables.SecurityTable; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.tables.SecurityTable; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java index b7c067b507..10ac927384 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.data.container; import com.djrapitops.plan.data.HasDate; -import com.djrapitops.plan.database.tables.Actions; +import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java index 18f4aead36..92a88f610c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.HasDate; -import com.djrapitops.plan.database.tables.Actions; +import com.djrapitops.plan.system.database.tables.Actions; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Objects; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java b/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java index 45590026b2..582f9b2ad6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.data.container; import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.database.tables.Actions; +import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plugin.api.TimeAmount; import com.google.common.base.Objects; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/Container.java b/Plan/src/main/java/com/djrapitops/plan/database/Container.java deleted file mode 100644 index 8e1885f724..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/database/Container.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.djrapitops.plan.database; - -/** - * Class to contain objects in the batches. - * - * @param Object stored. - * @author Rsl1122 - * @since 3.4.3 - */ -public class Container { - - private final T object; - private final int id; - - /** - * Constructor for the object. - * - * @param object Object to place inside the container. - * @param id UserID related to the object. - */ - public Container(T object, int id) { - this.object = object; - this.id = id; - } - - /** - * Get the object in the container. - * - * @return object. - */ - public T getObject() { - return object; - } - - /** - * Get the UserID related to the object. - * - * @return userID - */ - public int getId() { - return id; - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/database/DBUtils.java b/Plan/src/main/java/com/djrapitops/plan/database/DBUtils.java deleted file mode 100644 index c01a9d36b5..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/database/DBUtils.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.database; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Class containing static utility methods used by the Database classes. - * - * @author Rsl1122 - * @since 3.4.3 - */ -public class DBUtils { - - private static final int BATCH_SIZE = 10192; - - /** - * Constructor used to hide the public constructor - */ - private DBUtils() { - throw new IllegalStateException("Utility class"); - } - - /** - * Splits a collection of objects into lists with the size defined by - * BATCH_SIZE. - * - * @param Object type - * @param objects Collection of the objects - * @return Lists with max size of BATCH_SIZE - */ - public static List> splitIntoBatches(Collection objects) { - List> batches = new ArrayList<>(); - - int i = 0; - int j = 0; - - for (T obj : objects) { - if (batches.size() <= j) { - batches.add(new ArrayList<>()); - } - batches.get(j).add(obj); - i++; - if (i % BATCH_SIZE == 0) { - j++; - } - } - return batches; - } - - /** - * @param Object type - * @param objects Collection of the objects - * @return Lists with max size of BATCH_SIZE - */ - public static List>> splitIntoBatchesId(Map> objects) { - List>> wrappedBatches = new ArrayList<>(); - - int i = 0; - int j = 0; - - for (Entry> entry : objects.entrySet()) { - for (T object : entry.getValue()) { - if (wrappedBatches.size() <= j) { - wrappedBatches.add(new ArrayList<>()); - } - - wrappedBatches.get(j).add(new Container<>(object, entry.getKey())); - i++; - if (i % BATCH_SIZE == 0) { - j++; - } - } - } - return wrappedBatches; - } - - /** - * @param Object type - * @param objects Collection of the objects - * @return Lists with max size of BATCH_SIZE - */ - public static List>> splitIntoBatchesWithID(Map objects) { - List>> wrappedBatches = new ArrayList<>(); - - int i = 0; - int j = 0; - - for (Entry entry : objects.entrySet()) { - T object = entry.getValue(); - if (wrappedBatches.size() <= j) { - wrappedBatches.add(new ArrayList<>()); - } - - wrappedBatches.get(j).add(new Container<>(object, entry.getKey())); - i++; - if (i % BATCH_SIZE == 0) { - j++; - } - } - return wrappedBatches; - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 5b0c8f0bc2..5310d11bc5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -5,10 +5,11 @@ package com.djrapitops.plan.system; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.database.DBSystem; +import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; -import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Check; @@ -28,6 +29,7 @@ public abstract class PlanSystem implements SubSystem { protected VersionCheckSystem versionCheckSystem; protected FileSystem fileSystem; protected ConfigSystem configSystem; + protected DBSystem databaseSystem; public PlanSystem() { processingQueue = new ProcessingQueue(); @@ -59,6 +61,7 @@ private void checkSubSystemInitialization() throws EnableException { NullCheck.check(versionCheckSystem, new IllegalStateException("Version Check system was not initialized.")); NullCheck.check(fileSystem, new IllegalStateException("File system was not initialized.")); NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized.")); + NullCheck.check(databaseSystem, new IllegalStateException("Database system was not initialized.")); } catch (Exception e) { throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e); } @@ -94,4 +97,8 @@ public ConfigSystem getConfigSystem() { public FileSystem getFileSystem() { return fileSystem; } + + public DBSystem getDatabaseSystem() { + return databaseSystem; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java similarity index 74% rename from Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanDBSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java index e84c33a5e8..c22470f2cd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java @@ -2,11 +2,11 @@ * 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.file.database; +package com.djrapitops.plan.system.database; import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.database.databases.MySQLDB; -import com.djrapitops.plan.database.databases.SQLiteDB; +import com.djrapitops.plan.system.database.databases.MySQLDB; +import com.djrapitops.plan.system.database.databases.SQLiteDB; import com.djrapitops.plan.system.settings.Settings; /** @@ -14,7 +14,7 @@ * * @author Rsl1122 */ -public class PlanDBSystem extends DBSystem { +public class BukkitDBSystem extends DBSystem { @Override protected void initDatabase() throws DatabaseInitException { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanBungeeDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java similarity index 74% rename from Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanBungeeDBSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java index 25e2eb9ecb..8c216fbd32 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/PlanBungeeDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java @@ -2,19 +2,18 @@ * 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.file.database; +package com.djrapitops.plan.system.database; import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.database.databases.MySQLDB; +import com.djrapitops.plan.system.database.databases.MySQLDB; /** * //TODO Class Javadoc Comment * * @author Rsl1122 */ -public class PlanBungeeDBSystem extends DBSystem { - - +public class BungeeDBSystem extends DBSystem { + @Override protected void initDatabase() throws DatabaseInitException { db = new MySQLDB(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/systems/file/database/DBSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index afadcb9810..32f5f5d901 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/file/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -2,16 +2,17 @@ * 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.file.database; +package com.djrapitops.plan.system.database; import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.databases.SQLDB; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.systems.Systems; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -35,7 +36,9 @@ public DBSystem() { } public static DBSystem getInstance() { - return Systems.getInstance().getDatabaseSystem(); + DBSystem dbSystem = PlanSystem.getInstance().getDatabaseSystem(); + NullCheck.check(dbSystem, new IllegalStateException("Database system was not initialized.")); + return dbSystem; } @Override @@ -77,7 +80,7 @@ public Database getActiveDatabase() { return db; } - public static SQLDB getActiveDatabase(String dbName) throws DatabaseInitException { + public SQLDB getActiveDatabase(String dbName) throws DatabaseInitException { for (SQLDB database : DBSystem.getInstance().getDatabases()) { String dbConfigName = database.getConfigName(); if (Verify.equalsIgnoreCase(dbName, dbConfigName)) { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/database/Database.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index e0ad1310e1..db5b8aa556 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -1,9 +1,9 @@ -package com.djrapitops.plan.database; +package com.djrapitops.plan.system.database.databases; import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; -import com.djrapitops.plan.database.tables.*; +import com.djrapitops.plan.system.database.tables.*; import org.apache.commons.lang3.StringUtils; import java.sql.Connection; @@ -38,7 +38,6 @@ public abstract class Database { protected ServerTable serverTable; - /** * Super constructor. */ diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/MySQLDB.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/MySQLDB.java index 2ea9c55f4e..8837f11bfb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/MySQLDB.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.databases; +package com.djrapitops.plan.system.database.databases; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLDB.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLDB.java index ed544d912c..2ed862a891 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLDB.java @@ -1,12 +1,11 @@ -package com.djrapitops.plan.database.databases; +package com.djrapitops.plan.system.database.databases; import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.container.*; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.tables.*; -import com.djrapitops.plan.database.tables.move.Version8TransferTable; +import com.djrapitops.plan.system.database.tables.*; +import com.djrapitops.plan.system.database.tables.move.Version8TransferTable; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.TimeAmount; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLiteDB.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLiteDB.java index c8380ad43a..e66d7daab9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLiteDB.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.databases; +package com.djrapitops.plan.system.database.databases; import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/processing/ExecStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/processing/ExecStatement.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/database/processing/ExecStatement.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/processing/ExecStatement.java index 0efe6c60bc..7f12a4cacd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/processing/ExecStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/processing/ExecStatement.java @@ -1,8 +1,8 @@ -/* +/* * 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.database.processing; +package com.djrapitops.plan.system.database.processing; import java.sql.PreparedStatement; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/processing/QueryAllStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryAllStatement.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/database/processing/QueryAllStatement.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryAllStatement.java index e7d0247ff0..d4cf06c7d2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/processing/QueryAllStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryAllStatement.java @@ -1,8 +1,8 @@ -/* +/* * 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.database.processing; +package com.djrapitops.plan.system.database.processing; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/processing/QueryStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryStatement.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/database/processing/QueryStatement.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryStatement.java index e024374bbf..b386876832 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/processing/QueryStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryStatement.java @@ -1,8 +1,8 @@ -/* +/* * 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.database.processing; +package com.djrapitops.plan.system.database.processing; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/Insert.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Insert.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/database/sql/Insert.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/sql/Insert.java index 7acba858a7..ac63d3c0cf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/Insert.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Insert.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.sql; +package com.djrapitops.plan.system.database.sql; public class Insert extends SqlParser { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/Select.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Select.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/database/sql/Select.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/sql/Select.java index 142f36a0bf..58e9a249c6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/Select.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Select.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.sql; +package com.djrapitops.plan.system.database.sql; public class Select extends WhereParser { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/Sql.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Sql.java similarity index 89% rename from Plan/src/main/java/com/djrapitops/plan/database/sql/Sql.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/sql/Sql.java index c9b5520602..fdf964c556 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/Sql.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Sql.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.sql; +package com.djrapitops.plan.system.database.sql; public class Sql { public static final String INT = "integer"; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/SqlParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/SqlParser.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/database/sql/SqlParser.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/sql/SqlParser.java index 9110e135a3..3e51824fa6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/SqlParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/SqlParser.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.sql; +package com.djrapitops.plan.system.database.sql; /** * Class for parsing different SQL strings. diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/TableSqlParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/TableSqlParser.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/database/sql/TableSqlParser.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/sql/TableSqlParser.java index 0f286a8915..3edb43fdb9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/TableSqlParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/TableSqlParser.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.sql; +package com.djrapitops.plan.system.database.sql; /** * SqlParser Class for parsing table creation, removal and modification statements. diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/Update.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Update.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/database/sql/Update.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/sql/Update.java index 183f0a2fbb..178b1e43dd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/Update.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Update.java @@ -1,8 +1,8 @@ -/* +/* * 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.database.sql; +package com.djrapitops.plan.system.database.sql; /** * @author Fuzzlemann diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/WhereParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/WhereParser.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/database/sql/WhereParser.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/sql/WhereParser.java index d38bb0ce36..8e03a3d3a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/WhereParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/WhereParser.java @@ -1,8 +1,8 @@ -/* +/* * 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.database.sql; +package com.djrapitops.plan.system.database.sql; /** * @author Fuzzlemann diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Actions.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/Actions.java index e243276cf4..c10eadb2fe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Actions.java @@ -1,8 +1,8 @@ -/* +/* * 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.database.tables; +package com.djrapitops.plan.system.database.tables; import org.apache.commons.lang3.text.WordUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/ActionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/ActionsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java index 6c5b688f9d..189407cc84 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/ActionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java @@ -1,19 +1,19 @@ -/* +/* * 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.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Select; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/CommandUseTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/CommandUseTable.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/CommandUseTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/CommandUseTable.java index 0161f7db27..428f66b144 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/CommandUseTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/CommandUseTable.java @@ -1,14 +1,14 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Select; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/IPsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/IPsTable.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/IPsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/IPsTable.java index e75af6596c..0d08561892 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/IPsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/IPsTable.java @@ -1,14 +1,14 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.GeoInfo; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Select; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/KillsTable.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/KillsTable.java index 129f17b413..eb67b74d8b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/KillsTable.java @@ -1,14 +1,14 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/NicknamesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/NicknamesTable.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/NicknamesTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/NicknamesTable.java index 04ad76e4f1..8b4c1bdd94 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/NicknamesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/NicknamesTable.java @@ -1,13 +1,13 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SecurityTable.java similarity index 89% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/SecurityTable.java index 2c34dc0ce9..00ef2368b4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SecurityTable.java @@ -3,18 +3,18 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Insert; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Insert; +import com.djrapitops.plan.system.database.sql.Select; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java index ef905b5676..ef9a9b7280 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java @@ -2,14 +2,14 @@ * 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.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.*; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.*; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SessionsTable.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/SessionsTable.java index a9a98e8cb1..1b3ab61fb5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SessionsTable.java @@ -1,15 +1,15 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Select; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/TPSTable.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/TPSTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/TPSTable.java index d24549fd57..0cf5af36e5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/TPSTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/TPSTable.java @@ -1,14 +1,14 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Select; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/Table.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Table.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/Table.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/Table.java index 0abde340b5..3837286ffd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/Table.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Table.java @@ -1,9 +1,9 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.utilities.Verify; import com.google.common.base.Objects; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserIDTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserIDTable.java similarity index 83% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/UserIDTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserIDTable.java index cba453050c..695154c697 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserIDTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserIDTable.java @@ -1,7 +1,7 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; import java.sql.PreparedStatement; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java index dbdb316eb5..bf3e97103b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java @@ -2,20 +2,19 @@ * 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.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; -import com.djrapitops.plan.database.sql.Update; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Select; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.sql.Update; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UsersTable.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/UsersTable.java index abfdbb7f4b..9eea711155 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UsersTable.java @@ -1,12 +1,12 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.*; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.*; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/VersionTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/VersionTable.java similarity index 83% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/VersionTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/VersionTable.java index d398549d8c..6fa3c818e9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/VersionTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/VersionTable.java @@ -1,12 +1,12 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTable.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTable.java index 80be4ca9ec..cc1f78a606 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTable.java @@ -1,13 +1,12 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTimesTable.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTimesTable.java index fec3b97c82..84f68dfa4f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTimesTable.java @@ -1,16 +1,16 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Sql; -import com.djrapitops.plan.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.system.database.sql.Sql; +import com.djrapitops.plan.system.database.sql.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/move/BatchOperationTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java index e328d24178..8533cc06ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java @@ -2,14 +2,14 @@ * 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.database.tables.move; +package com.djrapitops.plan.system.database.tables.move; import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.tables.ServerTable; -import com.djrapitops.plan.database.tables.Table; -import com.djrapitops.plan.database.tables.UsersTable; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.tables.ServerTable; +import com.djrapitops.plan.system.database.tables.Table; +import com.djrapitops.plan.system.database.tables.UsersTable; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/database/tables/move/Version8TransferTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java index bce666da9c..3180159af5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java @@ -2,12 +2,12 @@ * 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.database.tables.move; +package com.djrapitops.plan.system.database.tables.move; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.tables.*; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.tables.*; import com.djrapitops.plugin.api.Benchmark; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java index 2cd84c3587..7361c212ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java @@ -8,19 +8,18 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.database.BukkitDBSystem; +import com.djrapitops.plan.system.database.BungeeDBSystem; +import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; -import com.djrapitops.plan.systems.file.database.DBSystem; -import com.djrapitops.plan.systems.file.database.PlanBungeeDBSystem; -import com.djrapitops.plan.systems.file.database.PlanDBSystem; +import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; +import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.tasks.PlanBungeeTaskSystem; import com.djrapitops.plan.systems.tasks.PlanTaskSystem; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.webserver.WebServerSystem; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.lang3.ArrayUtils; @@ -50,7 +49,7 @@ public class Systems { public Systems(Plan plugin) { fileSystem = new FileSystem(plugin); configSystem = new BukkitConfigSystem(); - databaseSystem = new PlanDBSystem(); + databaseSystem = new BukkitDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); taskSystem = new PlanTaskSystem(); @@ -67,7 +66,7 @@ public Systems(Plan plugin) { public Systems(PlanBungee plugin) { fileSystem = new FileSystem(plugin); configSystem = new BungeeConfigSystem(); - databaseSystem = new PlanBungeeDBSystem(); + databaseSystem = new BungeeDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); taskSystem = new PlanBungeeTaskSystem(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java index 4aad6c76ed..2521e19c35 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.systems.cache; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.Database; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index 9aa8ad4d9c..81fcc6bcac 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -11,9 +11,9 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.database.Database; 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.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java index d441d49ce2..99a7efb831 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java @@ -8,10 +8,10 @@ import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; 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.settings.Settings; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java index f4cd81ecef..7d043fe871 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java @@ -8,8 +8,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.tables.ServerTable; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.tables.ServerTable; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index 971e05026a..b059e7031b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -8,8 +8,8 @@ import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.tables.ServerTable; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.tables.ServerTable; import com.djrapitops.plan.systems.webserver.webapi.bukkit.ConfigurationWebAPI; import com.djrapitops.plan.systems.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plugin.api.TimeAmount; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java index 124f1e7cd9..948a9c9e9c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.database.tables.Actions; +import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plan.systems.processing.player.PlayerProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.html.HtmlUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java index dc1665cdec..5f5eb5092e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.database.Database; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.systems.cache.GeolocationCache; import com.djrapitops.plan.systems.processing.importing.ServerImportData; import com.djrapitops.plan.systems.processing.importing.UserImportData; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java index 9b15058364..36505c2012 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.systems.processing.player; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.database.tables.UsersTable; +import com.djrapitops.plan.system.database.tables.UsersTable; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java index 68751ba956..b4df70f6fa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.database.tables.Actions; +import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java index 4dec0a1bb8..e0aac70ce0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.systems.processing.player; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.tables.NicknamesTable; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.tables.NicknamesTable; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.processing.NewNickActionProcessor; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java index 0d29b2110d..a961acbcae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java @@ -6,10 +6,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.tables.Actions; -import com.djrapitops.plan.database.tables.UserInfoTable; -import com.djrapitops.plan.database.tables.UsersTable; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.tables.Actions; +import com.djrapitops.plan.system.database.tables.UserInfoTable; +import com.djrapitops.plan.system.database.tables.UsersTable; import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java index 5ce3ef38cd..518087ea16 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/ResponseHandler.java @@ -8,11 +8,10 @@ import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.database.tables.SecurityTable; +import com.djrapitops.plan.system.database.tables.SecurityTable; import com.djrapitops.plan.systems.webserver.pagecache.PageCache; import com.djrapitops.plan.systems.webserver.pagecache.PageId; import com.djrapitops.plan.systems.webserver.response.*; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.PassEncryptUtil; import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java index 02db10151f..59ccdf1096 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/PlayersPageResponse.java @@ -5,11 +5,10 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.element.TableContainer; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; import com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java index 6877ce5313..58506eb42e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.databases.SQLiteDB; -import com.djrapitops.plan.database.tables.move.BatchOperationTable; -import com.djrapitops.plan.systems.file.database.DBSystem; +import com.djrapitops.plan.system.database.DBSystem; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.SQLiteDB; +import com.djrapitops.plan.system.database.tables.move.BatchOperationTable; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index 8619c2e06f..f46009bd34 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -3,11 +3,11 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 83b6b6c723..07b49e83ac 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -7,10 +7,10 @@ import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.plugin.BanData; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index ce16eef5dc..58cbe33362 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.database.Database; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.utilities.FormatUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java index 4384dd4e1d..e3261fbcf9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java @@ -6,8 +6,7 @@ package com.djrapitops.plan.utilities.uuid; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.UUIDFetcher; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java index a093737f50..13877e46ea 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java @@ -5,7 +5,7 @@ */ package com.djrapitops.plan.data.cache; -import com.djrapitops.plan.database.Database; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.systems.cache.DataCache; import org.bukkit.plugin.java.JavaPlugin; import org.junit.After; diff --git a/Plan/test/main/java/com/djrapitops/plan/database/DBUtilsTest.java b/Plan/test/main/java/com/djrapitops/plan/database/DBUtilsTest.java deleted file mode 100644 index 1969dfe88d..0000000000 --- a/Plan/test/main/java/com/djrapitops/plan/database/DBUtilsTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.database; - -import org.junit.Test; -import test.utilities.RandomData; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -/** - * @author ristolah - */ -public class DBUtilsTest { - - @Test - public void testSplitIntoBatches() { - List list = new ArrayList<>(); - for (int i = 0; i < 21336; i++) { - list.add(i); - } - - List> result = DBUtils.splitIntoBatches(list); - - assertEquals(3, result.size()); - assertEquals(10192, result.get(0).size()); - assertEquals(10192, result.get(1).size()); - assertEquals(952, result.get(2).size()); - } - - @Test - public void testSplitIntoBatchesSingleBatch() { - List list = new ArrayList<>(); - for (int i = 0; i < 10192; i++) { - list.add(i); - } - - List> result = DBUtils.splitIntoBatches(list); - - assertEquals(1, result.size()); - assertEquals(10192, result.get(0).size()); - } - - @Test - public void testSplitIntoBatchesId() { - Map> map = new HashMap<>(); - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 2133; j++) { - map.computeIfAbsent(i, k -> new ArrayList<>()); - map.get(i).add(j); - } - } - - List>> result = DBUtils.splitIntoBatchesId(map); - - assertEquals(3, result.size()); - assertEquals(10192, result.get(0).size()); - assertEquals(10192, result.get(1).size()); - assertEquals(946, result.get(2).size()); - } - - @Test - public void testContainers() { - Object object = new Object(); - int id = RandomData.randomInt(1, 100); - - Container container = new Container<>(object, id); - - assertEquals(id, container.getId()); - assertEquals(object, container.getObject()); - } - -} diff --git a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java similarity index 98% rename from Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java rename to Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index e98c3dd16b..feb51eaaf3 100644 --- a/Plan/test/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan.database; +package com.djrapitops.plan.system.database; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DatabaseInitException; @@ -11,10 +11,11 @@ import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.database.databases.MySQLDB; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.databases.SQLiteDB; -import com.djrapitops.plan.database.tables.*; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.MySQLDB; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.databases.SQLiteDB; +import com.djrapitops.plan.system.database.tables.*; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.systems.processing.player.RegisterProcessor; diff --git a/Plan/test/main/java/com/djrapitops/plan/database/tables/ActionsTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java similarity index 83% rename from Plan/test/main/java/com/djrapitops/plan/database/tables/ActionsTest.java rename to Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java index 27e28d8e63..10018c9af8 100644 --- a/Plan/test/main/java/com/djrapitops/plan/database/tables/ActionsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.database.tables; +package com.djrapitops.plan.system.database.tables; import org.junit.Test; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index 391520aa5d..304a76cbac 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -6,9 +6,9 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.databases.SQLiteDB; -import com.djrapitops.plan.database.tables.UsersTable; +import com.djrapitops.plan.system.database.databases.SQLDB; +import com.djrapitops.plan.system.database.databases.SQLiteDB; +import com.djrapitops.plan.system.database.tables.UsersTable; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/test/main/java/test/utilities/DBTestSuite.java b/Plan/test/main/java/test/utilities/DBTestSuite.java index 8a02fd3470..5175019aed 100644 --- a/Plan/test/main/java/test/utilities/DBTestSuite.java +++ b/Plan/test/main/java/test/utilities/DBTestSuite.java @@ -4,7 +4,7 @@ */ package test.utilities; -import com.djrapitops.plan.database.DatabaseTest; +import com.djrapitops.plan.system.database.DatabaseTest; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; From 193cccc65056665269ed5f6959a760f8e79b3e77 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 13:23:34 +0200 Subject: [PATCH 009/166] Format code --- .../src/main/java/com/djrapitops/plan/Plan.java | 10 ---------- .../java/com/djrapitops/plan/PlanBungee.java | 6 ------ .../java/com/djrapitops/plan/ShutdownHook.java | 2 +- .../main/java/com/djrapitops/plan/api/API.java | 2 +- .../api/exceptions/DBCreateTableException.java | 2 +- .../plan/api/exceptions/DatabaseException.java | 2 +- .../api/exceptions/DatabaseInitException.java | 2 +- .../plan/api/exceptions/EnableException.java | 2 +- .../plan/api/exceptions/ParseException.java | 2 +- .../WebAPIConnectionFailException.java | 2 +- .../plan/api/exceptions/WebAPIException.java | 2 +- .../api/exceptions/WebAPIFailException.java | 2 +- .../exceptions/WebAPIForbiddenException.java | 2 +- .../WebAPIInternalErrorException.java | 2 +- .../api/exceptions/WebAPINotFoundException.java | 2 +- .../djrapitops/plan/command/ConditionUtils.java | 2 +- .../plan/command/PlanBungeeCommand.java | 2 +- .../djrapitops/plan/command/PlanCommand.java | 4 ++-- .../plan/command/commands/AnalyzeCommand.java | 2 +- .../plan/command/commands/DevCommand.java | 2 +- .../plan/command/commands/InfoCommand.java | 2 +- .../plan/command/commands/InspectCommand.java | 2 +- .../plan/command/commands/ListCommand.java | 3 +-- .../command/commands/ListServersCommand.java | 2 +- .../plan/command/commands/ManageCommand.java | 2 +- .../plan/command/commands/NetworkCommand.java | 2 +- .../plan/command/commands/ReloadCommand.java | 2 +- .../plan/command/commands/SearchCommand.java | 2 +- .../plan/command/commands/WebUserCommand.java | 2 +- .../commands/manage/ManageDisableCommand.java | 2 +- .../commands/manage/ManageImportCommand.java | 2 +- .../commands/manage/ManageRemoveCommand.java | 2 +- .../commands/webuser/WebLevelCommand.java | 2 +- .../commands/webuser/WebListUsersCommand.java | 2 +- .../com/djrapitops/plan/data/AnalysisData.java | 2 +- .../java/com/djrapitops/plan/data/HasDate.java | 2 +- .../com/djrapitops/plan/data/PlayerProfile.java | 2 +- .../com/djrapitops/plan/data/ServerProfile.java | 3 +-- .../djrapitops/plan/data/container/Action.java | 2 +- .../djrapitops/plan/data/container/GeoInfo.java | 2 +- .../plan/data/element/AnalysisContainer.java | 2 +- .../plan/data/element/InspectContainer.java | 2 +- .../plan/data/element/TableContainer.java | 2 +- .../djrapitops/plan/data/plugin/BanData.java | 2 +- .../plan/data/plugin/ContainerSize.java | 2 +- .../plan/settings/ServerSpecificSettings.java | 2 +- .../plan/settings/WorldAliasSettings.java | 4 ++-- .../djrapitops/plan/settings/locale/Locale.java | 3 +-- .../djrapitops/plan/settings/theme/Theme.java | 3 +-- .../plan/settings/theme/ThemeConfig.java | 1 - .../djrapitops/plan/system/BukkitSystem.java | 2 ++ .../djrapitops/plan/system/BungeeSystem.java | 2 ++ .../system/database/tables/ServerTable.java | 2 +- .../system/database/tables/UserInfoTable.java | 2 +- .../tables/move/BatchOperationTable.java | 2 +- .../tables/move/Version8TransferTable.java | 2 +- .../system/webserver/APIRequestHandler.java | 2 +- .../system/webserver/APIResponseHandler.java | 9 ++++++--- .../plan/system/webserver/Request.java | 5 +---- .../plan/system/webserver/RequestHandler.java | 4 ++-- .../plan/system/webserver/ResponseHandler.java | 17 +++++------------ .../plan/system/webserver/auth/FailReason.java | 2 +- .../plan/system/webserver/pagecache/PageId.java | 3 +-- .../webserver/pagecache/ResponseCache.java | 4 ++-- .../webserver/pages/DefaultResponses.java | 2 +- .../system/webserver/response/FileResponse.java | 2 +- .../system/webserver/response/ResponseType.java | 2 +- .../response/api/BadRequestResponse.java | 2 +- .../webserver/response/api/JsonResponse.java | 2 +- .../webserver/response/api/SuccessResponse.java | 2 +- .../response/errors/ErrorResponse.java | 2 +- .../response/errors/ForbiddenResponse.java | 2 +- .../response/errors/NotFoundResponse.java | 2 +- .../response/pages/AnalysisPageResponse.java | 2 +- .../response/pages/PlayersPageResponse.java | 6 ++---- .../plan/system/webserver/webapi/WebAPI.java | 6 +++--- .../system/webserver/webapi/WebAPIManager.java | 2 +- .../webapi/bukkit/AnalysisReadyWebAPI.java | 2 +- .../webserver/webapi/bukkit/AnalyzeWebAPI.java | 2 +- .../webapi/bukkit/ConfigurationWebAPI.java | 2 +- .../webserver/webapi/bukkit/InspectWebAPI.java | 2 +- .../webserver/webapi/bukkit/IsOnlineWebAPI.java | 2 +- .../RequestInspectPluginsTabBukkitWebAPI.java | 2 +- .../webserver/webapi/bungee/IsCachedWebAPI.java | 2 +- .../webserver/webapi/bungee/PostHtmlWebAPI.java | 4 ++-- .../bungee/PostInspectPluginsTabWebAPI.java | 2 +- .../bungee/PostNetworkPageContentWebAPI.java | 2 +- .../PostOriginalBukkitSettingsWebAPI.java | 2 +- .../webapi/bungee/RequestPluginsTabWebAPI.java | 2 +- .../webapi/bungee/RequestSetupWebAPI.java | 2 +- .../webserver/webapi/universal/PingWebAPI.java | 2 +- .../com/djrapitops/plan/systems/Systems.java | 6 ------ .../systems/info/BukkitInformationManager.java | 4 ++-- .../systems/info/BungeeInformationManager.java | 4 ++-- .../plan/systems/info/ImporterManager.java | 2 +- .../plan/systems/info/InformationManager.java | 6 +++--- .../info/parsing/AnalysisPageParser.java | 2 +- .../systems/info/parsing/NetworkPageParser.java | 2 +- .../plan/systems/info/parsing/PageParser.java | 2 +- .../plan/systems/info/parsing/UrlParser.java | 2 +- .../info/server/BukkitServerInfoManager.java | 2 +- .../info/server/BungeeServerInfoManager.java | 6 +----- .../plan/systems/info/server/ServerInfo.java | 2 +- .../systems/info/server/ServerInfoFile.java | 2 +- .../systems/processing/CommandProcessor.java | 2 +- .../processing/NewNickActionProcessor.java | 2 +- .../plan/systems/processing/Processor.java | 2 +- .../systems/processing/TPSInsertProcessor.java | 3 +-- .../processing/importing/ServerImportData.java | 2 +- .../processing/importing/UserImportData.java | 2 +- .../processing/importing/UserImportRefiner.java | 2 +- .../importing/importers/Importer.java | 2 +- .../importers/OfflinePlayerImporter.java | 2 +- .../BungeePluginChannelSenderProcessor.java | 2 +- .../info/InspectCacheRequestProcessor.java | 3 +-- .../info/NetworkPageUpdateProcessor.java | 2 +- .../processing/player/BanAndOpProcessor.java | 2 +- .../player/BungeePlayerRegisterProcessor.java | 2 +- .../processing/player/EndSessionProcessor.java | 2 +- .../processing/player/FirstLeaveProcessor.java | 2 +- .../processing/player/IPUpdateProcessor.java | 2 +- .../processing/player/KickProcessor.java | 2 +- .../processing/player/NameProcessor.java | 2 +- .../processing/player/PlayerProcessor.java | 2 +- .../processing/player/RegisterProcessor.java | 2 +- .../plan/systems/tasks/PlanTaskSystem.java | 2 +- .../plan/systems/tasks/TaskSystem.java | 1 - .../djrapitops/plan/utilities/NullCheck.java | 3 ++- .../comparators/HasDateComparator.java | 2 +- .../comparators/PieSliceComparator.java | 2 +- .../utilities/file/export/SpecificExport.java | 2 +- .../plan/utilities/html/HtmlStructure.java | 2 +- .../plan/utilities/html/HtmlUtils.java | 1 - .../html/graphs/ActivityStackGraph.java | 2 +- .../utilities/html/graphs/pie/ActivityPie.java | 2 +- .../utilities/html/graphs/pie/PieSeries.java | 2 +- .../utilities/html/graphs/pie/PieSlice.java | 2 +- .../utilities/html/graphs/pie/WorldPie.java | 2 +- .../AnalysisPluginsTabContentCreator.java | 2 +- .../InspectPluginsTabContentCreator.java | 2 +- .../structure/SessionTabStructureCreator.java | 2 +- .../html/tables/ActionsTableCreator.java | 2 +- .../utilities/html/tables/IpTableCreator.java | 2 +- .../html/tables/SessionsTableCreator.java | 4 ++-- .../plan/utilities/metrics/BStats.java | 6 +++--- .../test/main/java/test/utilities/TestInit.java | 2 +- 146 files changed, 167 insertions(+), 207 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 5970aae7d3..a3cf97636c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -23,7 +23,6 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.command.PlanCommand; import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.database.Database; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; @@ -35,18 +34,12 @@ import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; -import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.processing.ProcessingQueue; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.settings.config.ConfigSystem; -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.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.GeolocationCache; -import com.djrapitops.plan.systems.file.database.DBSystem; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.systems.info.InformationManager; @@ -55,9 +48,6 @@ import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plan.systems.processing.importing.importers.OfflinePlayerImporter; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.systems.webserver.WebServer; -import com.djrapitops.plan.systems.webserver.WebServerSystem; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index c3cbf28cfa..ce8b1d1dcb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -5,7 +5,6 @@ package com.djrapitops.plan; import com.djrapitops.plan.command.PlanBungeeCommand; -import com.djrapitops.plan.database.Database; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; @@ -20,17 +19,12 @@ import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.systems.Systems; -import com.djrapitops.plan.systems.file.database.DBSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.listeners.BungeePlayerListener; import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.systems.webserver.WebServer; -import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index 4d54088658..f8db0687a0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/API.java b/Plan/src/main/java/com/djrapitops/plan/api/API.java index c47595ddb4..87c056a39e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/API.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/API.java @@ -83,7 +83,7 @@ public void addPluginDataSource(PluginData dataSource) { */ public String getPlayerInspectPageLink(String name) { if (name == null) { - return "#"; + return "#"; } return "../player/" + name.replace(" ", "%20").replace(".", "%2E"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBCreateTableException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBCreateTableException.java index a107022f8a..0b8085feb8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBCreateTableException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBCreateTableException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseException.java index 5804614aaf..a754b0d718 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseInitException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseInitException.java index 73628a3b08..042e1657e6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseInitException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseInitException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/EnableException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/EnableException.java index 3ecaa5fb25..4646f49ade 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/EnableException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/EnableException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java index c72bdd4b6f..ed891f7af2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIConnectionFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIConnectionFailException.java index 9acef62414..13bbb40969 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIConnectionFailException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIConnectionFailException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIException.java index 6cbf73b4ab..b084f0a620 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIFailException.java index 354db876bb..c575b88104 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIFailException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIFailException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIForbiddenException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIForbiddenException.java index 8aa2a587e6..51ca8b31ea 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIForbiddenException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIForbiddenException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIInternalErrorException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIInternalErrorException.java index 1c44dc6c95..ba5825c82f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIInternalErrorException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIInternalErrorException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java index e2eb5c632e..e0adfa710d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java b/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java index d5bd2dcaba..2cc744783d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java @@ -29,7 +29,7 @@ private ConditionUtils() { * @return has the player played before, false if uuid is null. */ public static boolean playerHasPlayed(UUID uuid) { - if ( Verify.containsNull(uuid)) { + if (Verify.containsNull(uuid)) { return false; } boolean hasPlayed; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java index eed4c92ed3..a89a4aa3e2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.command.commands.*; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.defaultcmds.StatusCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java index 7e5974d79e..a68bfb5dbe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.commands.*; -import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.defaultcmds.StatusCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 647080f930..6166606457 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index ec5a068d11..e0673b018a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java index bddbe26eaf..8546feeb06 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index d4dbc3f28f..71ef34beb1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.ConditionUtils; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; 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 7406733657..0ecc3a5638 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,9 +1,8 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java index a7ebd34e78..dfc47621c2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java index 04926184a9..192130f077 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.commands.manage.*; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; 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 7c56b3bed1..2d63a7b958 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 @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java index f7f480aad6..89a99979e3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java index 9e6f468eba..c48ea78e2d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java index 94b66e4b00..74c203b35a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.command.commands.webuser.WebDeleteCommand; import com.djrapitops.plan.command.commands.webuser.WebLevelCommand; import com.djrapitops.plan.command.commands.webuser.WebListUsersCommand; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java index c08be9927e..03e969ece1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands.manage; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.listeners.PlanPlayerListener; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.command.CommandType; 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 6ecaf7c186..acc7f92e58 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 @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +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; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 42a4695501..3738efed88 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.Condition; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java index 95464a7bfd..0bf6f26e0d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands.webuser; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java index a6a4e8e7f1..f067343b21 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.comparators.WebUserComparator; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java index af3ad3e968..3bd8b92a97 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.data.element.HealthNotes; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/HasDate.java b/Plan/src/main/java/com/djrapitops/plan/data/HasDate.java index 5c4b03c63c..1c19a76f65 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/HasDate.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/HasDate.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index eda9fc2ab1..d5fc03b72f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java index aba72ac2ce..58e8c775a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -12,7 +12,6 @@ import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plan.utilities.comparators.PlayerProfileLastPlayedComparator; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java index 10ac927384..3a31adfba7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java b/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java index c9fa363c56..773c0e1fb0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/AnalysisContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/element/AnalysisContainer.java index c97a895471..2efb126ef6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/AnalysisContainer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/AnalysisContainer.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java index e52ea0c8ac..95c7dce033 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java index 64e7542087..759f04344a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/BanData.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/BanData.java index 3f3b035c8e..a2097562a1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/BanData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/BanData.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/ContainerSize.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/ContainerSize.java index 87dd725a20..3dae7883dd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/ContainerSize.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/ContainerSize.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java index b1bbdf22a5..361bd1d6cf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java b/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java index d64cf6ad56..bb7f3e3986 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java @@ -1,11 +1,11 @@ -/* +/* * 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.settings; -import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.config.ConfigNode; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java index 2dfca4158f..1e85e61d99 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java @@ -1,10 +1,9 @@ package com.djrapitops.plan.settings.locale; +import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plan.utilities.comparators.LocaleEntryComparator; import com.djrapitops.plan.utilities.comparators.StringLengthComparator; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java b/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java index 41175780e3..05d2bacc2e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java @@ -5,10 +5,9 @@ package com.djrapitops.plan.settings.theme; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.EnumUtility; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java b/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java index df1d5e131d..f017478bf0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java @@ -5,7 +5,6 @@ package com.djrapitops.plan.settings.theme; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index af6032991d..d845f13107 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.database.BukkitDBSystem; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; @@ -20,5 +21,6 @@ public BukkitSystem(Plan plugin) { versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); fileSystem = new FileSystem(plugin); configSystem = new BukkitConfigSystem(); + databaseSystem = new BukkitDBSystem(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java index d516d5f7df..895a1c3943 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.system.database.BungeeDBSystem; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; @@ -20,5 +21,6 @@ public BungeeSystem(PlanBungee plugin) { versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); fileSystem = new FileSystem(plugin); configSystem = new BungeeConfigSystem(); + databaseSystem = new BungeeDBSystem(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java index ef9a9b7280..12c42c6587 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java index bf3e97103b..e8c27d4b62 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java index 8533cc06ee..dcced5574f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java index 3180159af5..0648fcfe9f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java index a5c515bc3d..87f8c05976 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java index 005db193b9..6c2e4632ce 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java @@ -1,12 +1,15 @@ -/* +/* * 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.webserver; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.response.*; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.CSSResponse; +import com.djrapitops.plan.system.webserver.response.JavaScriptResponse; +import com.djrapitops.plan.system.webserver.response.RedirectResponse; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java index f7825e0308..c2ffff451e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java @@ -1,16 +1,13 @@ -/* +/* * 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.webserver; import com.djrapitops.plan.system.webserver.auth.Authentication; -import com.djrapitops.plugin.utilities.Verify; -import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import java.io.InputStream; -import java.util.List; import java.util.Optional; /** diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java index 5b6082e80d..885ff36184 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -57,7 +57,7 @@ public void handle(HttpExchange exchange) { } finally { exchange.close(); if (Settings.DEV_MODE.isTrue()) { - Log.debug(requestString + " Response code: " + responseCode+" took "+Benchmark.stop("", requestString)+" ms"); + Log.debug(requestString + " Response code: " + responseCode + " took " + Benchmark.stop("", requestString) + " ms"); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 559180643f..d353acc106 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -5,14 +5,11 @@ package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.database.tables.SecurityTable; import com.djrapitops.plan.system.webserver.auth.Authentication; -import com.djrapitops.plan.system.webserver.auth.FailReason; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pages.*; import com.djrapitops.plan.system.webserver.response.*; import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; @@ -20,18 +17,14 @@ import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse; -import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import com.djrapitops.plan.system.webserver.response.pages.PlayersPageResponse; -import com.djrapitops.plan.system.database.tables.SecurityTable; -import com.djrapitops.plan.systems.webserver.pagecache.PageCache; -import com.djrapitops.plan.systems.webserver.pagecache.PageId; import com.djrapitops.plan.systems.webserver.response.*; -import com.djrapitops.plan.utilities.PassEncryptUtil; -import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.UUID; /** * Handles choosing of the correct response to a request. diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java index a3273dea43..2aa60d224f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java @@ -9,7 +9,7 @@ * * @author Rsl1122 */ -public enum FailReason { +public enum FailReason { USER_AND_PASS_NOT_SPECIFIED("User and Password not specified"), USER_DOES_NOT_EXIST("User does not exist"), USER_PASS_MISMATCH("User and Password did not match"), diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java index 8359fe57af..700b458db7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java @@ -27,8 +27,7 @@ public enum PageId { CSS("css:"), // FAVICON_REDIRECT("Redirect:Favicon"), - AUTH_PROMPT("PromptAuth") - ; + AUTH_PROMPT("PromptAuth"); private final String id; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java index 9e32b912fe..887fa3b3ae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.system.webserver.pagecache; -import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import java.util.HashMap; import java.util.Map; @@ -66,7 +66,7 @@ public static Response loadResponse(String identifier) { /** * Returns a copy some responses - * + *

* Currently supported copyable responses: InspectPageResponse * * @param identifier The identifier of the page diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java index b43c9951cc..4d3a3e31d2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java @@ -4,9 +4,9 @@ */ package com.djrapitops.plan.system.webserver.pages; -import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.PromptAuthorizationResponse; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; /** * //TODO Class Javadoc Comment diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java index d8ad5ef780..4397758b7a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/FileResponse.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java index 4cbb01aabb..a9d61c57a1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java index fd29437d35..63f8cbf736 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/JsonResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/JsonResponse.java index 396f09c0a0..bb17adb87f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/JsonResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/JsonResponse.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/SuccessResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/SuccessResponse.java index 97c9c209ef..bf34c79406 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/SuccessResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/SuccessResponse.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java index 3f509c9e9c..e6357e6c91 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java index 347a0b514c..1d0d9a7b80 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java @@ -9,7 +9,7 @@ public class ForbiddenResponse extends ErrorResponse { public ForbiddenResponse() { super.setHeader("HTTP/1.1 403 Forbidden"); - super.setTitle(Html.FONT_AWESOME_ICON.parse("hand-stop-o")+" 403 Forbidden - Access Denied"); + super.setTitle(Html.FONT_AWESOME_ICON.parse("hand-stop-o") + " 403 Forbidden - Access Denied"); } public ForbiddenResponse(String msg) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java index 429fd1ea5a..1ce3432363 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java @@ -10,7 +10,7 @@ public class NotFoundResponse extends ErrorResponse { public NotFoundResponse() { super.setHeader("HTTP/1.1 404 Not Found"); - super.setTitle(Html.FONT_AWESOME_ICON.parse("map-signs")+" 404 Not Found"); + super.setTitle(Html.FONT_AWESOME_ICON.parse("map-signs") + " 404 Not Found"); super.setParagraph("Page does not exist."); super.replacePlaceholders(); } 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 8ef5faeae2..c988598b81 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 @@ -2,8 +2,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.AnalysisData; -import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; 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; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java index e2eead7948..9be634220e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java @@ -5,13 +5,11 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.element.TableContainer; -import com.djrapitops.plan.database.Database; import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; -import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index 0eaa1b8855..d288baaab8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -7,12 +7,12 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.*; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.api.SuccessResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java index 2887562ac0..b6cbfddebb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ 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 eff3e7889f..1f08ce47d3 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 @@ -1,4 +1,4 @@ -/* +/* * 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 */ 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 b5047045a6..6bc3714eab 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 @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index 1b2bf7ab2c..f4a92b0f54 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java index 7985c5a1d0..b0c8446e75 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java index 6aa8c70411..66df8b759a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java index 5fa25b9507..00dc96adc5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java index a5b5586462..b756187258 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ 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 8466905942..09ec52f367 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 @@ -7,11 +7,11 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; -import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.utilities.file.export.HtmlExport; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java index 1d89cf8786..c28a4b0049 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java index f874266a73..45517b6075 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java index 3300ad5862..3ea7361643 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index 465029b0c5..91b53107a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index 74e2c5d8b5..f59a7f37db 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -9,8 +9,8 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.api.Check; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java index c3afc031f4..51890fa519 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java index 1e8a0176bb..8f843b8ebe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java @@ -17,15 +17,9 @@ import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.systems.file.database.DBSystem; -import com.djrapitops.plan.systems.file.database.PlanBungeeDBSystem; -import com.djrapitops.plan.systems.file.database.PlanDBSystem; -import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.systems.tasks.PlanBungeeTaskSystem; import com.djrapitops.plan.systems.tasks.PlanTaskSystem; import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.systems.webserver.WebServerSystem; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.lang3.ArrayUtils; 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 index 679f968af2..5ca1ade113 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -15,9 +15,9 @@ 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.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.response.*; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.Response; 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.errors.NotFoundResponse; 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 index 085d73d079..58142d4117 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -10,9 +10,9 @@ import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.response.*; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java index 934341f793..1b214d07d7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ 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 index 3904741eec..e304742714 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -1,12 +1,12 @@ -/* +/* * 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.api.exceptions.ParseException; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plugin.command.ISender; @@ -88,5 +88,5 @@ public boolean isAuthRequired() { public abstract void updateNetworkPageContent(); - public abstract TreeMap> getErrors() throws IOException; + public abstract TreeMap> getErrors() throws IOException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java index 44ccce54b8..2c1576c4d3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java index 99a7efb831..700f5e907f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java index b4eb1be73b..159d16d402 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java index 8373f71162..0b0b19a509 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java index 7d043fe871..990fd56343 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index 2a80be4061..964f2bd301 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -10,10 +10,6 @@ import com.djrapitops.plan.api.exceptions.WebAPIException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.tables.ServerTable; -import com.djrapitops.plan.systems.webserver.webapi.bukkit.ConfigurationWebAPI; -import com.djrapitops.plan.systems.webserver.webapi.universal.PingWebAPI; -import com.djrapitops.plan.database.Database; -import com.djrapitops.plan.database.tables.ServerTable; import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI; import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plugin.api.TimeAmount; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java index 59ca572e58..5f5ea247b3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoFile.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoFile.java index dd3bbda541..4af0227913 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoFile.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoFile.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java index 585b95243e..397f0f5300 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java index 948a9c9e9c..03a160d7d4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java index 0e870716b0..f50feca713 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java index 942136a922..14cc30cfc1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java @@ -1,11 +1,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.systems.processing; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java index f99196d5ac..6dbe9b1ca9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java index 3941da6a94..8ab60be7f4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java index 955ea3c5c5..8bb791541f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java index 5f5eb5092e..ec40302bbd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java index 439db70db9..200bbd3535 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java index 3b51cb1c1e..c261565460 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java index dd841d3520..0c760249cb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -10,7 +10,6 @@ import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.processing.player.PlayerProcessor; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/NetworkPageUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/NetworkPageUpdateProcessor.java index e085b887f5..6691675a6a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/NetworkPageUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/NetworkPageUpdateProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java index a008bd3789..c2f3adafb1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java index 36505c2012..9087703de6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java index 410d734a58..bcbcac9426 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java index b4df70f6fa..57b506530a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java index 36b16b3955..15915b1c9b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java index a3d3de46fc..e8339ed0c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java index e0aac70ce0..fc9f53b8e0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/PlayerProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/PlayerProcessor.java index 628c88c42c..f0cbbe0ae4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/PlayerProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/PlayerProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java index a961acbcae..1791d84baf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java index 03280b2b86..1b843a8ebf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java @@ -5,9 +5,9 @@ package com.djrapitops.plan.systems.tasks; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.TimeAmount; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java index 7459d12d77..ff64d92ca3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java @@ -6,7 +6,6 @@ import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.systems.Systems; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.systems.TaskCenter; import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.IRunnable; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java b/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java index 54bf636fda..fc7de19efe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java @@ -11,7 +11,8 @@ */ public class NullCheck { - private NullCheck() {} + private NullCheck() { + } public static void check(Object toCheck, T throwIfNull) throws T { if (toCheck == null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java index b7afe27c5b..4f271db59f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java index 1be438a05d..06c6b8922f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index 2f23feb418..df67b81d29 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.utilities.file.export; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 58cbe33362..a1a7e85cd2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java index c96508c5a7..e57c5f8998 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java @@ -2,7 +2,6 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.utilities.MiscUtils; import org.apache.commons.lang3.text.StrSubstitutor; import java.io.Serializable; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java index d1d8f7d533..77a8fd1445 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java index 1ab72b2f7e..6ed0d2bf38 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSeries.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSeries.java index bc71845a32..a71d24120f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSeries.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSeries.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java index 01c5628eae..f941f6a073 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java index fead86ff2a..afa5d3e244 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.WorldAliasSettings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.comparators.PieSliceComparator; import java.util.*; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java index afc536bbde..0b033649a1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java index 68f4cc4f5d..83e9c85861 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index 02a5ccd83f..8690136d7a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java index 9a1c29d8a2..27b567d87a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/IpTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/IpTableCreator.java index e3e44b882c..a39757ea64 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/IpTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/IpTableCreator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index a1c74ba6aa..f3541a23ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -7,8 +7,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.WorldAliasSettings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.FormatUtils; 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 8b60034768..e9e799cc78 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 @@ -32,7 +32,7 @@ private void registerConfigSettingGraphs() { String serverType = plugin.getServer().getName(); if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) { serverType = "Spigot"; - } + } String databaseType = plugin.getDB().getName(); String analysisRefreshPeriod = Integer.toString(Settings.ANALYSIS_AUTO_REFRESH.getNumber()); String themeBase = Settings.THEME_BASE.toString(); @@ -41,7 +41,7 @@ private void registerConfigSettingGraphs() { addStringSettingPie("database_type", databaseType); addStringSettingPie("analysis_periodic_refresh", analysisRefreshPeriod); addStringSettingPie("theme_base", themeBase); - + addFeatureBarChart("features"); } @@ -60,7 +60,7 @@ private void addFeatureBarChart(String id) { if (isConnectedToBungee) { map.put("Copy Bungee Config Values", isEnabled(Settings.BUNGEE_COPY_CONFIG.isTrue())); map.put("Standalone Override", isEnabled(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isTrue())); - } + } map.put("Log Unknown Commands", isEnabled(Settings.LOG_UNKNOWN_COMMANDS.isTrue())); map.put("Combine Command Aliases", isEnabled(Settings.COMBINE_COMMAND_ALIASES.isTrue())); return map; diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index 6bae629038..4f81875370 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -2,8 +2,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.ServerVariableHolder; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.settings.locale.Locale; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; import com.djrapitops.plan.utilities.file.FileUtil; From d9e98430699ff68e862893a3e33f971393772638 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 13:46:32 +0200 Subject: [PATCH 010/166] Abstracted ListenerSystem, moved Processors to new package --- .../main/java/com/djrapitops/plan/Plan.java | 26 +-- .../java/com/djrapitops/plan/PlanBungee.java | 11 +- .../java/com/djrapitops/plan/PlanPlugin.java | 2 +- .../plan/command/commands/InspectCommand.java | 2 +- .../commands/manage/ManageDisableCommand.java | 4 +- .../djrapitops/plan/system/BukkitSystem.java | 4 + .../djrapitops/plan/system/BungeeSystem.java | 4 + .../djrapitops/plan/system/PlanSystem.java | 17 +- .../listeners/BukkitListenerSystem.java | 32 ++++ .../listeners/BungeeListenerSystem.java | 23 +++ .../plan/system/listeners/ListenerSystem.java | 25 +++ .../system/listeners/bukkit/ChatListener.java | 61 +++++++ .../bukkit/CommandPreprocessListener.java | 77 +++++++++ .../listeners/bukkit/DeathEventListener.java | 133 +++++++++++++++ .../bukkit/GamemodeChangeListener.java | 60 +++++++ .../bukkit/PlayerOnlineListener.java | 154 ++++++++++++++++++ .../listeners/bukkit/WorldChangeListener.java | 42 +++++ .../bungee/PlayerOnlineListener.java} | 8 +- .../system/processing/ProcessingQueue.java | 2 +- .../processors}/CommandProcessor.java | 2 +- .../processors}/NewNickActionProcessor.java | 4 +- .../processing/processors}/Processor.java | 2 +- .../processors}/TPSInsertProcessor.java | 3 +- .../importing/ServerImportData.java | 2 +- .../processors}/importing/UserImportData.java | 2 +- .../importing/UserImportRefiner.java | 2 +- .../importing/importers/Importer.java | 8 +- .../importers/OfflinePlayerImporter.java | 6 +- .../info/InspectCacheRequestProcessor.java | 4 +- .../info/NetworkPageUpdateProcessor.java | 4 +- .../processors}/player/BanAndOpProcessor.java | 2 +- .../player/BungeePlayerRegisterProcessor.java | 2 +- .../processors}/player/DeathProcessor.java | 2 +- .../player/EndSessionProcessor.java | 2 +- .../player/FirstLeaveProcessor.java | 2 +- .../processors}/player/IPUpdateProcessor.java | 2 +- .../processors}/player/KickProcessor.java | 2 +- .../processors}/player/KillProcessor.java | 2 +- .../processors}/player/NameProcessor.java | 4 +- .../processors}/player/PlayerProcessor.java | 4 +- .../processors}/player/RegisterProcessor.java | 4 +- .../bungee/RequestPluginsTabWebAPI.java | 2 +- .../plan/systems/cache/SessionCache.java | 2 +- .../info/BukkitInformationManager.java | 2 +- .../plan/systems/info/ImporterManager.java | 2 +- .../BungeePluginChannelSenderProcessor.java | 39 ----- .../plan/systems/tasks/TPSCountTimer.java | 2 +- .../importer/ImportBuilderTest.java | 4 +- .../plan/system/database/DatabaseTest.java | 2 +- 49 files changed, 695 insertions(+), 114 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/BungeeListenerSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java rename Plan/src/main/java/com/djrapitops/plan/{systems/listeners/BungeePlayerListener.java => system/listeners/bungee/PlayerOnlineListener.java} (81%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/CommandProcessor.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/NewNickActionProcessor.java (90%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/Processor.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/TPSInsertProcessor.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/importing/ServerImportData.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/importing/UserImportData.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/importing/UserImportRefiner.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/importing/importers/Importer.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/importing/importers/OfflinePlayerImporter.java (85%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/info/InspectCacheRequestProcessor.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/info/NetworkPageUpdateProcessor.java (81%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/BanAndOpProcessor.java (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/BungeePlayerRegisterProcessor.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/DeathProcessor.java (91%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/EndSessionProcessor.java (90%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/FirstLeaveProcessor.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/IPUpdateProcessor.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/KickProcessor.java (92%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/KillProcessor.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/NameProcessor.java (94%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/PlayerProcessor.java (81%) rename Plan/src/main/java/com/djrapitops/plan/{systems/processing => system/processing/processors}/player/RegisterProcessor.java (94%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index a3cf97636c..09b6212325 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -27,10 +27,13 @@ import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.BukkitSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.processors.importing.importers.OfflinePlayerImporter; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; @@ -44,9 +47,6 @@ import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; -import com.djrapitops.plan.systems.listeners.*; -import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plan.systems.processing.importing.importers.OfflinePlayerImporter; import com.djrapitops.plan.systems.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; @@ -180,11 +180,6 @@ public void onEnable() { Benchmark.stop("Enable", "WebServer Initialization"); - if (!reloading) { - registerListeners(); - } - PlanPlayerListener.setCountKicks(true); - TaskSystem.getInstance().enable(); this.api = new API(this); @@ -273,18 +268,7 @@ public String getVersion() { @Override public void onReload() { - ConfigSystem.reload(); - } - private void registerListeners() { - Benchmark.start("Register Listeners"); - registerListener(new PlanPlayerListener(this)); - registerListener(new PlanChatListener(this)); - registerListener(new PlanGamemodeChangeListener(this)); - registerListener(new PlanWorldChangeListener(this)); - registerListener(new PlanCommandPreprocessListener(this)); - registerListener(new PlanDeathEventListener(this)); - Benchmark.stop("Enable", "Register Listeners"); } /** @@ -434,4 +418,8 @@ public API getApi() { public Systems getSystems() { return systems; } + + public BukkitSystem getSystem() { + return system; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index ce8b1d1dcb..28545d4e88 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -9,10 +9,12 @@ import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.BungeeSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; @@ -22,8 +24,6 @@ import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.systems.listeners.BungeePlayerListener; -import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plan.systems.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; @@ -55,6 +55,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { private ProcessingQueue processingQueue; private boolean setupAllowed = false; + private BungeeSystem system; @Override public void onEnable() { @@ -94,8 +95,6 @@ public void onEnable() { processingQueue = new ProcessingQueue(); - registerListener(new BungeePlayerListener(this)); - Log.logDebug("Enable", "WebServer Initialization"); Log.info(Locale.get(Msg.ENABLED).toString()); if (Settings.ANALYSIS_EXPORT.isTrue()) { @@ -211,4 +210,8 @@ public boolean isSetupAllowed() { public void setSetupAllowed(boolean setupAllowed) { this.setupAllowed = setupAllowed; } + + public BungeeSystem getSystem() { + return system; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 0932ced168..7513469043 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -6,10 +6,10 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.config.Config; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 71ef34beb1..0cba2c0c7f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -4,8 +4,8 @@ import com.djrapitops.plan.command.ConditionUtils; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.processing.processors.info.InspectCacheRequestProcessor; import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.uuid.UUIDUtility; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java index 03e969ece1..3fcd989f26 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java @@ -2,8 +2,8 @@ import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.listeners.bukkit.PlayerOnlineListener; import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.systems.listeners.PlanPlayerListener; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; @@ -34,7 +34,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { } switch (args[0].toLowerCase()) { case "kickcount": - PlanPlayerListener.setCountKicks(false); + PlayerOnlineListener.setCountKicks(false); sender.sendMessage("§aDisabled Kick Counting temporarily until next plugin reload."); break; default: diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index d845f13107..7d3132b6fa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -23,4 +23,8 @@ public BukkitSystem(Plan plugin) { configSystem = new BukkitConfigSystem(); databaseSystem = new BukkitDBSystem(); } + + public static BukkitSystem getInstance() { + return Plan.getInstance().getSystem(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java index 895a1c3943..1388475a08 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -23,4 +23,8 @@ public BungeeSystem(PlanBungee plugin) { configSystem = new BungeeConfigSystem(); databaseSystem = new BungeeDBSystem(); } + + public static BungeeSystem getInstance() { + return PlanBungee.getInstance().getSystem(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 5310d11bc5..774e191942 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.listeners.ListenerSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; @@ -31,6 +32,8 @@ public abstract class PlanSystem implements SubSystem { protected ConfigSystem configSystem; protected DBSystem databaseSystem; + protected ListenerSystem listenerSystem; + public PlanSystem() { processingQueue = new ProcessingQueue(); } @@ -40,14 +43,19 @@ public void enable() throws EnableException { checkSubSystemInitialization(); versionCheckSystem.enable(); + fileSystem.enable(); configSystem.enable(); + databaseSystem.enable(); processingQueue.enable(); + listenerSystem.enable(); } @Override public void disable() { processingQueue.disable(); + databaseSystem.disable(); configSystem.disable(); + fileSystem.disable(); versionCheckSystem.disable(); } @@ -62,6 +70,7 @@ private void checkSubSystemInitialization() throws EnableException { NullCheck.check(fileSystem, new IllegalStateException("File system was not initialized.")); NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized.")); NullCheck.check(databaseSystem, new IllegalStateException("Database system was not initialized.")); + NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); } catch (Exception e) { throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e); } @@ -73,9 +82,9 @@ public static PlanSystem getInstance() { if (bukkitAvailable && bungeeAvailable) { // TODO test system. } else if (bungeeAvailable) { - // todo bungee + return BungeeSystem.getInstance(); } else { - // Todo bukkit + return BukkitSystem.getInstance(); } throw new IllegalAccessError("PlanSystem is not available on this platform."); } @@ -101,4 +110,8 @@ public FileSystem getFileSystem() { public DBSystem getDatabaseSystem() { return databaseSystem; } + + public ListenerSystem getListenerSystem() { + return listenerSystem; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java new file mode 100644 index 0000000000..c2118f80f3 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java @@ -0,0 +1,32 @@ +package com.djrapitops.plan.system.listeners; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.listeners.bukkit.*; +import org.bukkit.event.HandlerList; + +public class BukkitListenerSystem extends ListenerSystem { + + private final Plan plugin; + + public BukkitListenerSystem(Plan plugin) { + this.plugin = plugin; + } + + @Override + protected void registerListeners() { + plugin.registerListener( + new PlayerOnlineListener(plugin), + new ChatListener(plugin), + new GamemodeChangeListener(plugin), + new WorldChangeListener(plugin), + new CommandPreprocessListener(plugin), + new DeathEventListener(plugin) + ); + PlayerOnlineListener.setCountKicks(true); + } + + @Override + protected void unregisterListeners() { + HandlerList.unregisterAll(plugin); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/BungeeListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BungeeListenerSystem.java new file mode 100644 index 0000000000..99e4f6abcf --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BungeeListenerSystem.java @@ -0,0 +1,23 @@ +package com.djrapitops.plan.system.listeners; + +import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.system.listeners.bungee.PlayerOnlineListener; + +public class BungeeListenerSystem extends ListenerSystem { + + private final PlanBungee plugin; + + public BungeeListenerSystem(PlanBungee plugin) { + this.plugin = plugin; + } + + @Override + protected void registerListeners() { + plugin.registerListener(new PlayerOnlineListener(plugin)); + } + + @Override + protected void unregisterListeners() { + plugin.getProxy().getPluginManager().unregisterListeners(plugin); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java new file mode 100644 index 0000000000..4b4e717d1a --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java @@ -0,0 +1,25 @@ +package com.djrapitops.plan.system.listeners; + +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plugin.api.Benchmark; + +public abstract class ListenerSystem implements SubSystem { + + @Override + public void enable() { + Benchmark.start("Register Listeners"); + registerListeners(); + Benchmark.stop("Enable", "Register Listeners"); + } + + @Override + public void disable() { + unregisterListeners(); + } + + protected abstract void registerListeners(); + + protected abstract void unregisterListeners(); + + +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java new file mode 100644 index 0000000000..53c0ba6455 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java @@ -0,0 +1,61 @@ +package com.djrapitops.plan.system.listeners.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.processing.processors.player.NameProcessor; +import com.djrapitops.plan.systems.cache.DataCache; +import com.djrapitops.plugin.api.utility.log.Log; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +import java.util.UUID; + +/** + * Event Listener for AsyncPlayerChatEvents. + * + * @author Rsl1122 + */ +public class ChatListener implements Listener { + + private final Plan plugin; + private final DataCache dataCache; + + /** + * Class Constructor. + * + * @param plugin Current instance of Plan + */ + public ChatListener(Plan plugin) { + this.plugin = plugin; + dataCache = plugin.getDataCache(); + } + + /** + * ChatEvent listener. + * + * @param event Fired Event + */ + @EventHandler(priority = EventPriority.MONITOR) + public void onChat(AsyncPlayerChatEvent event) { + if (event.isCancelled()) { + return; + } + + try { + Player p = event.getPlayer(); + UUID uuid = p.getUniqueId(); + String name = p.getName(); + String displayName = p.getDisplayName(); + + if (dataCache.isFirstSession(uuid)) { + dataCache.firstSessionMessageSent(uuid); + } + + plugin.addToProcessQueue(new NameProcessor(uuid, name, displayName)); + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java new file mode 100644 index 0000000000..0a20f3dec6 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java @@ -0,0 +1,77 @@ +package com.djrapitops.plan.system.listeners.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.processing.processors.CommandProcessor; +import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.utility.log.Log; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +/** + * Event Listener for PlayerCommandPreprocessEvents. + * + * @author Rsl1122 + */ +public class CommandPreprocessListener implements Listener { + + private final Plan plugin; + + /** + * Class Constructor. + * + * @param plugin Current instance of Plan + */ + public CommandPreprocessListener(Plan plugin) { + this.plugin = plugin; + } + + /** + * Command use listener. + * + * @param event Fired event. + */ + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerCommand(PlayerCommandPreprocessEvent event) { + if (event.isCancelled()) { + return; + } + Player player = event.getPlayer(); + + try { + if (player.hasPermission(Permissions.IGNORE_COMMANDUSE.getPermission())) { + return; + } + + String commandName = event.getMessage().substring(1).split(" ")[0].toLowerCase(); + + boolean logUnknownCommands = Settings.LOG_UNKNOWN_COMMANDS.isTrue(); + boolean combineCommandAliases = Settings.COMBINE_COMMAND_ALIASES.isTrue(); + + if (!logUnknownCommands || combineCommandAliases) { + Command command = plugin.getServer().getPluginCommand(commandName); + if (command == null) { + try { + command = plugin.getServer().getCommandMap().getCommand(commandName); + } catch (NoSuchMethodError ignored) { + /* Ignored, Bukkit 1.8 has no such method */ + } + } + if (command == null) { + if (!logUnknownCommands) { + return; + } + } else if (combineCommandAliases) { + commandName = command.getName(); + } + } + plugin.addToProcessQueue(new CommandProcessor(commandName)); + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java new file mode 100644 index 0000000000..9a3545f261 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java @@ -0,0 +1,133 @@ +package com.djrapitops.plan.system.listeners.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.processing.processors.player.DeathProcessor; +import com.djrapitops.plan.system.processing.processors.player.KillProcessor; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.utilities.Format; +import org.bukkit.Material; +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.projectiles.ProjectileSource; + +/** + * Event Listener for EntityDeathEvents. + * + * @author Rsl1122 + */ +public class DeathEventListener implements Listener { + + private final Plan plugin; + + /** + * Class Constructor. + * + * @param plugin Current instance of Plan + */ + public DeathEventListener(Plan plugin) { + this.plugin = plugin; + } + + /** + * Command use listener. + * + * @param event Fired event. + */ + @SuppressWarnings("deprecation") + @EventHandler(priority = EventPriority.MONITOR) + public void onDeath(EntityDeathEvent event) { + long time = MiscUtils.getTime(); + LivingEntity dead = event.getEntity(); + + if (dead instanceof Player) { + plugin.addToProcessQueue(new DeathProcessor(dead.getUniqueId())); + } + + try { + EntityDamageEvent entityDamageEvent = dead.getLastDamageCause(); + if (!(entityDamageEvent instanceof EntityDamageByEntityEvent)) { + return; + } + + EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) entityDamageEvent; + Entity killerEntity = entityDamageByEntityEvent.getDamager(); + + if (killerEntity instanceof Player) { + handlePlayerKill(time, dead, (Player) killerEntity); + } else if (killerEntity instanceof Wolf) { + handleWolfKill(time, dead, (Wolf) killerEntity); + } else if (killerEntity instanceof Arrow) { + handleArrowKill(time, dead, (Arrow) killerEntity); + } + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } + + private void handlePlayerKill(long time, LivingEntity dead, Player killer) { + Material itemInHand; + try { + itemInHand = killer.getInventory().getItemInMainHand().getType(); + } catch (NoSuchMethodError e) { + try { + itemInHand = killer.getInventory().getItemInHand().getType(); // Support for non dual wielding versions. + } catch (Exception | NoSuchMethodError | NoSuchFieldError e2) { + itemInHand = Material.AIR; + } + } + + plugin.addToProcessQueue(new KillProcessor(killer.getUniqueId(), time, dead, normalizeMaterialName(itemInHand))); + } + + private void handleWolfKill(long time, LivingEntity dead, Wolf wolf) { + if (!wolf.isTamed()) { + return; + } + + AnimalTamer owner = wolf.getOwner(); + if (!(owner instanceof Player)) { + return; + } + + plugin.addToProcessQueue(new KillProcessor(owner.getUniqueId(), time, dead, "Wolf")); + } + + private void handleArrowKill(long time, LivingEntity dead, Arrow arrow) { + ProjectileSource source = arrow.getShooter(); + if (!(source instanceof Player)) { + return; + } + + Player player = (Player) source; + + plugin.addToProcessQueue(new KillProcessor(player.getUniqueId(), time, dead, "Bow")); + } + + /** + * Normalizes a material name + * + * @param material The material + * @return The normalized material name + */ + private String normalizeMaterialName(Material material) { + String[] parts = material.name().split("_"); + StringBuilder builder = new StringBuilder(); + + for (int i = 0; i < parts.length; i++) { + String part = new Format(parts[i]).capitalize().toString(); + builder.append(part); + if (i < parts.length - 1) { + builder.append(" "); + } + } + + return builder.toString(); + } +} + diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java new file mode 100644 index 0000000000..dbfdb6c95d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java @@ -0,0 +1,60 @@ +package com.djrapitops.plan.system.listeners.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.settings.WorldAliasSettings; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.utility.log.Log; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerGameModeChangeEvent; + +import java.util.Optional; +import java.util.UUID; + +/** + * Event Listener for PlayerGameModeChangeEvents. + * + * @author Rsl1122 + */ +public class GamemodeChangeListener implements Listener { + + private final Plan plugin; + + /** + * Class Constructor. + * + * @param plugin Current instance of Plan + */ + public GamemodeChangeListener(Plan plugin) { + this.plugin = plugin; + } + + /** + * GM Change Event Listener. + * + * @param event Fired Event. + */ + @EventHandler(priority = EventPriority.MONITOR) + public void onGamemodeChange(PlayerGameModeChangeEvent event) { + if (event.isCancelled()) { + return; + } + try { + Player p = event.getPlayer(); + UUID uuid = p.getUniqueId(); + long time = MiscUtils.getTime(); + String gameMode = event.getNewGameMode().name(); + String worldName = p.getWorld().getName(); + + new WorldAliasSettings().addWorld(worldName); + + Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); + cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time)); + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java new file mode 100644 index 0000000000..2a5aa85827 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -0,0 +1,154 @@ +package com.djrapitops.plan.system.listeners.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; +import com.djrapitops.plan.system.processing.processors.player.*; +import com.djrapitops.plan.systems.cache.DataCache; +import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.systems.NotificationCenter; +import com.djrapitops.plugin.api.utility.log.Log; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.UUID; + +/** + * Event Listener for PlayerJoin, PlayerQuit and PlayerKickEvents. + * + * @author Rsl1122 + * @since 2.0.0 + */ +public class PlayerOnlineListener implements Listener { + + private static boolean countKicks = true; + + private final Plan plugin; + private final DataCache cache; + + /** + * Class Constructor. + * + * @param plugin Current instance of Plan + */ + public PlayerOnlineListener(Plan plugin) { + this.plugin = plugin; + cache = plugin.getDataCache(); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerLogin(PlayerLoginEvent event) { + try { + PlayerLoginEvent.Result result = event.getResult(); + UUID uuid = event.getPlayer().getUniqueId(); + boolean op = event.getPlayer().isOp(); + if (result == PlayerLoginEvent.Result.KICK_BANNED) { + plugin.addToProcessQueue(new BanAndOpProcessor(uuid, true, op)); + } else { + plugin.addToProcessQueue(new BanAndOpProcessor(uuid, false, op)); + } + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } + + /** + * PlayerKickEvent Listener. + *

+ * Adds processing information to the ProcessingQueue. + * After KickEvent, the QuitEvent is automatically called. + * + * @param event Fired event + */ + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerKick(PlayerKickEvent event) { + try { + if (!countKicks || event.isCancelled()) { + return; + } + UUID uuid = event.getPlayer().getUniqueId(); + plugin.addToProcessQueue(new KickProcessor(uuid)); + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } + + /** + * PlayerJoinEvent Listener. + *

+ * Adds processing information to the ProcessingQueue. + * + * @param event The Fired event. + */ + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerJoin(PlayerJoinEvent event) { + try { + Player player = event.getPlayer(); + NotificationCenter.checkNotifications(player); + + UUID uuid = player.getUniqueId(); + long time = MiscUtils.getTime(); + + String world = player.getWorld().getName(); + String gm = player.getGameMode().name(); + + String ip = player.getAddress().getAddress().getHostAddress(); + + String playerName = player.getName(); + String displayName = player.getDisplayName(); + + int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline(); + + cache.cacheSession(uuid, Session.start(time, world, gm)); + plugin.addToProcessQueue( + new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline, + new IPUpdateProcessor(uuid, ip, time), + new NameProcessor(uuid, playerName, displayName) + ), + new NetworkPageUpdateProcessor(plugin.getInfoManager()) + ); + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } + + /** + * PlayerQuitEvent Listener. + *

+ * Adds processing information to the ProcessingQueue. + * + * @param event Fired event + */ + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerQuit(PlayerQuitEvent event) { + try { + long time = MiscUtils.getTime(); + Player player = event.getPlayer(); + UUID uuid = player.getUniqueId(); + + plugin.addToProcessQueue( + new BanAndOpProcessor(uuid, player.isBanned(), player.isOp()), + new EndSessionProcessor(uuid, time), + new NetworkPageUpdateProcessor(plugin.getInfoManager()) + ); + + if (cache.isFirstSession(uuid)) { + int messagesSent = plugin.getDataCache().getFirstSessionMsgCount(uuid); + plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent)); + } + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } + + public static void setCountKicks(boolean value) { + countKicks = value; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java new file mode 100644 index 0000000000..860465d83a --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java @@ -0,0 +1,42 @@ +package com.djrapitops.plan.system.listeners.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.settings.WorldAliasSettings; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.utility.log.Log; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; + +import java.util.Optional; +import java.util.UUID; + +public class WorldChangeListener implements Listener { + private final Plan plugin; + + public WorldChangeListener(Plan plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onWorldChange(PlayerChangedWorldEvent event) { + try { + Player p = event.getPlayer(); + String worldName = p.getWorld().getName(); + + UUID uuid = p.getUniqueId(); + String gameMode = p.getGameMode().name(); + long time = MiscUtils.getTime(); + + new WorldAliasSettings().addWorld(worldName); + + Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); + cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time)); + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/BungeePlayerListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/systems/listeners/BungeePlayerListener.java rename to Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java index c5f728c159..8937317f39 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/BungeePlayerListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.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.systems.listeners; +package com.djrapitops.plan.system.listeners.bungee; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.systems.processing.player.BungeePlayerRegisterProcessor; +import com.djrapitops.plan.system.processing.processors.player.BungeePlayerRegisterProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -20,11 +20,11 @@ * * @author Rsl1122 */ -public class BungeePlayerListener implements Listener { +public class PlayerOnlineListener implements Listener { private final PlanBungee plugin; - public BungeePlayerListener(PlanBungee plugin) { + public PlayerOnlineListener(PlanBungee plugin) { this.plugin = plugin; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index d7c35a7c84..fa9a16e6f8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -3,7 +3,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.systems.processing.Processor; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.systems.queue.Consumer; import com.djrapitops.plan.systems.queue.Queue; import com.djrapitops.plan.systems.queue.Setup; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java index 397f0f5300..00a01bc37e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/CommandProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.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.systems.processing; +package com.djrapitops.plan.system.processing.processors; import com.djrapitops.plan.Plan; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java index 03a160d7d4..8229f432bb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/NewNickActionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java @@ -2,12 +2,12 @@ * 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.processing; +package com.djrapitops.plan.system.processing.processors; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.database.tables.Actions; -import com.djrapitops.plan.systems.processing.player.PlayerProcessor; +import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java index f50feca713..88575dcd8b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/Processor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.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.systems.processing; +package com.djrapitops.plan.system.processing.processors; import com.djrapitops.plan.system.processing.ProcessingQueue; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java index 14cc30cfc1..7b3664a26e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java @@ -2,8 +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.processing; +package com.djrapitops.plan.system.processing.processors; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/ServerImportData.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/ServerImportData.java index 6dbe9b1ca9..1624d758f9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/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.systems.processing.importing; +package com.djrapitops.plan.system.processing.processors.importing; import com.djrapitops.plan.data.container.TPS; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportData.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportData.java index 8ab60be7f4..572607797f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/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.systems.processing.importing; +package com.djrapitops.plan.system.processing.processors.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/systems/processing/importing/UserImportRefiner.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportRefiner.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/UserImportRefiner.java index 8bb791541f..0afe68c081 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/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.systems.processing.importing; +package com.djrapitops.plan.system.processing.processors.importing; import com.djrapitops.plan.Plan; import com.djrapitops.plugin.api.Benchmark; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/Importer.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/Importer.java index ec40302bbd..48e8c662ec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/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.systems.processing.importing.importers; +package com.djrapitops.plan.system.processing.processors.importing.importers; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.GeoInfo; @@ -10,10 +10,10 @@ import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.time.WorldTimes; 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.systems.cache.GeolocationCache; -import com.djrapitops.plan.systems.processing.importing.ServerImportData; -import com.djrapitops.plan.systems.processing.importing.UserImportData; -import com.djrapitops.plan.systems.processing.importing.UserImportRefiner; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/OfflinePlayerImporter.java similarity index 85% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/importing/importers/OfflinePlayerImporter.java index 200bbd3535..ed7546cbe0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/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.systems.processing.importing.importers; +package com.djrapitops.plan.system.processing.processors.importing.importers; -import com.djrapitops.plan.systems.processing.importing.ServerImportData; -import com.djrapitops.plan.systems.processing.importing.UserImportData; +import com.djrapitops.plan.system.processing.processors.importing.ServerImportData; +import com.djrapitops.plan.system.processing.processors.importing.UserImportData; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java index 0c760249cb..5e57630f02 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java @@ -2,14 +2,14 @@ * 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.processing.info; +package com.djrapitops.plan.system.processing.processors.info; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.processing.player.PlayerProcessor; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/NetworkPageUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/info/NetworkPageUpdateProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java index 6691675a6a..a0c879c538 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/NetworkPageUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.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.systems.processing.info; +package com.djrapitops.plan.system.processing.processors.info; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.systems.processing.Processor; /** * //TODO Class Javadoc Comment diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BanAndOpProcessor.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BanAndOpProcessor.java index c2f3adafb1..6f1382759c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BanAndOpProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BanAndOpProcessor.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.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java index 9087703de6..4dbcad6005 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/BungeePlayerRegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.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.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.system.database.tables.UsersTable; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/DeathProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/DeathProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java index c519e51f92..91c0464dba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/DeathProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/EndSessionProcessor.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/EndSessionProcessor.java index bcbcac9426..55e7e2f677 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/EndSessionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/EndSessionProcessor.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.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java index 57b506530a..90290109d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.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.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Action; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java index 15915b1c9b..c1b5cc17ac 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/IPUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.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.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.GeoInfo; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KickProcessor.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KickProcessor.java index e8339ed0c4..79361ae929 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KickProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KickProcessor.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.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KillProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KillProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java index ceffd2a072..ce24473825 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/KillProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.PlayerKill; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java index fc9f53b8e0..0a74b71e00 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java @@ -2,13 +2,13 @@ * 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.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.tables.NicknamesTable; +import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor; import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.processing.NewNickActionProcessor; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/PlayerProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/PlayerProcessor.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/PlayerProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/PlayerProcessor.java index f0cbbe0ae4..d65f4fd23c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/PlayerProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/PlayerProcessor.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.processing.player; +package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.systems.processing.Processor; +import com.djrapitops.plan.system.processing.processors.Processor; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index 1791d84baf..3ac0b095f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.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.systems.processing.player; +package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Action; @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plan.system.database.tables.UserInfoTable; import com.djrapitops.plan.system.database.tables.UsersTable; -import com.djrapitops.plan.systems.processing.Processor; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index 91b53107a5..f03d86e6c7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -7,11 +7,11 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; import com.djrapitops.plan.systems.info.server.ServerInfo; -import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java index 95740524d1..3ace0c79c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.systems.processing.Processor; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; 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 index 5ca1ade113..d5260fcf9d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -12,6 +12,7 @@ import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.system.webserver.WebServerSystem; @@ -32,7 +33,6 @@ import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.parsing.AnalysisPageParser; import com.djrapitops.plan.systems.info.parsing.InspectPageParser; -import com.djrapitops.plan.systems.processing.Processor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.file.export.HtmlExport; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java index 1b214d07d7..762a45a248 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.systems.info; -import com.djrapitops.plan.systems.processing.importing.importers.Importer; +import com.djrapitops.plan.system.processing.processors.importing.importers.Importer; import java.util.ArrayList; import java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java deleted file mode 100644 index c261565460..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/info/BungeePluginChannelSenderProcessor.java +++ /dev/null @@ -1,39 +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.processing.info; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.systems.processing.Processor; -import com.djrapitops.plugin.api.utility.log.Log; -import org.bukkit.entity.Player; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ -public class BungeePluginChannelSenderProcessor extends Processor { - - public BungeePluginChannelSenderProcessor(Player object) { - super(object); - } - - @Override - public void process() { - Log.debug("Sending a Bungee Address get Request through plugin channel"); - try (ByteArrayOutputStream b = new ByteArrayOutputStream()) { - try (DataOutputStream out = new DataOutputStream(b)) { - out.writeUTF("bungee_address_get"); - object.sendPluginMessage(Plan.getInstance(), "BungeeCord", b.toByteArray()); - } - } catch (IOException e) { - Log.toLog(this.getClass().getName(), e); - } - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java index a950016ef5..c41d2fc0bd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java @@ -4,7 +4,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.systems.processing.TPSInsertProcessor; +import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plugin.api.Check; 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 42e728f0bd..b6e1e5e9ee 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 @@ 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.systems.processing.importing.ServerImportData; -import com.djrapitops.plan.systems.processing.importing.UserImportData; +import com.djrapitops.plan.system.processing.processors.importing.ServerImportData; +import com.djrapitops.plan.system.processing.processors.importing.UserImportData; import com.google.common.collect.ImmutableMap; import org.junit.Test; import test.utilities.RandomData; diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index feb51eaaf3..6eaf5e7eb7 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -16,9 +16,9 @@ import com.djrapitops.plan.system.database.databases.SQLDB; import com.djrapitops.plan.system.database.databases.SQLiteDB; import com.djrapitops.plan.system.database.tables.*; +import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.server.ServerInfo; -import com.djrapitops.plan.systems.processing.player.RegisterProcessor; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; From 0e80545e9197c1a1ab9184b4bbf07abcce9ae42d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 13:47:05 +0200 Subject: [PATCH 011/166] Moved queue package --- .../djrapitops/plan/system/processing/ProcessingQueue.java | 6 +++--- .../plan/{systems => utilities}/queue/Consumer.java | 2 +- .../djrapitops/plan/{systems => utilities}/queue/Queue.java | 2 +- .../djrapitops/plan/{systems => utilities}/queue/Setup.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/{systems => utilities}/queue/Consumer.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems => utilities}/queue/Queue.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems => utilities}/queue/Setup.java (94%) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index fa9a16e6f8..ddf5fe84f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -4,10 +4,10 @@ import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.processing.processors.Processor; -import com.djrapitops.plan.systems.queue.Consumer; -import com.djrapitops.plan.systems.queue.Queue; -import com.djrapitops.plan.systems.queue.Setup; import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plan.utilities.queue.Consumer; +import com.djrapitops.plan.utilities.queue.Queue; +import com.djrapitops.plan.utilities.queue.Setup; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/queue/Consumer.java b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/queue/Consumer.java rename to Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java index 62268296b0..95e900a4f0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/queue/Consumer.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.queue; +package com.djrapitops.plan.utilities.queue; import com.djrapitops.plugin.task.AbsRunnable; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/queue/Queue.java b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Queue.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/queue/Queue.java rename to Plan/src/main/java/com/djrapitops/plan/utilities/queue/Queue.java index 126c395be5..809096f500 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/queue/Queue.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Queue.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.queue; +package com.djrapitops.plan.utilities.queue; import java.util.ArrayList; import java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/queue/Setup.java b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Setup.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/systems/queue/Setup.java rename to Plan/src/main/java/com/djrapitops/plan/utilities/queue/Setup.java index 694da7a744..f0031cdc13 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/queue/Setup.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Setup.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.queue; +package com.djrapitops.plan.utilities.queue; import com.djrapitops.plugin.task.RunnableFactory; From 8f6b196b604f24340aa0697bbcfe86bb9116eb23 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 13:51:52 +0200 Subject: [PATCH 012/166] Moved task system --- Plan/src/main/java/com/djrapitops/plan/Plan.java | 3 ++- Plan/src/main/java/com/djrapitops/plan/PlanBungee.java | 2 +- .../java/com/djrapitops/plan/system/PlanSystem.java | 8 ++++++++ .../plan/system/listeners/ListenerSystem.java | 8 ++++++++ .../system/listeners/bukkit/PlayerOnlineListener.java | 2 +- .../tasks/BukkitTaskSystem.java} | 4 ++-- .../tasks/BungeeTaskSystem.java} | 4 ++-- .../plan/{systems => system}/tasks/TPSCountTimer.java | 2 +- .../plan/{systems => system}/tasks/TaskSystem.java | 7 ++++--- .../main/java/com/djrapitops/plan/systems/Systems.java | 10 +++++----- .../plan/systems/info/InformationManager.java | 1 + .../djrapitops/plan/utilities/analysis/Analysis.java | 6 +++--- .../plan/utilities/html/graphs/line/RamGraph.java | 2 +- .../utilities/html/graphs/line/WorldLoadGraph.java | 2 +- 14 files changed, 40 insertions(+), 21 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/{systems/tasks/PlanTaskSystem.java => system/tasks/BukkitTaskSystem.java} (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems/tasks/PlanBungeeTaskSystem.java => system/tasks/BungeeTaskSystem.java} (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/tasks/TPSCountTimer.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/tasks/TaskSystem.java (86%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 09b6212325..3e5855bb1c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -47,7 +47,7 @@ import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; @@ -357,6 +357,7 @@ public Config getMainConfig() { return ConfigSystem.getInstance().getConfig(); } + @Deprecated public InformationManager getInfoManager() { return infoManager; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 28545d4e88..130b30457e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -24,7 +24,7 @@ import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 774e191942..b6ea59b9d2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.system.listeners.ListenerSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; 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.utilities.NullCheck; import com.djrapitops.plugin.api.Check; @@ -33,6 +34,7 @@ public abstract class PlanSystem implements SubSystem { protected DBSystem databaseSystem; protected ListenerSystem listenerSystem; + protected TaskSystem taskSystem; public PlanSystem() { processingQueue = new ProcessingQueue(); @@ -48,12 +50,14 @@ public void enable() throws EnableException { databaseSystem.enable(); processingQueue.enable(); listenerSystem.enable(); + taskSystem.enable(); } @Override public void disable() { processingQueue.disable(); databaseSystem.disable(); + taskSystem.disable(); configSystem.disable(); fileSystem.disable(); versionCheckSystem.disable(); @@ -114,4 +118,8 @@ public DBSystem getDatabaseSystem() { public ListenerSystem getListenerSystem() { return listenerSystem; } + + public TaskSystem getTaskSystem() { + return taskSystem; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java index 4b4e717d1a..486dfe4597 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java @@ -1,10 +1,18 @@ package com.djrapitops.plan.system.listeners; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; public abstract class ListenerSystem implements SubSystem { + public static ListenerSystem getInstance() { + ListenerSystem listenerSystem = PlanSystem.getInstance().getListenerSystem(); + NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); + return listenerSystem; + } + @Override public void enable() { Benchmark.start("Register Listeners"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index 2a5aa85827..eaa6b9f345 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -5,7 +5,7 @@ import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; import com.djrapitops.plan.system.processing.processors.player.*; import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.systems.NotificationCenter; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index 1b843a8ebf..46d2b2d3f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.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.systems.tasks; +package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.Plan; import com.djrapitops.plan.settings.locale.Locale; @@ -21,7 +21,7 @@ * * @author Rsl1122 */ -public class PlanTaskSystem extends TaskSystem { +public class BukkitTaskSystem extends TaskSystem { // TODO Remove Plan.getInstance requirement. diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java index 74bbb617d6..dcdc15a1bb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.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.systems.tasks; +package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.systems.info.BungeeInformationManager; @@ -14,7 +14,7 @@ * * @author Rsl1122 */ -public class PlanBungeeTaskSystem extends TaskSystem { +public class BungeeTaskSystem extends TaskSystem { @Override public void enable() { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java index c41d2fc0bd..fd1a324da3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.tasks; +package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java similarity index 86% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java index ff64d92ca3..8cc02c0863 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java @@ -2,10 +2,11 @@ * 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.tasks; +package com.djrapitops.plan.system.tasks; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plugin.api.systems.TaskCenter; import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.IRunnable; @@ -21,7 +22,7 @@ public abstract class TaskSystem implements SubSystem { protected TPSCountTimer tpsCountTimer; public static TaskSystem getInstance() { - return Systems.getInstance().getTaskSystem(); + return PlanSystem.getInstance().getTaskSystem(); } protected IRunnable registerTask(AbsRunnable runnable) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java index 8f843b8ebe..b0d9dd2ca5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java @@ -17,9 +17,9 @@ import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.systems.tasks.PlanBungeeTaskSystem; -import com.djrapitops.plan.systems.tasks.PlanTaskSystem; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.BungeeTaskSystem; +import com.djrapitops.plan.system.tasks.BukkitTaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.lang3.ArrayUtils; @@ -52,7 +52,7 @@ public Systems(Plan plugin) { databaseSystem = new BukkitDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); - taskSystem = new PlanTaskSystem(); + taskSystem = new BukkitTaskSystem(); webServerSystem = new WebServerSystem(); themeSystem = new Theme(); @@ -69,7 +69,7 @@ public Systems(PlanBungee plugin) { databaseSystem = new BungeeDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); - taskSystem = new PlanBungeeTaskSystem(); + taskSystem = new BungeeTaskSystem(); webServerSystem = new WebServerSystem(); themeSystem = new Theme(); 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 index e304742714..11e39f7f38 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -21,6 +21,7 @@ * * @author Rsl1122 */ +@Deprecated public abstract class InformationManager { boolean usingAnotherWebServer; String webServerAddress; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index d7ae999e73..ee191dd8b0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -16,8 +16,8 @@ import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.systems.tasks.PlanTaskSystem; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.BukkitTaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; @@ -55,7 +55,7 @@ public void runAnalysis(InformationManager infoManager) { return; } - ((PlanTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis(); + ((BukkitTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis(); Benchmark.start("Analysis"); log(Locale.get(Msg.ANALYSIS_START).toString()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java index 71340d85e4..61ef570a63 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.utilities.html.graphs.line; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.systems.tasks.TPSCountTimer; +import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plan.utilities.analysis.Point; import java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java index 0964743801..40cee358c6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.utilities.html.graphs.line; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.systems.tasks.TPSCountTimer; +import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plan.utilities.analysis.Point; import java.util.List; From fb09f327efdaf0148ea977af34e066b6a9587900 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 14:15:35 +0200 Subject: [PATCH 013/166] Split TPSCountTimer into multiple subclasses. --- .../djrapitops/plan/system/BukkitSystem.java | 4 + .../djrapitops/plan/system/BungeeSystem.java | 4 + .../djrapitops/plan/system/PlanSystem.java | 45 +++-- .../system/settings/config/ConfigSystem.java | 4 +- .../plan/system/tasks/BukkitTaskSystem.java | 15 +- .../plan/system/tasks/BungeeTaskSystem.java | 9 +- .../plan/system/tasks/TPSCountTimer.java | 155 +----------------- .../tasks/bukkit/BukkitTPSCountTimer.java | 112 +++++++++++++ .../tasks/bukkit/PaperTPSCountTimer.java | 35 ++++ .../tasks/bungee/BungeeTPSCountTimer.java | 19 +++ .../com/djrapitops/plan/systems/Systems.java | 8 +- .../info/BukkitInformationManager.java | 1 + .../info/BungeeInformationManager.java | 2 + .../plan/systems/info/parsing/UrlParser.java | 77 --------- .../info/server/BukkitServerInfoManager.java | 1 + .../info/server/BungeeServerInfoManager.java | 1 + 16 files changed, 241 insertions(+), 251 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BukkitTPSCountTimer.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PaperTPSCountTimer.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/BungeeTPSCountTimer.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index 7d3132b6fa..821fdce1d2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -7,7 +7,9 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.database.BukkitDBSystem; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.listeners.BukkitListenerSystem; import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; +import com.djrapitops.plan.system.tasks.BukkitTaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; /** @@ -22,6 +24,8 @@ public BukkitSystem(Plan plugin) { fileSystem = new FileSystem(plugin); configSystem = new BukkitConfigSystem(); databaseSystem = new BukkitDBSystem(); + listenerSystem = new BukkitListenerSystem(plugin); + taskSystem = new BukkitTaskSystem(plugin); } public static BukkitSystem getInstance() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java index 1388475a08..72d157d9c0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -7,7 +7,9 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.system.database.BungeeDBSystem; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.listeners.BungeeListenerSystem; import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; +import com.djrapitops.plan.system.tasks.BungeeTaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; /** @@ -22,6 +24,8 @@ public BungeeSystem(PlanBungee plugin) { fileSystem = new FileSystem(plugin); configSystem = new BungeeConfigSystem(); databaseSystem = new BungeeDBSystem(); + listenerSystem = new BungeeListenerSystem(plugin); + taskSystem = new BungeeTaskSystem(plugin); } public static BungeeSystem getInstance() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index b6ea59b9d2..04efebdbd8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -44,28 +44,36 @@ public PlanSystem() { public void enable() throws EnableException { checkSubSystemInitialization(); - versionCheckSystem.enable(); - fileSystem.enable(); - configSystem.enable(); - databaseSystem.enable(); - processingQueue.enable(); - listenerSystem.enable(); - taskSystem.enable(); + SubSystem[] systems = new SubSystem[]{ + versionCheckSystem, + fileSystem, + configSystem, + databaseSystem, + processingQueue, + listenerSystem, + taskSystem + }; + for (SubSystem system : systems) { + system.enable(); + } } @Override public void disable() { - processingQueue.disable(); - databaseSystem.disable(); - taskSystem.disable(); - configSystem.disable(); - fileSystem.disable(); - versionCheckSystem.disable(); - } - - public void reload() throws EnableException { - checkSubSystemInitialization(); - configSystem.reload(); + SubSystem[] systems = new SubSystem[]{ + listenerSystem, + processingQueue, + databaseSystem, + taskSystem, + configSystem, + fileSystem, + versionCheckSystem + }; + for (SubSystem system : systems) { + if (system != null) { + system.disable(); + } + } } private void checkSubSystemInitialization() throws EnableException { @@ -75,6 +83,7 @@ private void checkSubSystemInitialization() throws EnableException { NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized.")); NullCheck.check(databaseSystem, new IllegalStateException("Database system was not initialized.")); NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); + NullCheck.check(taskSystem, new IllegalStateException("Task system was not initialized.")); } catch (Exception e) { throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index 368f2ba627..b58d7e3565 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; @@ -34,7 +34,7 @@ public ConfigSystem() { } public static ConfigSystem getInstance() { - ConfigSystem configSystem = Systems.getInstance().getConfigSystem(); + ConfigSystem configSystem = PlanSystem.getInstance().getConfigSystem(); NullCheck.check(configSystem, new IllegalStateException("Config System has not been initialized.")); return configSystem; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index 46d2b2d3f5..e79576e8e4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -8,8 +8,11 @@ import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.tasks.bukkit.BukkitTPSCountTimer; +import com.djrapitops.plan.system.tasks.bukkit.PaperTPSCountTimer; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plugin.api.Benchmark; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; @@ -23,7 +26,11 @@ */ public class BukkitTaskSystem extends TaskSystem { - // TODO Remove Plan.getInstance requirement. + private final Plan plugin; + + public BukkitTaskSystem(Plan plugin) { + this.plugin = plugin; + } private ITask bootAnalysisTask; @@ -38,7 +45,9 @@ private void registerTasks() { String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString(); Benchmark.start("Task Registration"); - tpsCountTimer = new TPSCountTimer(Plan.getInstance()); + tpsCountTimer = Check.isPaperAvailable() + ? new PaperTPSCountTimer(plugin) + : new BukkitTPSCountTimer(plugin); registerTask(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks()); // Analysis refresh settings @@ -48,7 +57,7 @@ private void registerTasks() { Log.info(bootAnalysisMsg); - InformationManager infoManager = Plan.getInstance().getInfoManager(); + InformationManager infoManager = plugin.getInfoManager(); bootAnalysisTask = RunnableFactory.createNew("BootAnalysisTask", new AbsRunnable() { @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java index dcdc15a1bb..9a7d868fe5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.task.AbsRunnable; @@ -16,6 +17,12 @@ */ public class BungeeTaskSystem extends TaskSystem { + private final PlanBungee plugin; + + public BungeeTaskSystem(PlanBungee plugin) { + this.plugin = plugin; + } + @Override public void enable() { registerTasks(); @@ -31,7 +38,7 @@ public void run() { infoManager.sendConfigSettings(); } }).runTaskAsynchronously(); - registerTask("Player Count task", new TPSCountTimer(PlanBungee.getInstance())) + registerTask("Player Count task", new BungeeTPSCountTimer(plugin)) .runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks()); registerTask("NetworkPageContentUpdateTask", new AbsRunnable("NetworkPageContentUpdateTask") { @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java index fd1a324da3..efd8015531 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java @@ -1,20 +1,11 @@ package com.djrapitops.plan.system.tasks; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor; import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plan.utilities.analysis.MathUtils; -import com.djrapitops.plugin.api.Check; -import com.djrapitops.plugin.api.TimeAmount; -import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; -import org.bukkit.World; -import java.lang.management.ManagementFactory; -import java.lang.management.OperatingSystemMXBean; import java.util.ArrayList; import java.util.List; @@ -23,22 +14,18 @@ * * @author Rsl1122 */ -public class TPSCountTimer extends AbsRunnable { +public abstract class TPSCountTimer extends AbsRunnable { - private final PlanPlugin plugin; - private final List history; - private long lastCheckNano; + protected final T plugin; + protected final List history; - private final boolean usingBungee; - private int latestPlayersOnline = 0; + protected int latestPlayersOnline = 0; - public TPSCountTimer(PlanPlugin plugin) { + public TPSCountTimer(T plugin) { super("TPSCountTimer"); - lastCheckNano = -1; this.plugin = plugin; history = new ArrayList<>(); - usingBungee = Check.isBungeeAvailable(); } @Override @@ -46,141 +33,15 @@ public void run() { long nanoTime = System.nanoTime(); long now = MiscUtils.getTime(); - if (usingBungee) { - history.add(new TPS(now, -1, ((PlanBungee) plugin).getProxy().getOnlineCount(), -1, -1, -1, -1)); - } else { - long diff = nanoTime - lastCheckNano; - - lastCheckNano = nanoTime; - - if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible. - Log.debug("First run of TPSCountTimer Task."); - return; - } - - history.add(calculateTPS(diff, now)); - } + addNewTPSEntry(nanoTime, now); + if (history.size() >= 60) { plugin.addToProcessQueue(new TPSInsertProcessor(new ArrayList<>(history))); history.clear(); } } - /** - * Calculates the TPS - * - * @param diff The time difference between the last run and the new run - * @param now The time right now - * @return the TPS - */ - private TPS calculateTPS(long diff, long now) { - OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); - int availableProcessors = operatingSystemMXBean.getAvailableProcessors(); - double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0); - - if (averageCPUUsage < 0) { // If unavailable, getSystemLoadAverage() returns -1 - averageCPUUsage = -1; - } - - Runtime runtime = Runtime.getRuntime(); - - long totalMemory = runtime.totalMemory(); - long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000; - - int playersOnline = ((Plan) plugin).getServer().getOnlinePlayers().size(); - latestPlayersOnline = playersOnline; - int loadedChunks = getLoadedChunks(); - int entityCount; - - if (plugin.getVariable().isUsingPaper()) { - entityCount = getEntityCountPaper(); - - return getTPSPaper(now, averageCPUUsage, usedMemory, entityCount, loadedChunks, playersOnline); - } else { - entityCount = getEntityCount(); - - // 40ms removed because the run appears to take 40-50ms, screwing the tps. - long fortyMsAsNs = TimeAmount.MILLISECOND.ns() * 40L; - return getTPS(diff - fortyMsAsNs, now, averageCPUUsage, usedMemory, entityCount, loadedChunks, playersOnline); - } - } - - /** - * Gets the TPS for Spigot / Bukkit - * - * @param diff The difference between the last run and this run - * @param now The time right now - * @param cpuUsage The usage of the CPU - * @param playersOnline The amount of players that are online - * @return the TPS - */ - private TPS getTPS(long diff, long now, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded, int playersOnline) { - long difference = diff; - if (difference < TimeAmount.SECOND.ns()) { // No tick count above 20 - difference = TimeAmount.SECOND.ns(); - } - - long twentySeconds = 20L * TimeAmount.SECOND.ns(); - while (difference > twentySeconds) { - history.add(new TPS(now, 0, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded)); - difference -= twentySeconds; - } - - double tpsN = twentySeconds * 1.0 / difference; - - return new TPS(now, tpsN, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded); - } - - /** - * Gets the TPS for Paper - * - * @param now The time right now - * @param cpuUsage The usage of the CPU - * @param playersOnline The amount of players that are online - * @return the TPS - */ - private TPS getTPSPaper(long now, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded, int playersOnline) { - double tps = ((Plan) plugin).getServer().getTPS()[0]; - - if (tps > 20) { - tps = 20; - } - - tps = MathUtils.round(tps); - - return new TPS(now, tps, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded); - } - - /** - * Gets the amount of loaded chunks - * - * @return amount of loaded chunks - */ - private int getLoadedChunks() { - return ((Plan) plugin).getServer().getWorlds().stream().mapToInt(world -> world.getLoadedChunks().length).sum(); - } - - /** - * Gets the amount of entities on the server for Bukkit / Spigot - * - * @return amount of entities - */ - private int getEntityCount() { - return ((Plan) plugin).getServer().getWorlds().stream().mapToInt(world -> world.getEntities().size()).sum(); - } - - /** - * Gets the amount of entities on the server for Paper - * - * @return amount of entities - */ - private int getEntityCountPaper() { - try { - return ((Plan) plugin).getServer().getWorlds().stream().mapToInt(World::getEntityCount).sum(); - } catch (BootstrapMethodError | NoSuchMethodError e) { - return getEntityCount(); - } - } + public abstract void addNewTPSEntry(long nanoTime, long now); public int getLatestPlayersOnline() { return latestPlayersOnline; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BukkitTPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BukkitTPSCountTimer.java new file mode 100644 index 0000000000..0d745ef61c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BukkitTPSCountTimer.java @@ -0,0 +1,112 @@ +package com.djrapitops.plan.system.tasks.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.system.tasks.TPSCountTimer; +import com.djrapitops.plan.utilities.analysis.MathUtils; +import com.djrapitops.plugin.api.TimeAmount; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.lang.management.ManagementFactory; +import java.lang.management.OperatingSystemMXBean; + +public class BukkitTPSCountTimer extends TPSCountTimer { + + private long lastCheckNano; + + public BukkitTPSCountTimer(Plan plugin) { + super(plugin); + lastCheckNano = -1; + } + + @Override + public void addNewTPSEntry(long nanoTime, long now) { + long diff = nanoTime - lastCheckNano; + + lastCheckNano = nanoTime; + + if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible. + Log.debug("First run of TPSCountTimer Task."); + return; + } + + history.add(calculateTPS(diff, now)); + } + + /** + * Calculates the TPS + * + * @param diff The time difference between the last run and the new run + * @param now The time right now + * @return the TPS + */ + private TPS calculateTPS(long diff, long now) { + OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); + int availableProcessors = operatingSystemMXBean.getAvailableProcessors(); + double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0); + + if (averageCPUUsage < 0) { // If unavailable, getSystemLoadAverage() returns -1 + averageCPUUsage = -1; + } + + Runtime runtime = Runtime.getRuntime(); + + long totalMemory = runtime.totalMemory(); + long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000; + + int playersOnline = plugin.getServer().getOnlinePlayers().size(); + latestPlayersOnline = playersOnline; + int loadedChunks = getLoadedChunks(); + int entityCount; + + entityCount = getEntityCount(); + + // 40ms removed because the run appears to take 40-50ms, screwing the tps. + long fortyMsAsNs = TimeAmount.MILLISECOND.ns() * 40L; + return getTPS(diff - fortyMsAsNs, now, averageCPUUsage, usedMemory, entityCount, loadedChunks, playersOnline); + } + + /** + * Gets the TPS for Spigot / Bukkit + * + * @param diff The difference between the last run and this run + * @param now The time right now + * @param cpuUsage The usage of the CPU + * @param playersOnline The amount of players that are online + * @return the TPS + */ + protected TPS getTPS(long diff, long now, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded, int playersOnline) { + long difference = diff; + if (difference < TimeAmount.SECOND.ns()) { // No tick count above 20 + difference = TimeAmount.SECOND.ns(); + } + + long twentySeconds = 20L * TimeAmount.SECOND.ns(); + while (difference > twentySeconds) { + history.add(new TPS(now, 0, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded)); + difference -= twentySeconds; + } + + double tpsN = twentySeconds * 1.0 / difference; + + return new TPS(now, tpsN, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded); + } + + /** + * Gets the amount of loaded chunks + * + * @return amount of loaded chunks + */ + private int getLoadedChunks() { + return plugin.getServer().getWorlds().stream().mapToInt(world -> world.getLoadedChunks().length).sum(); + } + + /** + * Gets the amount of entities on the server for Bukkit / Spigot + * + * @return amount of entities + */ + protected int getEntityCount() { + return plugin.getServer().getWorlds().stream().mapToInt(world -> world.getEntities().size()).sum(); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PaperTPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PaperTPSCountTimer.java new file mode 100644 index 0000000000..6955515148 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PaperTPSCountTimer.java @@ -0,0 +1,35 @@ +package com.djrapitops.plan.system.tasks.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.utilities.analysis.MathUtils; +import org.bukkit.World; + +public class PaperTPSCountTimer extends BukkitTPSCountTimer { + + public PaperTPSCountTimer(Plan plugin) { + super(plugin); + } + + @Override + protected TPS getTPS(long diff, long now, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded, int playersOnline) { + double tps = plugin.getServer().getTPS()[0]; + + if (tps > 20) { + tps = 20; + } + + tps = MathUtils.round(tps); + + return new TPS(now, tps, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded); + } + + @Override + protected int getEntityCount() { + try { + return plugin.getServer().getWorlds().stream().mapToInt(World::getEntityCount).sum(); + } catch (BootstrapMethodError | NoSuchMethodError e) { + return super.getEntityCount(); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/BungeeTPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/BungeeTPSCountTimer.java new file mode 100644 index 0000000000..e1d4d73c33 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/BungeeTPSCountTimer.java @@ -0,0 +1,19 @@ +package com.djrapitops.plan.system.tasks.bungee; + +import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.system.tasks.TPSCountTimer; + +public class BungeeTPSCountTimer extends TPSCountTimer { + + public BungeeTPSCountTimer(PlanBungee plugin) { + super(plugin); + } + + @Override + public void addNewTPSEntry(long nanoTime, long now) { + int onlineCount = plugin.getProxy().getOnlineCount(); + history.add(new TPS(now, -1, onlineCount, -1, -1, -1, -1)); + latestPlayersOnline = onlineCount; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java index b0d9dd2ca5..23ae9617f2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.database.BukkitDBSystem; @@ -15,11 +16,11 @@ import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; -import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.system.tasks.BungeeTaskSystem; import com.djrapitops.plan.system.tasks.BukkitTaskSystem; +import com.djrapitops.plan.system.tasks.BungeeTaskSystem; import com.djrapitops.plan.system.tasks.TaskSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; +import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.lang3.ArrayUtils; @@ -28,6 +29,7 @@ * * @author Rsl1122 */ +@Deprecated public class Systems { private FileSystem fileSystem; 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 index d5260fcf9d..525bf7608b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -52,6 +52,7 @@ * * @author Rsl1122 */ +@Deprecated public class BukkitInformationManager extends InformationManager { private final Plan plugin; 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 index 58142d4117..3fa12400f9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.systems.info; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException; import com.djrapitops.plan.api.exceptions.WebAPIException; @@ -43,6 +44,7 @@ * * @author Rsl1122 */ +@Deprecated public class BungeeInformationManager extends InformationManager { private final PlanBungee plugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java deleted file mode 100644 index 0b0b19a509..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/UrlParser.java +++ /dev/null @@ -1,77 +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.parsing; - -/** - * Used for parsing URL strings. - * - * @author Rsl1122 - */ -public class UrlParser { - - private final String webServerAddress; - private StringBuilder url; - - public UrlParser(String address) { - webServerAddress = address; - url = new StringBuilder(); - } - - public UrlParser relativeProtocol() { - url.append("//"); - return this; - } - - public UrlParser httpProtocol() { - if (url.length() == 0) { - url.append("http://"); - } else { - String current = url.toString(); - url = new StringBuilder("./"); - url.append(current.substring(current.indexOf("/"))); - } - return this; - } - - public UrlParser httpsProtocol() { - if (url.length() == 0) { - url.append("https://"); - } else { - String current = url.toString(); - url = new StringBuilder("./"); - url.append(current.substring(current.indexOf("/"))); - } - return this; - } - - public UrlParser relative() { - if (url.length() == 0) { - url.append("./"); - } else { - String current = url.toString(); - url = new StringBuilder("./"); - url.append(current.substring(current.indexOf("/"))); - } - return this; - } - - public UrlParser webAddress() { - url.append(webServerAddress); - return this; - } - - public UrlParser target(String target) { - if (!target.startsWith("/") && url.charAt(url.length() - 1) != '/') { - url.append("/"); - } - url.append(target); - return this; - } - - @Override - public String toString() { - return url.toString(); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java index 990fd56343..3da833a584 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java @@ -25,6 +25,7 @@ * * @author Rsl1122 */ +@Deprecated public class BukkitServerInfoManager { private final Plan plugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index 964f2bd301..90652893c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -26,6 +26,7 @@ * * @author Rsl1122 */ +@Deprecated public class BungeeServerInfoManager { private final PlanBungee plugin; From 91e58d29e24a507d4096d76f12ecd825186e09c1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 21:20:29 +0200 Subject: [PATCH 014/166] Cleaned up task registration --- .../java/com/djrapitops/plan/PlanBungee.java | 3 +- .../djrapitops/plan/ServerVariableHolder.java | 1 + .../plan/system/tasks/BukkitTaskSystem.java | 42 +---- .../plan/system/tasks/BungeeTaskSystem.java | 22 +-- .../system/tasks/bukkit/BootAnalysisTask.java | 22 +++ .../tasks/bukkit/NetworkPageRefreshTask.java | 16 ++ .../tasks/bukkit/PeriodicAnalysisTask.java | 16 ++ .../tasks/bungee/EnableConnectionTask.java | 20 +++ .../systems/listeners/PlanChatListener.java | 61 ------- .../PlanCommandPreprocessListener.java | 77 --------- .../listeners/PlanDeathEventListener.java | 133 --------------- .../listeners/PlanGamemodeChangeListener.java | 60 ------- .../systems/listeners/PlanPlayerListener.java | 154 ------------------ .../listeners/PlanWorldChangeListener.java | 42 ----- 14 files changed, 90 insertions(+), 579 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BootAnalysisTask.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PeriodicAnalysisTask.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/EnableConnectionTask.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanDeathEventListener.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanGamemodeChangeListener.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanWorldChangeListener.java diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 130b30457e..08315d2195 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -17,6 +17,7 @@ import com.djrapitops.plan.system.processing.processors.Processor; 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; @@ -24,7 +25,6 @@ import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; @@ -148,6 +148,7 @@ public BungeeServerInfoManager getServerInfoManager() { } @Override + @Deprecated public InformationManager getInfoManager() { return infoManager; } diff --git a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java b/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java index 6dabe79955..a4e96366ea 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java +++ b/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java @@ -70,6 +70,7 @@ public String getIp() { * * @return if the server is using PaperSpigot. */ + @Deprecated public boolean isUsingPaper() { return usingPaper; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index e79576e8e4..a173aff832 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -8,16 +8,12 @@ import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.tasks.bukkit.BukkitTPSCountTimer; -import com.djrapitops.plan.system.tasks.bukkit.PaperTPSCountTimer; -import com.djrapitops.plan.systems.info.InformationManager; +import com.djrapitops.plan.system.tasks.bukkit.*; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.ITask; -import com.djrapitops.plugin.task.RunnableFactory; /** * //TODO Class Javadoc Comment @@ -39,51 +35,27 @@ public void enable() { registerTasks(); } - // TODO Clean Up private void registerTasks() { - String bootAnalysisMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_INFO).toString(); - String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString(); - Benchmark.start("Task Registration"); + tpsCountTimer = Check.isPaperAvailable() ? new PaperTPSCountTimer(plugin) : new BukkitTPSCountTimer(plugin); - registerTask(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks()); // Analysis refresh settings int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber(); boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0; long analysisPeriod = analysisRefreshMinutes * TimeAmount.MINUTE.ticks(); - Log.info(bootAnalysisMsg); - - InformationManager infoManager = plugin.getInfoManager(); + Log.info(Locale.get(Msg.ENABLE_BOOT_ANALYSIS_INFO).toString()); - bootAnalysisTask = RunnableFactory.createNew("BootAnalysisTask", new AbsRunnable() { - @Override - public void run() { - Log.info(bootAnalysisRunMsg); - infoManager.refreshAnalysis(Plan.getServerUUID()); - this.cancel(); - } - }).runTaskLaterAsynchronously(30 * TimeAmount.SECOND.ticks()); + registerTask(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks()); + registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(20L, 5L * TimeAmount.MINUTE.ticks()); + bootAnalysisTask = registerTask(new BootAnalysisTask()).runTaskLaterAsynchronously(30L * TimeAmount.SECOND.ticks()); if (analysisRefreshTaskIsEnabled) { - RunnableFactory.createNew("PeriodicalAnalysisTask", new AbsRunnable() { - @Override - public void run() { - infoManager.refreshAnalysis(Plan.getServerUUID()); - } - }).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod); + registerTask(new PeriodicAnalysisTask()).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod); } - - registerTask("PeriodicNetworkBoxRefreshTask", new AbsRunnable() { - @Override - public void run() { - infoManager.updateNetworkPageContent(); - } - }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks(), TimeAmount.MINUTE.ticks() * 5L); - Benchmark.stop("Enable", "Task Registration"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java index 9a7d868fe5..bd7fce3651 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java @@ -5,10 +5,11 @@ package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.system.tasks.bukkit.NetworkPageRefreshTask; import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer; +import com.djrapitops.plan.system.tasks.bungee.EnableConnectionTask; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plugin.api.TimeAmount; -import com.djrapitops.plugin.task.AbsRunnable; /** * //TODO Class Javadoc Comment @@ -21,6 +22,7 @@ public class BungeeTaskSystem extends TaskSystem { public BungeeTaskSystem(PlanBungee plugin) { this.plugin = plugin; + tpsCountTimer = new BungeeTPSCountTimer(plugin); } @Override @@ -31,20 +33,8 @@ public void enable() { private void registerTasks() { BungeeInformationManager infoManager = ((BungeeInformationManager) PlanBungee.getInstance().getInfoManager()); - registerTask("Enable Bukkit Connection Task", new AbsRunnable() { - @Override - public void run() { - infoManager.attemptConnection(); - infoManager.sendConfigSettings(); - } - }).runTaskAsynchronously(); - registerTask("Player Count task", new BungeeTPSCountTimer(plugin)) - .runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks()); - registerTask("NetworkPageContentUpdateTask", new AbsRunnable("NetworkPageContentUpdateTask") { - @Override - public void run() { - infoManager.updateNetworkPageContent(); - } - }).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks()); + registerTask(new EnableConnectionTask()).runTaskAsynchronously(); + registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks()); + registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks()); } } \ No newline at end of file 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 new file mode 100644 index 0000000000..2c4c14af12 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/BootAnalysisTask.java @@ -0,0 +1,22 @@ +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.plugin.api.utility.log.Log; +import com.djrapitops.plugin.task.AbsRunnable; + +public class BootAnalysisTask extends AbsRunnable { + + public BootAnalysisTask() { + super(BootAnalysisTask.class.getSimpleName()); + } + + @Override + public void run() { + String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString(); + Log.info(bootAnalysisRunMsg); + Plan.getInstance().getInfoManager().refreshAnalysis(Plan.getServerUUID()); + cancel(); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java new file mode 100644 index 0000000000..38f4c42617 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java @@ -0,0 +1,16 @@ +package com.djrapitops.plan.system.tasks.bukkit; + +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plugin.task.AbsRunnable; + +public class NetworkPageRefreshTask extends AbsRunnable { + + public NetworkPageRefreshTask() { + super(NetworkPageRefreshTask.class.getSimpleName()); + } + + @Override + public void run() { + PlanPlugin.getInstance().getInfoManager().updateNetworkPageContent(); + } +} 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 new file mode 100644 index 0000000000..79cb344fad --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/PeriodicAnalysisTask.java @@ -0,0 +1,16 @@ +package com.djrapitops.plan.system.tasks.bukkit; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plugin.task.AbsRunnable; + +public class PeriodicAnalysisTask extends AbsRunnable { + + public PeriodicAnalysisTask() { + super(PeriodicAnalysisTask.class.getSimpleName()); + } + + @Override + public void run() { + Plan.getInstance().getInfoManager().refreshAnalysis(Plan.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 new file mode 100644 index 0000000000..b6b66734f4 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bungee/EnableConnectionTask.java @@ -0,0 +1,20 @@ +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 { + + public EnableConnectionTask() { + super(EnableConnectionTask.class.getSimpleName()); + } + + @Override + public void run() { + BungeeInformationManager infoManager = (BungeeInformationManager) PlanBungee.getInstance().getInfoManager(); + infoManager.attemptConnection(); + infoManager.sendConfigSettings(); + cancel(); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java deleted file mode 100644 index d965a499f8..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.djrapitops.plan.systems.listeners; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.processing.player.NameProcessor; -import com.djrapitops.plugin.api.utility.log.Log; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; - -import java.util.UUID; - -/** - * Event Listener for AsyncPlayerChatEvents. - * - * @author Rsl1122 - */ -public class PlanChatListener implements Listener { - - private final Plan plugin; - private final DataCache dataCache; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public PlanChatListener(Plan plugin) { - this.plugin = plugin; - dataCache = plugin.getDataCache(); - } - - /** - * ChatEvent listener. - * - * @param event Fired Event - */ - @EventHandler(priority = EventPriority.MONITOR) - public void onChat(AsyncPlayerChatEvent event) { - if (event.isCancelled()) { - return; - } - - try { - Player p = event.getPlayer(); - UUID uuid = p.getUniqueId(); - String name = p.getName(); - String displayName = p.getDisplayName(); - - if (dataCache.isFirstSession(uuid)) { - dataCache.firstSessionMessageSent(uuid); - } - - plugin.addToProcessQueue(new NameProcessor(uuid, name, displayName)); - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java deleted file mode 100644 index e134d503d3..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.djrapitops.plan.systems.listeners; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.processing.CommandProcessor; -import com.djrapitops.plugin.api.utility.log.Log; -import org.bukkit.command.Command; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -/** - * Event Listener for PlayerCommandPreprocessEvents. - * - * @author Rsl1122 - */ -public class PlanCommandPreprocessListener implements Listener { - - private final Plan plugin; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public PlanCommandPreprocessListener(Plan plugin) { - this.plugin = plugin; - } - - /** - * Command use listener. - * - * @param event Fired event. - */ - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerCommand(PlayerCommandPreprocessEvent event) { - if (event.isCancelled()) { - return; - } - Player player = event.getPlayer(); - - try { - if (player.hasPermission(Permissions.IGNORE_COMMANDUSE.getPermission())) { - return; - } - - String commandName = event.getMessage().substring(1).split(" ")[0].toLowerCase(); - - boolean logUnknownCommands = Settings.LOG_UNKNOWN_COMMANDS.isTrue(); - boolean combineCommandAliases = Settings.COMBINE_COMMAND_ALIASES.isTrue(); - - if (!logUnknownCommands || combineCommandAliases) { - Command command = plugin.getServer().getPluginCommand(commandName); - if (command == null) { - try { - command = plugin.getServer().getCommandMap().getCommand(commandName); - } catch (NoSuchMethodError ignored) { - /* Ignored, Bukkit 1.8 has no such method */ - } - } - if (command == null) { - if (!logUnknownCommands) { - return; - } - } else if (combineCommandAliases) { - commandName = command.getName(); - } - } - plugin.addToProcessQueue(new CommandProcessor(commandName)); - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanDeathEventListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanDeathEventListener.java deleted file mode 100644 index 5be636f7a7..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanDeathEventListener.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.djrapitops.plan.systems.listeners; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.systems.processing.player.DeathProcessor; -import com.djrapitops.plan.systems.processing.player.KillProcessor; -import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.utilities.Format; -import org.bukkit.Material; -import org.bukkit.entity.*; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.projectiles.ProjectileSource; - -/** - * Event Listener for EntityDeathEvents. - * - * @author Rsl1122 - */ -public class PlanDeathEventListener implements Listener { - - private final Plan plugin; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public PlanDeathEventListener(Plan plugin) { - this.plugin = plugin; - } - - /** - * Command use listener. - * - * @param event Fired event. - */ - @SuppressWarnings("deprecation") - @EventHandler(priority = EventPriority.MONITOR) - public void onDeath(EntityDeathEvent event) { - long time = MiscUtils.getTime(); - LivingEntity dead = event.getEntity(); - - if (dead instanceof Player) { - plugin.addToProcessQueue(new DeathProcessor(dead.getUniqueId())); - } - - try { - EntityDamageEvent entityDamageEvent = dead.getLastDamageCause(); - if (!(entityDamageEvent instanceof EntityDamageByEntityEvent)) { - return; - } - - EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) entityDamageEvent; - Entity killerEntity = entityDamageByEntityEvent.getDamager(); - - if (killerEntity instanceof Player) { - handlePlayerKill(time, dead, (Player) killerEntity); - } else if (killerEntity instanceof Wolf) { - handleWolfKill(time, dead, (Wolf) killerEntity); - } else if (killerEntity instanceof Arrow) { - handleArrowKill(time, dead, (Arrow) killerEntity); - } - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } - - private void handlePlayerKill(long time, LivingEntity dead, Player killer) { - Material itemInHand; - try { - itemInHand = killer.getInventory().getItemInMainHand().getType(); - } catch (NoSuchMethodError e) { - try { - itemInHand = killer.getInventory().getItemInHand().getType(); // Support for non dual wielding versions. - } catch (Exception | NoSuchMethodError | NoSuchFieldError e2) { - itemInHand = Material.AIR; - } - } - - plugin.addToProcessQueue(new KillProcessor(killer.getUniqueId(), time, dead, normalizeMaterialName(itemInHand))); - } - - private void handleWolfKill(long time, LivingEntity dead, Wolf wolf) { - if (!wolf.isTamed()) { - return; - } - - AnimalTamer owner = wolf.getOwner(); - if (!(owner instanceof Player)) { - return; - } - - plugin.addToProcessQueue(new KillProcessor(owner.getUniqueId(), time, dead, "Wolf")); - } - - private void handleArrowKill(long time, LivingEntity dead, Arrow arrow) { - ProjectileSource source = arrow.getShooter(); - if (!(source instanceof Player)) { - return; - } - - Player player = (Player) source; - - plugin.addToProcessQueue(new KillProcessor(player.getUniqueId(), time, dead, "Bow")); - } - - /** - * Normalizes a material name - * - * @param material The material - * @return The normalized material name - */ - private String normalizeMaterialName(Material material) { - String[] parts = material.name().split("_"); - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < parts.length; i++) { - String part = new Format(parts[i]).capitalize().toString(); - builder.append(part); - if (i < parts.length - 1) { - builder.append(" "); - } - } - - return builder.toString(); - } -} - diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanGamemodeChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanGamemodeChangeListener.java deleted file mode 100644 index 26c94492c2..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanGamemodeChangeListener.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.djrapitops.plan.systems.listeners; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.WorldAliasSettings; -import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plugin.api.utility.log.Log; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerGameModeChangeEvent; - -import java.util.Optional; -import java.util.UUID; - -/** - * Event Listener for PlayerGameModeChangeEvents. - * - * @author Rsl1122 - */ -public class PlanGamemodeChangeListener implements Listener { - - private final Plan plugin; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public PlanGamemodeChangeListener(Plan plugin) { - this.plugin = plugin; - } - - /** - * GM Change Event Listener. - * - * @param event Fired Event. - */ - @EventHandler(priority = EventPriority.MONITOR) - public void onGamemodeChange(PlayerGameModeChangeEvent event) { - if (event.isCancelled()) { - return; - } - try { - Player p = event.getPlayer(); - UUID uuid = p.getUniqueId(); - long time = MiscUtils.getTime(); - String gameMode = event.getNewGameMode().name(); - String worldName = p.getWorld().getName(); - - new WorldAliasSettings().addWorld(worldName); - - Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); - cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time)); - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java deleted file mode 100644 index 7ddbfbab1a..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.djrapitops.plan.systems.listeners; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.processing.info.NetworkPageUpdateProcessor; -import com.djrapitops.plan.systems.processing.player.*; -import com.djrapitops.plan.systems.tasks.TaskSystem; -import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plugin.api.systems.NotificationCenter; -import com.djrapitops.plugin.api.utility.log.Log; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerKickEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.UUID; - -/** - * Event Listener for PlayerJoin, PlayerQuit and PlayerKickEvents. - * - * @author Rsl1122 - * @since 2.0.0 - */ -public class PlanPlayerListener implements Listener { - - private static boolean countKicks = true; - - private final Plan plugin; - private final DataCache cache; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public PlanPlayerListener(Plan plugin) { - this.plugin = plugin; - cache = plugin.getDataCache(); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerLogin(PlayerLoginEvent event) { - try { - PlayerLoginEvent.Result result = event.getResult(); - UUID uuid = event.getPlayer().getUniqueId(); - boolean op = event.getPlayer().isOp(); - if (result == PlayerLoginEvent.Result.KICK_BANNED) { - plugin.addToProcessQueue(new BanAndOpProcessor(uuid, true, op)); - } else { - plugin.addToProcessQueue(new BanAndOpProcessor(uuid, false, op)); - } - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } - - /** - * PlayerKickEvent Listener. - *

- * Adds processing information to the ProcessingQueue. - * After KickEvent, the QuitEvent is automatically called. - * - * @param event Fired event - */ - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerKick(PlayerKickEvent event) { - try { - if (!countKicks || event.isCancelled()) { - return; - } - UUID uuid = event.getPlayer().getUniqueId(); - plugin.addToProcessQueue(new KickProcessor(uuid)); - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } - - /** - * PlayerJoinEvent Listener. - *

- * Adds processing information to the ProcessingQueue. - * - * @param event The Fired event. - */ - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent event) { - try { - Player player = event.getPlayer(); - NotificationCenter.checkNotifications(player); - - UUID uuid = player.getUniqueId(); - long time = MiscUtils.getTime(); - - String world = player.getWorld().getName(); - String gm = player.getGameMode().name(); - - String ip = player.getAddress().getAddress().getHostAddress(); - - String playerName = player.getName(); - String displayName = player.getDisplayName(); - - int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline(); - - cache.cacheSession(uuid, Session.start(time, world, gm)); - plugin.addToProcessQueue( - new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline, - new IPUpdateProcessor(uuid, ip, time), - new NameProcessor(uuid, playerName, displayName) - ), - new NetworkPageUpdateProcessor(plugin.getInfoManager()) - ); - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } - - /** - * PlayerQuitEvent Listener. - *

- * Adds processing information to the ProcessingQueue. - * - * @param event Fired event - */ - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerQuit(PlayerQuitEvent event) { - try { - long time = MiscUtils.getTime(); - Player player = event.getPlayer(); - UUID uuid = player.getUniqueId(); - - plugin.addToProcessQueue( - new BanAndOpProcessor(uuid, player.isBanned(), player.isOp()), - new EndSessionProcessor(uuid, time), - new NetworkPageUpdateProcessor(plugin.getInfoManager()) - ); - - if (cache.isFirstSession(uuid)) { - int messagesSent = plugin.getDataCache().getFirstSessionMsgCount(uuid); - plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent)); - } - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } - - public static void setCountKicks(boolean value) { - countKicks = value; - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanWorldChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanWorldChangeListener.java deleted file mode 100644 index e23e5abaf3..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanWorldChangeListener.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.djrapitops.plan.systems.listeners; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.WorldAliasSettings; -import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plugin.api.utility.log.Log; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerChangedWorldEvent; - -import java.util.Optional; -import java.util.UUID; - -public class PlanWorldChangeListener implements Listener { - private final Plan plugin; - - public PlanWorldChangeListener(Plan plugin) { - this.plugin = plugin; - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onWorldChange(PlayerChangedWorldEvent event) { - try { - Player p = event.getPlayer(); - String worldName = p.getWorld().getName(); - - UUID uuid = p.getUniqueId(); - String gameMode = p.getGameMode().name(); - long time = MiscUtils.getTime(); - - new WorldAliasSettings().addWorld(worldName); - - Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); - cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time)); - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - } -} From 8cfaf54cb04381c3f1e5ba4ffa86662bf55b581c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 22:02:57 +0200 Subject: [PATCH 015/166] Database refactoring preparations --- .../com/djrapitops/plan/ShutdownHook.java | 2 +- .../api/exceptions/DBNoDataException.java | 16 ++++ .../database/tables => data}/Actions.java | 2 +- .../plan/data/container/Action.java | 2 +- .../plan/data/container/PlayerKill.java | 2 +- .../plan/data/container/StickyData.java | 2 +- .../system/database/databases/Database.java | 91 +++++-------------- .../databases/operation/BackupOperations.java | 11 +++ .../databases/operation/CheckOperations.java | 12 +++ .../databases/operation/FetchOperations.java | 19 ++++ .../databases/operation/RemoveOperations.java | 19 ++++ .../system/database/tables/ActionsTable.java | 1 + .../processors/NewNickActionProcessor.java | 2 +- .../player/FirstLeaveProcessor.java | 2 +- .../processors/player/RegisterProcessor.java | 2 +- .../plan/system/tasks/BukkitTaskSystem.java | 12 +-- .../plan/system/tasks/BungeeTaskSystem.java | 8 +- .../plan/system/database/DatabaseTest.java | 1 + .../system/database/tables/ActionsTest.java | 1 + 19 files changed, 118 insertions(+), 89 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBNoDataException.java rename Plan/src/main/java/com/djrapitops/plan/{system/database/tables => data}/Actions.java (94%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index f8db0687a0..f45b3f3662 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -5,10 +5,10 @@ package com.djrapitops.plan; import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plan.system.database.tables.SessionsTable; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBNoDataException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBNoDataException.java new file mode 100644 index 0000000000..6e2ae2d9a1 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBNoDataException.java @@ -0,0 +1,16 @@ +package com.djrapitops.plan.api.exceptions; + +public class DBNoDataException extends DatabaseException { + + public DBNoDataException(String message, Throwable cause) { + super(message, cause); + } + + public DBNoDataException(Throwable cause) { + super(cause); + } + + public DBNoDataException(String message) { + super(message); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Actions.java b/Plan/src/main/java/com/djrapitops/plan/data/Actions.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/Actions.java rename to Plan/src/main/java/com/djrapitops/plan/data/Actions.java index c10eadb2fe..f7784fe22f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Actions.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/Actions.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.database.tables; +package com.djrapitops.plan.data; import org.apache.commons.lang3.text.WordUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java index 3a31adfba7..2f4b16f705 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java @@ -4,8 +4,8 @@ */ package com.djrapitops.plan.data.container; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.HasDate; -import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java index 92a88f610c..1318c5b212 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.data.container; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.HasDate; -import com.djrapitops.plan.system.database.tables.Actions; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Objects; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java b/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java index 582f9b2ad6..da59fe7979 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/StickyData.java @@ -4,8 +4,8 @@ */ package com.djrapitops.plan.data.container; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plugin.api.TimeAmount; import com.google.common.base.Objects; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index db5b8aa556..38bfa691d4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -3,8 +3,9 @@ import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; +import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.tables.*; -import org.apache.commons.lang3.StringUtils; +import com.djrapitops.plan.utilities.NullCheck; import java.sql.Connection; import java.sql.SQLException; @@ -37,11 +38,10 @@ public abstract class Database { protected WorldTimesTable worldTimesTable; protected ServerTable serverTable; - - /** - * Super constructor. - */ - public Database() { + public static Database getInstance() { + Database database = DBSystem.getInstance().getActiveDatabase(); + NullCheck.check(database, new IllegalStateException("Database was not initialized.")); + return database; } /** @@ -77,7 +77,7 @@ public void init() throws DatabaseInitException { * @return sqlite/mysql */ public String getConfigName() { - return StringUtils.remove(getName().toLowerCase(), ' '); + return getName().toLowerCase().trim(); } public abstract boolean isNewDatabase() throws SQLException; @@ -123,6 +123,7 @@ public String getConfigName() { * @param uuid UUID of the account. * @throws SQLException If a database error occurs. */ + @Deprecated public abstract void removeAccount(UUID uuid) throws SQLException; /** @@ -132,6 +133,7 @@ public String getConfigName() { * * @throws SQLException if remove fails. */ + @Deprecated public abstract void removeAllData() throws SQLException; /** @@ -140,6 +142,7 @@ public String getConfigName() { * @return Set of saved UUIDs * @throws SQLException If a database error occurs. */ + @Deprecated public Set getSavedUUIDs() throws SQLException { return usersTable.getSavedUUIDs(); } @@ -150,96 +153,60 @@ public Set getSavedUUIDs() throws SQLException { * @return String command (key), Integer times used * @throws SQLException If a database error occurs. */ + @Deprecated public Map getCommandUse() throws SQLException { return commandUseTable.getCommandUse(); } - /** - * Used to get the users table. - * - * @return Table representing plan_users - */ + + public abstract void commit(Connection connection) throws SQLException; + + public boolean isUsingMySQL() { + return "mysql".equals(getConfigName()); + } + + @Deprecated + public abstract PlayerProfile getPlayerProfile(UUID uuid) throws SQLException; + + @Deprecated + public abstract ServerProfile getServerProfile(UUID serverUUID) throws SQLException; + public UsersTable getUsersTable() { return usersTable; } - /** - * Used to get the users table. - * - * @return Table representing plan_sessions - */ public SessionsTable getSessionsTable() { return sessionsTable; } - /** - * Used to get the kills table. - * - * @return Table representing plan_kills - */ public KillsTable getKillsTable() { return killsTable; } - /** - * Used to get the ips table. - * - * @return Table representing plan_ips - */ public IPsTable getIpsTable() { return ipsTable; } - /** - * Used to get the nicknames table. - * - * @return Table representing plan_nicknames - */ public NicknamesTable getNicknamesTable() { return nicknamesTable; } - /** - * Used to get the command usage table. - * - * @return Table representing plan_commandusages - */ public CommandUseTable getCommandUseTable() { return commandUseTable; } - /** - * Used to get the tps table. - * - * @return Table representing plan_tps - */ public TPSTable getTpsTable() { return tpsTable; } - /** - * Used to get the security table. - * - * @return Table representing plan_security - */ public SecurityTable getSecurityTable() { return securityTable; } - /** - * Used to get the worlds table. - * - * @return Table representing plan_worlds - */ public WorldTable getWorldTable() { return worldTable; } - /** - * Used to get the world times table. - * - * @return Table representing plan_world_times - */ public WorldTimesTable getWorldTimesTable() { return worldTimesTable; } @@ -255,14 +222,4 @@ public ActionsTable getActionsTable() { public UserInfoTable getUserInfoTable() { return userInfoTable; } - - public abstract void commit(Connection connection) throws SQLException; - - public boolean isUsingMySQL() { - return "mysql".equals(getConfigName()); - } - - public abstract PlayerProfile getPlayerProfile(UUID uuid) throws SQLException; - - public abstract ServerProfile getServerProfile(UUID serverUUID) throws SQLException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java new file mode 100644 index 0000000000..1f3b10615c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java @@ -0,0 +1,11 @@ +package com.djrapitops.plan.system.database.databases.operation; + +import com.djrapitops.plan.system.database.databases.Database; + +public interface BackupOperations { + + void backup(Database toDatabase); + + void restore(Database fromDatabase); + +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java new file mode 100644 index 0000000000..bc37f7c469 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java @@ -0,0 +1,12 @@ +package com.djrapitops.plan.system.database.databases.operation; + +import java.util.UUID; + +public interface CheckOperations { + + boolean wasSeenBefore(UUID player); + + boolean wasSeenBefore(UUID player, UUID server); + + +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java new file mode 100644 index 0000000000..8d44728a5a --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -0,0 +1,19 @@ +package com.djrapitops.plan.system.database.databases.operation; + +import com.djrapitops.plan.data.PlayerProfile; +import com.djrapitops.plan.data.ServerProfile; + +import java.sql.SQLException; +import java.util.Set; +import java.util.UUID; + +public interface FetchOperations { + + ServerProfile getServerProfile(UUID serverUUID) throws SQLException; + + PlayerProfile getPlayerProfile(UUID uuid) throws SQLException; + + Set getSavedUUIDs() throws SQLException; + + Set getSavedUUIDs(UUID server) throws SQLException; +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java new file mode 100644 index 0000000000..3355faf969 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java @@ -0,0 +1,19 @@ +package com.djrapitops.plan.system.database.databases.operation; + +import com.djrapitops.plan.api.exceptions.DBNoDataException; + +import java.sql.SQLException; +import java.util.UUID; + +public interface RemoveOperations { + + void removePlayer(UUID uuid) throws SQLException, DBNoDataException; + + void removePlayer(UUID player, UUID server) throws SQLException, DBNoDataException; + + void removeServer(UUID serverUUID) throws SQLException, DBNoDataException; + + void removeAll() throws SQLException, DBNoDataException; + + void removeWebUser(String name) throws SQLException, DBNoDataException; +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java index 189407cc84..4f752ad585 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.database.databases.SQLDB; import com.djrapitops.plan.system.database.processing.ExecStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java index 8229f432bb..ca81b41dde 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.system.processing.processors; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.html.HtmlUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java index 90290109d8..aff15ce6c3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index 3ac0b095f5..b4ddc83c0e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java @@ -5,9 +5,9 @@ package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.tables.Actions; import com.djrapitops.plan.system.database.tables.UserInfoTable; import com.djrapitops.plan.system.database.tables.UsersTable; import com.djrapitops.plan.system.processing.processors.Processor; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index a173aff832..b784b76972 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -16,16 +16,17 @@ import com.djrapitops.plugin.task.ITask; /** - * //TODO Class Javadoc Comment + * TaskSystem responsible for registering tasks for Bukkit. * * @author Rsl1122 */ public class BukkitTaskSystem extends TaskSystem { - private final Plan plugin; - public BukkitTaskSystem(Plan plugin) { - this.plugin = plugin; + tpsCountTimer = Check.isPaperAvailable() + ? new PaperTPSCountTimer(plugin) + : new BukkitTPSCountTimer(plugin); + } private ITask bootAnalysisTask; @@ -38,9 +39,6 @@ public void enable() { private void registerTasks() { Benchmark.start("Task Registration"); - tpsCountTimer = Check.isPaperAvailable() - ? new PaperTPSCountTimer(plugin) - : new BukkitTPSCountTimer(plugin); // Analysis refresh settings int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java index bd7fce3651..9140ea0964 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java @@ -8,20 +8,16 @@ import com.djrapitops.plan.system.tasks.bukkit.NetworkPageRefreshTask; import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer; import com.djrapitops.plan.system.tasks.bungee.EnableConnectionTask; -import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plugin.api.TimeAmount; /** - * //TODO Class Javadoc Comment + * TaskSystem responsible for registering tasks for Bungee. * * @author Rsl1122 */ public class BungeeTaskSystem extends TaskSystem { - private final PlanBungee plugin; - public BungeeTaskSystem(PlanBungee plugin) { - this.plugin = plugin; tpsCountTimer = new BungeeTPSCountTimer(plugin); } @@ -31,8 +27,6 @@ public void enable() { } private void registerTasks() { - BungeeInformationManager infoManager = ((BungeeInformationManager) PlanBungee.getInstance().getInfoManager()); - registerTask(new EnableConnectionTask()).runTaskAsynchronously(); registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks()); registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks()); diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index 6eaf5e7eb7..6e24bc68ab 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.data.time.GMTimes; diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java index 10018c9af8..eed5686fae 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java @@ -1,5 +1,6 @@ package com.djrapitops.plan.system.database.tables; +import com.djrapitops.plan.data.Actions; import org.junit.Test; import static org.junit.Assert.assertEquals; From 65b45ce92c0b9eaf54cc0f584f6a16af91764fff Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 14 Jan 2018 15:33:00 +0200 Subject: [PATCH 016/166] Progress on database refactoring --- .../com/djrapitops/plan/ShutdownHook.java | 8 +- .../java/com/djrapitops/plan/api/API.java | 13 +- .../java/com/djrapitops/plan/api/PlanAPI.java | 8 + .../DBCreateTableException.java | 4 +- .../DBException.java} | 10 +- .../DBInitException.java} | 10 +- .../{ => database}/DBNoDataException.java | 4 +- .../exceptions/database/FatalDBException.java | 16 ++ .../WebAPIConnectionFailException.java | 2 +- .../{ => webapi}/WebAPIException.java | 2 +- .../{ => webapi}/WebAPIFailException.java | 2 +- .../WebAPIForbiddenException.java | 2 +- .../WebAPIInternalErrorException.java | 2 +- .../{ => webapi}/WebAPINotFoundException.java | 2 +- .../plan/command/ConditionUtils.java | 26 -- .../plan/command/commands/DevCommand.java | 2 +- .../plan/command/commands/InspectCommand.java | 24 +- .../command/commands/QInspectCommand.java | 10 +- .../command/commands/RegisterCommand.java | 2 +- .../commands/manage/ManageBackupCommand.java | 4 +- .../commands/manage/ManageClearCommand.java | 11 +- .../commands/manage/ManageHotswapCommand.java | 1 - .../commands/manage/ManageRemoveCommand.java | 31 +-- .../commands/manage/ManageRestoreCommand.java | 2 +- .../commands/manage/ManageSetupCommand.java | 4 +- .../commands/webuser/WebCheckCommand.java | 2 +- .../commands/webuser/WebDeleteCommand.java | 2 +- .../plan/system/database/BukkitDBSystem.java | 8 +- .../plan/system/database/BungeeDBSystem.java | 6 +- .../plan/system/database/DBSystem.java | 14 +- .../system/database/databases/Database.java | 198 ++------------ .../databases/operation/BackupOperations.java | 7 +- .../databases/operation/CheckOperations.java | 9 +- .../databases/operation/FetchOperations.java | 13 +- .../databases/operation/RemoveOperations.java | 13 +- .../database/databases/sql/ErrorUtil.java | 33 +++ .../database/databases/{ => sql}/MySQLDB.java | 2 +- .../database/databases/sql/SQLBackupOps.java | 21 ++ .../database/databases/sql/SQLCheckOps.java | 43 +++ .../database/databases/{ => sql}/SQLDB.java | 250 ++++++++++-------- .../database/databases/sql/SQLFetchOps.java | 100 +++++++ .../system/database/databases/sql/SQLOps.java | 40 +++ .../database/databases/sql/SQLRemoveOps.java | 74 ++++++ .../databases/{ => sql}/SQLiteDB.java | 11 +- .../sql}/processing/ExecStatement.java | 9 +- .../sql}/processing/QueryAllStatement.java | 2 +- .../sql}/processing/QueryStatement.java | 9 +- .../databases/sql/statements/Insert.java | 30 +++ .../databases/sql/statements/Select.java | 26 ++ .../databases/sql/statements/Sql.java | 16 ++ .../databases/sql/statements/SqlParser.java | 35 +++ .../sql/statements/TableSqlParser.java | 118 +++++++++ .../databases/sql/statements/Update.java | 30 +++ .../databases/sql/statements/WhereParser.java | 48 ++++ .../sql}/tables/ActionsTable.java | 22 +- .../sql}/tables/CommandUseTable.java | 22 +- .../{ => databases/sql}/tables/IPsTable.java | 26 +- .../sql}/tables/KillsTable.java | 20 +- .../sql}/tables/NicknamesTable.java | 24 +- .../sql}/tables/SecurityTable.java | 24 +- .../sql}/tables/ServerTable.java | 20 +- .../sql}/tables/SessionsTable.java | 22 +- .../{ => databases/sql}/tables/TPSTable.java | 23 +- .../{ => databases/sql}/tables/Table.java | 17 +- .../sql}/tables/UserIDTable.java | 10 +- .../sql}/tables/UserInfoTable.java | 30 ++- .../sql}/tables/UsersTable.java | 18 +- .../sql}/tables/VersionTable.java | 20 +- .../sql}/tables/WorldTable.java | 29 +- .../sql}/tables/WorldTimesTable.java | 26 +- .../sql}/tables/move/BatchOperationTable.java | 26 +- .../tables/move/Version8TransferTable.java | 8 +- .../importing/importers/Importer.java | 20 +- .../player/BungeePlayerRegisterProcessor.java | 2 +- .../processors/player/NameProcessor.java | 2 +- .../processors/player/RegisterProcessor.java | 4 +- .../webserver/pages/PlayerPageHandler.java | 3 +- .../plan/system/webserver/webapi/WebAPI.java | 2 +- .../webapi/bukkit/AnalysisReadyWebAPI.java | 2 +- .../webapi/bukkit/AnalyzeWebAPI.java | 2 +- .../webapi/bukkit/ConfigurationWebAPI.java | 2 +- .../webapi/bukkit/InspectWebAPI.java | 2 +- .../webapi/bukkit/IsOnlineWebAPI.java | 2 +- .../RequestInspectPluginsTabBukkitWebAPI.java | 2 +- .../webapi/bungee/IsCachedWebAPI.java | 4 +- .../webapi/bungee/PostHtmlWebAPI.java | 2 +- .../bungee/PostInspectPluginsTabWebAPI.java | 2 +- .../bungee/PostNetworkPageContentWebAPI.java | 2 +- .../PostOriginalBukkitSettingsWebAPI.java | 2 +- .../bungee/RequestPluginsTabWebAPI.java | 2 +- .../webapi/bungee/RequestSetupWebAPI.java | 2 +- .../webapi/universal/PingWebAPI.java | 2 +- .../info/BukkitInformationManager.java | 6 +- .../info/BungeeInformationManager.java | 8 +- .../info/parsing/InspectPageParser.java | 6 +- .../info/server/BukkitServerInfoManager.java | 2 +- .../info/server/BungeeServerInfoManager.java | 4 +- .../plan/utilities/ManageUtils.java | 24 +- .../plan/system/database/DatabaseTest.java | 71 ++--- .../sql}/tables/ActionsTest.java | 2 +- .../plan/utilities/MiscUtilsTest.java | 6 +- 101 files changed, 1228 insertions(+), 722 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => database}/DBCreateTableException.java (81%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{DatabaseException.java => database/DBException.java} (59%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{DatabaseInitException.java => database/DBInitException.java} (56%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => database}/DBNoDataException.java (71%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/FatalDBException.java rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => webapi}/WebAPIConnectionFailException.java (91%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => webapi}/WebAPIException.java (92%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => webapi}/WebAPIFailException.java (92%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => webapi}/WebAPIForbiddenException.java (88%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => webapi}/WebAPIInternalErrorException.java (90%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{ => webapi}/WebAPINotFoundException.java (89%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/ErrorUtil.java rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/{ => sql}/MySQLDB.java (96%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLBackupOps.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLCheckOps.java rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/{ => sql}/SQLDB.java (71%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLFetchOps.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLOps.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLRemoveOps.java rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/{ => sql}/SQLiteDB.java (93%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/processing/ExecStatement.java (79%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/processing/QueryAllStatement.java (91%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/processing/QueryStatement.java (81%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Insert.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Select.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Sql.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/SqlParser.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/TableSqlParser.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Update.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/WhereParser.java rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/ActionsTable.java (92%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/CommandUseTable.java (91%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/IPsTable.java (90%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/KillsTable.java (94%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/NicknamesTable.java (92%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/SecurityTable.java (84%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/ServerTable.java (96%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/SessionsTable.java (97%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/TPSTable.java (93%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/Table.java (92%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/UserIDTable.java (74%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/UserInfoTable.java (93%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/UsersTable.java (96%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/VersionTable.java (75%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/WorldTable.java (86%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/WorldTimesTable.java (95%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/move/BatchOperationTable.java (88%) rename Plan/src/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/move/Version8TransferTable.java (95%) rename Plan/test/main/java/com/djrapitops/plan/system/database/{ => databases/sql}/tables/ActionsTest.java (82%) diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index f45b3f3662..e6d7b227e9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -4,12 +4,12 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.tables.SessionsTable; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.tables.SessionsTable; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.MiscUtils; @@ -58,7 +58,7 @@ public void run() { saveFirstSessionInformation(now); saveActiveSessions(activeSessions, now); - } catch (DatabaseInitException e) { + } catch (DBInitException e) { Log.toLog(this.getClass().getName(), e); } finally { if (db != null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/api/API.java b/Plan/src/main/java/com/djrapitops/plan/api/API.java index 87c056a39e..82bb40bcf8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/API.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/API.java @@ -2,8 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.api.exceptions.database.DBException; 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.systems.info.BukkitInformationManager; import com.djrapitops.plan.utilities.uuid.UUIDUtility; import com.djrapitops.plugin.utilities.Verify; @@ -11,6 +13,7 @@ import java.sql.SQLException; import java.util.Collection; +import java.util.Collections; import java.util.UUID; import static org.bukkit.Bukkit.getOfflinePlayer; @@ -198,7 +201,7 @@ public AnalysisData getAnalysisDataFromCache() { * @throws IllegalArgumentException If uuid is null. * @throws IllegalStateException If the player has not played on the server before. */ - public String getPlayerName(UUID uuid) throws SQLException { + public String getPlayerName(UUID uuid) { Verify.nullCheck(uuid); String playerName = plugin.getDB().getUsersTable().getPlayerName(uuid); if (playerName != null) { @@ -248,7 +251,11 @@ public UUID playerNameToUUID(String playerName) { * @throws SQLException If database error occurs. * @since 3.4.2 */ - public Collection getSavedUUIDs() throws SQLException { - return plugin.getDB().getSavedUUIDs(); + public Collection getSavedUUIDs() { + try { + return Database.getActive().fetch().getSavedUUIDs(); + } catch (DBException e) { + return Collections.EMPTY_SET; + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java index e6c36f03a3..554e0f1f32 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java @@ -5,6 +5,10 @@ package com.djrapitops.plan.api; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.database.databases.operation.FetchOperations; + +import java.util.Map; +import java.util.UUID; /** * //TODO Class Javadoc Comment @@ -18,4 +22,8 @@ static PlanAPI getInstance() { } void registerPluginData(PluginData pluginData); + + Map getKnownUsernames(); + + FetchOperations fetchFromPlanDB(); } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBCreateTableException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBCreateTableException.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBCreateTableException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBCreateTableException.java index 0b8085feb8..4ca76fe6aa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBCreateTableException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBCreateTableException.java @@ -2,14 +2,14 @@ * 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.exceptions; +package com.djrapitops.plan.api.exceptions.database; /** * Thrown when something goes wrong with creating tables with {@code Table#createTable}. * * @author Rsl1122 */ -public class DBCreateTableException extends DatabaseInitException { +public class DBCreateTableException extends DBInitException { public DBCreateTableException(String tableName, String message, Throwable cause) { super(tableName + ": " + message, cause); diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBException.java similarity index 59% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBException.java index a754b0d718..d275f598be 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBException.java @@ -2,24 +2,24 @@ * 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.exceptions; +package com.djrapitops.plan.api.exceptions.database; /** * Thrown when something goes wrong with the Database, generic exception. * * @author Rsl1122 */ -public class DatabaseException extends Exception { +public class DBException extends Exception { - public DatabaseException(String message, Throwable cause) { + public DBException(String message, Throwable cause) { super(message, cause); } - public DatabaseException(Throwable cause) { + public DBException(Throwable cause) { super(cause); } - public DatabaseException(String message) { + public DBException(String message) { super(message); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseInitException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBInitException.java similarity index 56% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseInitException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBInitException.java index 042e1657e6..a70acf1b5d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DatabaseInitException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBInitException.java @@ -2,24 +2,24 @@ * 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.exceptions; +package com.djrapitops.plan.api.exceptions.database; /** * Thrown when something goes wrong with {@code Database#init}. * * @author Rsl1122 */ -public class DatabaseInitException extends DatabaseException { +public class DBInitException extends FatalDBException { - public DatabaseInitException(String message, Throwable cause) { + public DBInitException(String message, Throwable cause) { super(message, cause); } - public DatabaseInitException(Throwable cause) { + public DBInitException(Throwable cause) { super(cause); } - public DatabaseInitException(String message) { + public DBInitException(String message) { super(message); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBNoDataException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBNoDataException.java similarity index 71% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBNoDataException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBNoDataException.java index 6e2ae2d9a1..71effcbe45 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/DBNoDataException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBNoDataException.java @@ -1,6 +1,6 @@ -package com.djrapitops.plan.api.exceptions; +package com.djrapitops.plan.api.exceptions.database; -public class DBNoDataException extends DatabaseException { +public class DBNoDataException extends DBException { public DBNoDataException(String message, Throwable cause) { super(message, cause); diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/FatalDBException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/FatalDBException.java new file mode 100644 index 0000000000..c0ec4bcd05 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/FatalDBException.java @@ -0,0 +1,16 @@ +package com.djrapitops.plan.api.exceptions.database; + +public class FatalDBException extends DBException { + + public FatalDBException(String message, Throwable cause) { + super(message, cause); + } + + public FatalDBException(Throwable cause) { + super(cause); + } + + public FatalDBException(String message) { + super(message); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIConnectionFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIConnectionFailException.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIConnectionFailException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIConnectionFailException.java index 13bbb40969..a7a675d3c1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIConnectionFailException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIConnectionFailException.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.api.exceptions; +package com.djrapitops.plan.api.exceptions.webapi; /** * Thrown when WebAPI fails to connect to an address. diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIException.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIException.java index b084f0a620..175b15d410 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIException.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.api.exceptions; +package com.djrapitops.plan.api.exceptions.webapi; /** * Thrown when WebAPI POST-request fails, general Exception. diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIFailException.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIFailException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIFailException.java index c575b88104..acc8fd4281 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIFailException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIFailException.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.api.exceptions; +package com.djrapitops.plan.api.exceptions.webapi; /** * Group of WebAPIExceptions that can be considered a failed connection state on some occasions. diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIForbiddenException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIForbiddenException.java similarity index 88% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIForbiddenException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIForbiddenException.java index 51ca8b31ea..4dc6c0b48a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIForbiddenException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIForbiddenException.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.api.exceptions; +package com.djrapitops.plan.api.exceptions.webapi; /** * Thrown when WebAPI gets a 403 response. diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIInternalErrorException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIInternalErrorException.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIInternalErrorException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIInternalErrorException.java index ba5825c82f..144240a73c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPIInternalErrorException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIInternalErrorException.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.api.exceptions; +package com.djrapitops.plan.api.exceptions.webapi; /** * Thrown when WebAPI returns 404, usually when response is supposed to be false. diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPINotFoundException.java similarity index 89% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPINotFoundException.java index e0adfa710d..762f264f79 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebAPINotFoundException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPINotFoundException.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.api.exceptions; +package com.djrapitops.plan.api.exceptions.webapi; /** * Thrown when WebAPI returns 404, usually when response is supposed to be false. diff --git a/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java b/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java index 2cc744783d..e4ddc38f18 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/ConditionUtils.java @@ -1,12 +1,5 @@ package com.djrapitops.plan.command; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plugin.api.Check; -import com.djrapitops.plugin.utilities.Verify; - -import java.util.UUID; - /** * This class contains methods used by commands * @@ -21,23 +14,4 @@ public class ConditionUtils { private ConditionUtils() { throw new IllegalStateException("Utility class"); } - - /** - * Condition if the player has played. - * - * @param uuid UUID of player - * @return has the player played before, false if uuid is null. - */ - public static boolean playerHasPlayed(UUID uuid) { - if (Verify.containsNull(uuid)) { - return false; - } - boolean hasPlayed; - if (Check.isBukkitAvailable()) { - hasPlayed = Plan.getInstance().getServer().getOfflinePlayer(uuid).hasPlayedBefore(); - } else { - hasPlayed = PlanBungee.getInstance().getDB().wasSeenBefore(uuid); - } - return hasPlayed; - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index e0673b018a..9e094e45b9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.webserver.webapi.WebAPI; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 0cba2c0c7f..8822ee8e46 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -1,9 +1,11 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.command.ConditionUtils; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.FatalDBException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.processors.info.InspectCacheRequestProcessor; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; @@ -19,7 +21,6 @@ import com.djrapitops.plugin.utilities.Verify; import org.bukkit.ChatColor; -import java.sql.SQLException; import java.util.UUID; /** @@ -66,26 +67,29 @@ private void runInspectTask(String playerName, ISender sender) { @Override public void run() { try { + Database activeDB = Database.getActive(); UUID uuid = UUIDUtility.getUUIDOf(playerName); if (!Condition.isTrue(Verify.notNull(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString(), sender)) { return; } - if (!Condition.isTrue(ConditionUtils.playerHasPlayed(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_SEEN).toString(), sender)) { - return; - } - if (!Condition.isTrue(plugin.getDB().wasSeenBefore(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) { + if (!Condition.isTrue(activeDB.check().isPlayerRegistered(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) { return; } if (CommandUtils.isPlayer(sender) && plugin.getWebServer().isAuthRequired()) { - boolean senderHasWebUser = plugin.getDB().getSecurityTable().userExists(sender.getName()); + boolean senderHasWebUser = activeDB.check().doesWebUserExists(sender.getName()); + if (!senderHasWebUser) { sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); } } - plugin.addToProcessQueue(new InspectCacheRequestProcessor(uuid, sender, playerName)); - } catch (SQLException ex) { - Log.toLog(this.getClass().getName(), ex); + } catch (DBException ex) { + if (ex instanceof FatalDBException) { + Log.toLog(this.getClass().getName(), ex); + sender.sendMessage(ChatColor.RED + "Fatal database exception occurred: " + ex.getMessage()); + } else { + sender.sendMessage(ChatColor.YELLOW + "Non-Fatal database exception occurred: " + ex.getMessage()); + } } finally { this.cancel(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java index ed249757ed..ad4a8ca521 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java @@ -1,10 +1,12 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.FormatUtils; @@ -20,7 +22,6 @@ import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.utilities.Verify; -import java.sql.SQLException; import java.util.UUID; /** @@ -71,15 +72,16 @@ public void run() { if (!Condition.isTrue(Verify.notNull(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString(), sender)) { return; } - if (!Condition.isTrue(plugin.getDB().wasSeenBefore(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) { + Database database = Database.getActive(); + if (!Condition.isTrue(database.check().isPlayerRegistered(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) { return; } - PlayerProfile playerProfile = plugin.getDB().getPlayerProfile(uuid); + PlayerProfile playerProfile = database.fetch().getPlayerProfile(uuid); sendMsgs(sender, playerProfile); - } catch (SQLException ex) { + } catch (DBException ex) { Log.toLog(this.getClass().getName(), ex); } finally { this.cancel(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index 08f54df604..d0e5ed92a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -4,7 +4,7 @@ import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.system.database.tables.SecurityTable; +import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.PassEncryptUtil; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java index bbbbca7501..0463ca3eaf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; @@ -63,7 +63,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { } Log.debug("Backup", "Start"); runBackupTask(sender, args, database); - } catch (DatabaseInitException | NullPointerException e) { + } catch (DBInitException | NullPointerException e) { sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); } finally { Log.logDebug("Backup"); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index 18162f16c5..dcefe343a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -1,7 +1,8 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; @@ -20,8 +21,6 @@ import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.utilities.Verify; -import java.sql.SQLException; - /** * This manage subcommand is used to clear a database of all data. * @@ -73,7 +72,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { try { Database database = ManageUtils.getDB(dbName); runClearTask(sender, database); - } catch (DatabaseInitException e) { + } catch (DBInitException e) { sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); } return true; @@ -86,7 +85,7 @@ public void run() { try { sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse()); - database.removeAllData(); + database.remove().everything(); DataCache dataCache = plugin.getDataCache(); long now = MiscUtils.getTime(); @@ -96,7 +95,7 @@ public void run() { new Session(now, player.getWorld().getName(), player.getGameMode().name())) ); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString()); - } catch (SQLException e) { + } catch (DBException e) { sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); Log.toLog(this.getClass().getSimpleName() + "/" + this.getTaskName(), e); } finally { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index 4a5112cb9a..d19c5a4f19 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -76,7 +76,6 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { assert database != null; - database.getVersion(); //Test db connection } catch (Exception e) { Log.toLog(this.getClass().getName(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 3738efed88..d034451b7f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -1,9 +1,11 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; @@ -19,7 +21,6 @@ import com.djrapitops.plugin.utilities.Verify; import org.bukkit.entity.Player; -import java.sql.SQLException; import java.util.UUID; import static org.bukkit.Bukkit.getPlayer; @@ -80,7 +81,8 @@ public void run() { } message = Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(); - if (!Condition.isTrue(plugin.getDB().wasSeenBefore(uuid), message, sender)) { + Database database = Database.getActive(); + if (!Condition.isTrue(database.check().isPlayerRegistered(uuid), message, sender)) { return; } @@ -90,20 +92,19 @@ public void run() { } sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse()); - try { - plugin.getDB().removeAccount(uuid); - - DataCache dataCache = plugin.getDataCache(); - Player player = getPlayer(uuid); - if (player != null) { - SessionCache.getActiveSessions().remove(uuid); - dataCache.cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name())); - } - sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName())); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); + + database.remove().player(uuid); + + DataCache dataCache = plugin.getDataCache(); + Player player = getPlayer(uuid); + if (player != null) { + SessionCache.getActiveSessions().remove(uuid); + dataCache.cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name())); } + sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName())); + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); } finally { this.cancel(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index 4f3bab355e..2f0ea5e35b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -4,7 +4,7 @@ import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.SQLiteDB; +import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 5f3b0bcff2..2dea249108 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.api.exceptions.WebAPIForbiddenException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIForbiddenException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java index 18dcb5f9c1..387bcb7c31 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java @@ -4,7 +4,7 @@ import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.system.database.tables.SecurityTable; +import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java index b1190782ed..3029b142a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java @@ -3,7 +3,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.system.database.tables.SecurityTable; +import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java index c22470f2cd..d092cafcea 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java @@ -4,9 +4,9 @@ */ package com.djrapitops.plan.system.database; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.system.database.databases.MySQLDB; -import com.djrapitops.plan.system.database.databases.SQLiteDB; +import com.djrapitops.plan.api.exceptions.database.DBInitException; +import com.djrapitops.plan.system.database.databases.sql.MySQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.settings.Settings; /** @@ -17,7 +17,7 @@ public class BukkitDBSystem extends DBSystem { @Override - protected void initDatabase() throws DatabaseInitException { + protected void initDatabase() throws DBInitException { databases.add(new MySQLDB()); databases.add(new SQLiteDB()); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java index 8c216fbd32..0e205fab81 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java @@ -4,8 +4,8 @@ */ package com.djrapitops.plan.system.database; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.system.database.databases.MySQLDB; +import com.djrapitops.plan.api.exceptions.database.DBInitException; +import com.djrapitops.plan.system.database.databases.sql.MySQLDB; /** * //TODO Class Javadoc Comment @@ -15,7 +15,7 @@ public class BungeeDBSystem extends DBSystem { @Override - protected void initDatabase() throws DatabaseInitException { + protected void initDatabase() throws DBInitException { db = new MySQLDB(); databases.add(db); db.init(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index 32f5f5d901..387a446e37 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -4,14 +4,14 @@ */ package com.djrapitops.plan.system.database; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; 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.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; @@ -50,12 +50,12 @@ public void enable() throws EnableException { db.scheduleClean(10L); Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName())); Benchmark.stop("Systems", "Init Database"); - } catch (DatabaseInitException e) { + } catch (DBInitException e) { throw new EnableException(db.getName() + "-Database failed to initialize", e); } } - protected abstract void initDatabase() throws DatabaseInitException; + protected abstract void initDatabase() throws DBInitException; public Set getDatabases() { return databases; @@ -80,14 +80,14 @@ public Database getActiveDatabase() { return db; } - public SQLDB getActiveDatabase(String dbName) throws DatabaseInitException { - for (SQLDB database : DBSystem.getInstance().getDatabases()) { + public SQLDB getActiveDatabase(String dbName) throws DBInitException { + for (SQLDB database : getDatabases()) { String dbConfigName = database.getConfigName(); if (Verify.equalsIgnoreCase(dbName, dbConfigName)) { database.init(); return database; } } - throw new DatabaseInitException(Locale.get(Msg.ENABLE_FAIL_WRONG_DB) + " " + dbName); + throw new DBInitException(Locale.get(Msg.ENABLE_FAIL_WRONG_DB) + " " + dbName); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index 38bfa691d4..aa861498d1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -1,18 +1,14 @@ package com.djrapitops.plan.system.database.databases; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; -import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.data.ServerProfile; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.plan.system.database.tables.*; +import com.djrapitops.plan.system.database.databases.operation.BackupOperations; +import com.djrapitops.plan.system.database.databases.operation.CheckOperations; +import com.djrapitops.plan.system.database.databases.operation.FetchOperations; +import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; import com.djrapitops.plan.utilities.NullCheck; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - /** * Abstract class representing a Database. *

@@ -23,42 +19,23 @@ */ public abstract class Database { - protected UsersTable usersTable; - protected UserInfoTable userInfoTable; - protected ActionsTable actionsTable; - protected KillsTable killsTable; - protected NicknamesTable nicknamesTable; - protected SessionsTable sessionsTable; - protected IPsTable ipsTable; - protected CommandUseTable commandUseTable; - protected TPSTable tpsTable; - protected VersionTable versionTable; - protected SecurityTable securityTable; - protected WorldTable worldTable; - protected WorldTimesTable worldTimesTable; - protected ServerTable serverTable; + private boolean open; - public static Database getInstance() { + public static Database getActive() { Database database = DBSystem.getInstance().getActiveDatabase(); NullCheck.check(database, new IllegalStateException("Database was not initialized.")); return database; } - /** - * Initiates the database. - * - * @throws DatabaseInitException if SQLException or other exception occurs. - */ - public void init() throws DatabaseInitException { - } + public abstract void init() throws DBInitException; - /** - * Condition if the user is saved in the database. - * - * @param uuid UUID of the user. - * @return true/false - */ - public abstract boolean wasSeenBefore(UUID uuid); + public abstract BackupOperations backup(); + + public abstract CheckOperations check(); + + public abstract FetchOperations fetch(); + + public abstract RemoveOperations remove(); /** * Used to get the name of the database type. @@ -80,146 +57,9 @@ public String getConfigName() { return getName().toLowerCase().trim(); } - public abstract boolean isNewDatabase() throws SQLException; - - /** - * Used to get the database schema version. - * - * @return Integer starting from 0, incremented by one when schema is - * updated. - * @throws SQLException If a database error occurs. - */ - public abstract int getVersion() throws SQLException; - - /** - * Used to set the database schema version. - * - * @param version Integer starting from 0, incremented by one when schema is - * updated. - * @throws SQLException If a database error occurs. - */ - public abstract void setVersion(int version) throws SQLException; - - /** - * Closes the database and it's resources. - * - * @throws SQLException If a database error occurs. - */ - public abstract void close() throws SQLException; - - /** - * Returns a connection to the MySQL connection pool. - *

- * On SQLite does nothing. - * - * @param connection Connection to return. - * @throws SQLException DB Error - */ - public abstract void returnToPool(Connection connection) throws SQLException; - - /** - * Removes all data related to an account from the database. - * - * @param uuid UUID of the account. - * @throws SQLException If a database error occurs. - */ - @Deprecated - public abstract void removeAccount(UUID uuid) throws SQLException; - - /** - * Used to clear all data from the database. - *

- * Uses DELETE * FROM table. - * - * @throws SQLException if remove fails. - */ - @Deprecated - public abstract void removeAllData() throws SQLException; - - /** - * Used to fetch the saved UUIDs in the users table. - * - * @return Set of saved UUIDs - * @throws SQLException If a database error occurs. - */ - @Deprecated - public Set getSavedUUIDs() throws SQLException { - return usersTable.getSavedUUIDs(); - } - - /** - * Used to get the Command usage mep. - * - * @return String command (key), Integer times used - * @throws SQLException If a database error occurs. - */ - @Deprecated - public Map getCommandUse() throws SQLException { - return commandUseTable.getCommandUse(); - } - - - public abstract void commit(Connection connection) throws SQLException; - - public boolean isUsingMySQL() { - return "mysql".equals(getConfigName()); - } - - @Deprecated - public abstract PlayerProfile getPlayerProfile(UUID uuid) throws SQLException; - - @Deprecated - public abstract ServerProfile getServerProfile(UUID serverUUID) throws SQLException; - - public UsersTable getUsersTable() { - return usersTable; - } - - public SessionsTable getSessionsTable() { - return sessionsTable; - } - - public KillsTable getKillsTable() { - return killsTable; - } - - public IPsTable getIpsTable() { - return ipsTable; - } - - public NicknamesTable getNicknamesTable() { - return nicknamesTable; - } - - public CommandUseTable getCommandUseTable() { - return commandUseTable; - } - - public TPSTable getTpsTable() { - return tpsTable; - } - - public SecurityTable getSecurityTable() { - return securityTable; - } - - public WorldTable getWorldTable() { - return worldTable; - } - - public WorldTimesTable getWorldTimesTable() { - return worldTimesTable; - } - - public ServerTable getServerTable() { - return serverTable; - } - - public ActionsTable getActionsTable() { - return actionsTable; - } + public abstract void close() throws DBException; - public UserInfoTable getUserInfoTable() { - return userInfoTable; + public boolean isOpen() { + return open; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java index 1f3b10615c..be20d5e97e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/BackupOperations.java @@ -1,11 +1,12 @@ package com.djrapitops.plan.system.database.databases.operation; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; public interface BackupOperations { - void backup(Database toDatabase); + void backup(Database toDatabase) throws DBException; + + void restore(Database fromDatabase) throws DBException; - void restore(Database fromDatabase); - } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java index bc37f7c469..ff8ecb763c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java @@ -1,12 +1,15 @@ package com.djrapitops.plan.system.database.databases.operation; +import com.djrapitops.plan.api.exceptions.database.DBException; + import java.util.UUID; public interface CheckOperations { - boolean wasSeenBefore(UUID player); + boolean isPlayerRegistered(UUID player) throws DBException; + + boolean isPlayerRegistered(UUID player, UUID server) throws DBException; - boolean wasSeenBefore(UUID player, UUID server); - + boolean doesWebUserExists(String username) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 8d44728a5a..af75bc269b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -1,19 +1,22 @@ package com.djrapitops.plan.system.database.databases.operation; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; -import java.sql.SQLException; +import java.util.Map; import java.util.Set; import java.util.UUID; public interface FetchOperations { - ServerProfile getServerProfile(UUID serverUUID) throws SQLException; + ServerProfile getServerProfile(UUID serverUUID) throws DBException; - PlayerProfile getPlayerProfile(UUID uuid) throws SQLException; + PlayerProfile getPlayerProfile(UUID uuid) throws DBException; - Set getSavedUUIDs() throws SQLException; + Set getSavedUUIDs() throws DBException; - Set getSavedUUIDs(UUID server) throws SQLException; + Set getSavedUUIDs(UUID server) throws DBException; + + Map getServerNames() throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java index 3355faf969..672351821d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/RemoveOperations.java @@ -1,19 +1,18 @@ package com.djrapitops.plan.system.database.databases.operation; -import com.djrapitops.plan.api.exceptions.DBNoDataException; +import com.djrapitops.plan.api.exceptions.database.DBException; -import java.sql.SQLException; import java.util.UUID; public interface RemoveOperations { - void removePlayer(UUID uuid) throws SQLException, DBNoDataException; + void player(UUID uuid) throws DBException; - void removePlayer(UUID player, UUID server) throws SQLException, DBNoDataException; + void player(UUID player, UUID server) throws DBException; - void removeServer(UUID serverUUID) throws SQLException, DBNoDataException; + void server(UUID serverUUID) throws DBException; - void removeAll() throws SQLException, DBNoDataException; + void everything() throws DBException; - void removeWebUser(String name) throws SQLException, DBNoDataException; + void webUser(String name) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/ErrorUtil.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/ErrorUtil.java new file mode 100644 index 0000000000..ef2b9abbd9 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/ErrorUtil.java @@ -0,0 +1,33 @@ +package com.djrapitops.plan.system.database.databases.sql; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.FatalDBException; + +import java.sql.SQLException; + +public class ErrorUtil { + + private ErrorUtil() { + } + + public static DBException getExceptionFor(SQLException e) { + String message = e.getMessage(); + if (message.contains("Communications link failure")) { + return new FatalDBException("MySQL-connection failed", e); + } else if (message.contains("syntax")) { + return new FatalDBException("There is an error in SQL syntax", e); + } else if (message.contains("duplicate key")) { + return new FatalDBException("An SQL save method attempts to save duplicates.", e); + } + return new DBException(e); + } + + public static FatalDBException getFatalExceptionFor(SQLException e) { + DBException normalException = getExceptionFor(e); + if (normalException instanceof FatalDBException) { + return (FatalDBException) normalException; + } else { + return new FatalDBException(normalException.getCause()); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/MySQLDB.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java index 8837f11bfb..50dfa59402 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.database.databases; +package com.djrapitops.plan.system.database.databases.sql; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLBackupOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLBackupOps.java new file mode 100644 index 0000000000..87a02138fc --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLBackupOps.java @@ -0,0 +1,21 @@ +package com.djrapitops.plan.system.database.databases.sql; + +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.operation.BackupOperations; + +public class SQLBackupOps implements BackupOperations { + + private final SQLDB db; + + public SQLBackupOps(SQLDB db) { + this.db = db; + } + + @Override + public void backup(Database toDatabase) { + } + + @Override + public void restore(Database fromDatabase) { + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLCheckOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLCheckOps.java new file mode 100644 index 0000000000..efa912c6f4 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLCheckOps.java @@ -0,0 +1,43 @@ +package com.djrapitops.plan.system.database.databases.sql; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.operation.CheckOperations; + +import java.sql.SQLException; +import java.util.UUID; + +public class SQLCheckOps implements CheckOperations { + + private final SQLDB db; + + public SQLCheckOps(SQLDB db) { + this.db = db; + } + + @Override + public boolean isPlayerRegistered(UUID player) throws DBException { + try { + return db.getUsersTable().isRegistered(player); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public boolean isPlayerRegistered(UUID player, UUID server) throws DBException { + try { + return db.getUserInfoTable().isRegistered(player, server); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public boolean doesWebUserExists(String username) throws DBException { + try { + return db.getSecurityTable().userExists(username); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java similarity index 71% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLDB.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 2ed862a891..1136281a64 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -1,11 +1,16 @@ -package com.djrapitops.plan.system.database.databases; +package com.djrapitops.plan.system.database.databases.sql; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.container.*; -import com.djrapitops.plan.system.database.tables.*; -import com.djrapitops.plan.system.database.tables.move.Version8TransferTable; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.operation.BackupOperations; +import com.djrapitops.plan.system.database.databases.operation.CheckOperations; +import com.djrapitops.plan.system.database.databases.operation.FetchOperations; +import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; +import com.djrapitops.plan.system.database.databases.sql.tables.*; +import com.djrapitops.plan.system.database.databases.sql.tables.move.Version8TransferTable; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.TimeAmount; @@ -27,6 +32,26 @@ */ public abstract class SQLDB extends Database { + private final UsersTable usersTable; + private final UserInfoTable userInfoTable; + private final ActionsTable actionsTable; + private final KillsTable killsTable; + private final NicknamesTable nicknamesTable; + private final SessionsTable sessionsTable; + private final IPsTable ipsTable; + private final CommandUseTable commandUseTable; + private final TPSTable tpsTable; + private final VersionTable versionTable; + private final SecurityTable securityTable; + private final WorldTable worldTable; + private final WorldTimesTable worldTimesTable; + private final ServerTable serverTable; + + private final SQLBackupOps backupOps; + private final SQLCheckOps checkOps; + private final SQLFetchOps fetchOps; + private final SQLRemoveOps removeOps; + private final boolean usingMySQL; private boolean open = false; private ITask dbCleanTask; @@ -34,22 +59,27 @@ public abstract class SQLDB extends Database { public SQLDB() { usingMySQL = getName().equals("MySQL"); - versionTable = new VersionTable(this, usingMySQL); - serverTable = new ServerTable(this, usingMySQL); - securityTable = new SecurityTable(this, usingMySQL); - - commandUseTable = new CommandUseTable(this, usingMySQL); - tpsTable = new TPSTable(this, usingMySQL); - - usersTable = new UsersTable(this, usingMySQL); - userInfoTable = new UserInfoTable(this, usingMySQL); - actionsTable = new ActionsTable(this, usingMySQL); - ipsTable = new IPsTable(this, usingMySQL); - nicknamesTable = new NicknamesTable(this, usingMySQL); - sessionsTable = new SessionsTable(this, usingMySQL); - killsTable = new KillsTable(this, usingMySQL); - worldTable = new WorldTable(this, usingMySQL); - worldTimesTable = new WorldTimesTable(this, usingMySQL); + versionTable = new VersionTable(this); + serverTable = new ServerTable(this); + securityTable = new SecurityTable(this); + + commandUseTable = new CommandUseTable(this); + tpsTable = new TPSTable(this); + + usersTable = new UsersTable(this); + userInfoTable = new UserInfoTable(this); + actionsTable = new ActionsTable(this); + ipsTable = new IPsTable(this); + nicknamesTable = new NicknamesTable(this); + sessionsTable = new SessionsTable(this); + killsTable = new KillsTable(this); + worldTable = new WorldTable(this); + worldTimesTable = new WorldTimesTable(this); + + backupOps = new SQLBackupOps(this); + checkOps = new SQLCheckOps(this); + fetchOps = new SQLFetchOps(this); + removeOps = new SQLRemoveOps(this); } /** @@ -60,10 +90,10 @@ public SQLDB() { * Converts Unsaved Bukkit player files to database data. * Cleans the database. * - * @throws DatabaseInitException if Database fails to initiate. + * @throws DBInitException if Database fails to initiate. */ @Override - public void init() throws DatabaseInitException { + public void init() throws DBInitException { setStatus("Init"); String benchName = "Init " + getConfigName(); Benchmark.start("Database", benchName); @@ -99,9 +129,9 @@ public void run() { *

* Updates to latest schema. * - * @throws DatabaseInitException if something goes wrong. + * @throws DBInitException if something goes wrong. */ - public void setupDatabase() throws DatabaseInitException { + public void setupDatabase() throws DBInitException { try { boolean newDatabase = isNewDatabase(); @@ -122,7 +152,7 @@ public void setupDatabase() throws DatabaseInitException { public void run() { try { new Version8TransferTable(db, isUsingMySQL()).alterTablesToV10(); - } catch (DatabaseInitException | SQLException e) { + } catch (DBInitException | SQLException e) { Log.toLog(this.getClass().getName(), e); } } @@ -142,7 +172,7 @@ public void run() { setVersion(13); } } catch (SQLException e) { - throw new DatabaseInitException("Failed to set-up Database", e); + throw new DBInitException("Failed to set-up Database", e); } } @@ -151,7 +181,7 @@ public void run() { *

* Updates table columns to latest schema. */ - private void createTables() throws DatabaseInitException { + private void createTables() throws DBInitException { Benchmark.start("Database", "Create tables"); for (Table table : getAllTables()) { table.createTable(); @@ -191,15 +221,10 @@ public Table[] getAllTablesInRemoveOrder() { /** * Setups the {@link BasicDataSource} */ - public abstract void setupDataSource() throws DatabaseInitException; + public abstract void setupDataSource() throws DBInitException; - /** - * Closes the SQLDB - * - * @throws SQLException DB Error - */ @Override - public void close() throws SQLException { + public void close() { setStatus("Closed"); open = false; Log.logDebug("Database"); // Log remaining Debug info if present @@ -208,70 +233,18 @@ public void close() throws SQLException { } } - /** - * @return @throws SQLException - */ - @Override public int getVersion() throws SQLException { return versionTable.getVersion(); } - @Override public void setVersion(int version) throws SQLException { versionTable.setVersion(version); } - @Override public boolean isNewDatabase() throws SQLException { return versionTable.isNewDatabase(); } - @Override - public PlayerProfile getPlayerProfile(UUID uuid) throws SQLException { - if (!wasSeenBefore(uuid)) { - return null; - } - - String playerName = usersTable.getPlayerName(uuid); - Optional registerDate = usersTable.getRegisterDate(uuid); - - if (!registerDate.isPresent()) { - throw new IllegalStateException("User has been saved with null register date to a NOT NULL column"); - } - - PlayerProfile profile = new PlayerProfile(uuid, playerName, registerDate.get()); - profile.setTimesKicked(usersTable.getTimesKicked(uuid)); - - Map userInfo = userInfoTable.getAllUserInfo(uuid); - addUserInfoToProfile(profile, userInfo); - - profile.setActions(actionsTable.getActions(uuid)); - profile.setNicknames(nicknamesTable.getAllNicknames(uuid)); - profile.setGeoInformation(ipsTable.getGeoInfo(uuid)); - - Map> sessions = sessionsTable.getSessions(uuid); - profile.setSessions(sessions); - profile.calculateWorldTimesPerServer(); - profile.setTotalWorldTimes(worldTimesTable.getWorldTimesOfUser(uuid)); - - return profile; - } - - private void addUserInfoToProfile(PlayerProfile profile, Map userInfo) { - for (Map.Entry entry : userInfo.entrySet()) { - UUID serverUUID = entry.getKey(); - UserInfo info = entry.getValue(); - - profile.setRegistered(serverUUID, info.getRegistered()); - if (info.isBanned()) { - profile.bannedOnServer(serverUUID); - } - if (info.isOpped()) { - profile.oppedOnServer(serverUUID); - } - } - } - @Override public ServerProfile getServerProfile(UUID serverUUID) throws SQLException { ServerProfile profile = new ServerProfile(serverUUID); @@ -330,21 +303,6 @@ private List getPlayers(UUID serverUUID) throws SQLException { return players; } - @Override - public boolean wasSeenBefore(UUID uuid) { - if (uuid == null) { - return false; - } - try { - return usersTable.isRegistered(uuid); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - return false; - } finally { - setAvailable(); - } - } - public void removeAccount(UUID uuid) throws SQLException { if (uuid == null) { return; @@ -374,18 +332,6 @@ private void clean() throws SQLException { Log.info("Clean complete."); } - @Override - public void removeAllData() throws SQLException { - setStatus("Clearing all data"); - try { - for (Table table : getAllTablesInRemoveOrder()) { - table.removeAllData(); - } - } finally { - setAvailable(); - } - } - private void setStatus(String status) { Log.logDebug("Database", status); } @@ -401,7 +347,6 @@ public void setAvailable() { *

* MySQL has Auto Commit enabled. */ - @Override public void commit(Connection connection) throws SQLException { try { if (!usingMySQL) { @@ -416,7 +361,6 @@ public void commit(Connection connection) throws SQLException { } } - @Override public void returnToPool(Connection connection) throws SQLException { if (usingMySQL && connection != null) { connection.close(); @@ -438,7 +382,79 @@ public void rollback(Connection connection) throws SQLException { } } - public boolean isOpen() { - return open; + public UsersTable getUsersTable() { + return usersTable; + } + + public SessionsTable getSessionsTable() { + return sessionsTable; + } + + public KillsTable getKillsTable() { + return killsTable; + } + + public IPsTable getIpsTable() { + return ipsTable; + } + + public NicknamesTable getNicknamesTable() { + return nicknamesTable; + } + + public CommandUseTable getCommandUseTable() { + return commandUseTable; + } + + public TPSTable getTpsTable() { + return tpsTable; + } + + public SecurityTable getSecurityTable() { + return securityTable; + } + + public WorldTable getWorldTable() { + return worldTable; + } + + public WorldTimesTable getWorldTimesTable() { + return worldTimesTable; + } + + public ServerTable getServerTable() { + return serverTable; + } + + public ActionsTable getActionsTable() { + return actionsTable; + } + + public UserInfoTable getUserInfoTable() { + return userInfoTable; + } + + public boolean isUsingMySQL() { + return this instanceof MySQLDB; + } + + @Override + public BackupOperations backup() { + return backupOps; + } + + @Override + public CheckOperations check() { + return checkOps; + } + + @Override + public FetchOperations fetch() { + return fetchOps; + } + + @Override + public RemoveOperations remove() { + return removeOps; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLFetchOps.java new file mode 100644 index 0000000000..1957e421a1 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLFetchOps.java @@ -0,0 +1,100 @@ +package com.djrapitops.plan.system.database.databases.sql; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.PlayerProfile; +import com.djrapitops.plan.data.ServerProfile; +import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.data.container.UserInfo; +import com.djrapitops.plan.system.database.databases.operation.FetchOperations; + +import java.sql.SQLException; +import java.util.*; + +public class SQLFetchOps extends SQLOps implements FetchOperations { + + public SQLFetchOps(SQLDB db) { + super(db); + } + + @Override + public ServerProfile getServerProfile(UUID serverUUID) { + return null; + } + + @Override + public PlayerProfile getPlayerProfile(UUID uuid) throws DBException { + try { + if (!usersTable.isRegistered(uuid)) { + return null; + } + + String playerName = usersTable.getPlayerName(uuid); + Optional registerDate = usersTable.getRegisterDate(uuid); + + if (!registerDate.isPresent()) { + throw new IllegalStateException("User has been saved with null register date to a NOT NULL column"); + } + + PlayerProfile profile = new PlayerProfile(uuid, playerName, registerDate.get()); + profile.setTimesKicked(usersTable.getTimesKicked(uuid)); + + Map userInfo = userInfoTable.getAllUserInfo(uuid); + addUserInfoToProfile(profile, userInfo); + + profile.setActions(actionsTable.getActions(uuid)); + profile.setNicknames(nicknamesTable.getAllNicknames(uuid)); + profile.setGeoInformation(ipsTable.getGeoInfo(uuid)); + + Map> sessions = sessionsTable.getSessions(uuid); + profile.setSessions(sessions); + profile.calculateWorldTimesPerServer(); + profile.setTotalWorldTimes(worldTimesTable.getWorldTimesOfUser(uuid)); + + return profile; + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + private void addUserInfoToProfile(PlayerProfile profile, Map userInfo) { + for (Map.Entry entry : userInfo.entrySet()) { + UUID serverUUID = entry.getKey(); + UserInfo info = entry.getValue(); + + profile.setRegistered(serverUUID, info.getRegistered()); + if (info.isBanned()) { + profile.bannedOnServer(serverUUID); + } + if (info.isOpped()) { + profile.oppedOnServer(serverUUID); + } + } + } + + @Override + public Set getSavedUUIDs() throws DBException { + try { + return usersTable.getSavedUUIDs(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Set getSavedUUIDs(UUID server) throws DBException { + try { + return userInfoTable.getSavedUUIDs(server); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getServerNames() throws DBException { + try { + return serverTable.getServerNames(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLOps.java new file mode 100644 index 0000000000..9abd83bfd4 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLOps.java @@ -0,0 +1,40 @@ +package com.djrapitops.plan.system.database.databases.sql; + +import com.djrapitops.plan.system.database.databases.sql.tables.*; + +public class SQLOps { + + protected final SQLDB db; + + protected final UsersTable usersTable; + protected final UserInfoTable userInfoTable; + protected final ActionsTable actionsTable; + protected final KillsTable killsTable; + protected final NicknamesTable nicknamesTable; + protected final SessionsTable sessionsTable; + protected final IPsTable ipsTable; + protected final CommandUseTable commandUseTable; + protected final TPSTable tpsTable; + protected final SecurityTable securityTable; + protected final WorldTable worldTable; + protected final WorldTimesTable worldTimesTable; + protected final ServerTable serverTable; + + public SQLOps(SQLDB db) { + this.db = db; + + usersTable = db.getUsersTable(); + userInfoTable = db.getUserInfoTable(); + actionsTable = db.getActionsTable(); + killsTable = db.getKillsTable(); + nicknamesTable = db.getNicknamesTable(); + sessionsTable = db.getSessionsTable(); + ipsTable = db.getIpsTable(); + commandUseTable = db.getCommandUseTable(); + tpsTable = db.getTpsTable(); + securityTable = db.getSecurityTable(); + worldTable = db.getWorldTable(); + worldTimesTable = db.getWorldTimesTable(); + serverTable = db.getServerTable(); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLRemoveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLRemoveOps.java new file mode 100644 index 0000000000..e78504cadd --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLRemoveOps.java @@ -0,0 +1,74 @@ +package com.djrapitops.plan.system.database.databases.sql; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.FatalDBException; +import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; +import com.djrapitops.plan.system.database.databases.sql.tables.Table; +import com.djrapitops.plan.system.database.databases.sql.tables.UserIDTable; +import com.djrapitops.plugin.api.Benchmark; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.sql.SQLException; +import java.util.UUID; + +public class SQLRemoveOps extends SQLOps implements RemoveOperations { + + public SQLRemoveOps(SQLDB db) { + super(db); + } + + @Override + public void player(UUID uuid) throws DBException { + if (uuid == null) { + return; + } + + try { + Log.logDebug("Database", "Removing Account: " + uuid); + Benchmark.start("Database", "Remove Account"); + + for (Table t : db.getAllTablesInRemoveOrder()) { + if (!(t instanceof UserIDTable)) { + continue; + } + + UserIDTable table = (UserIDTable) t; + table.removeUser(uuid); + } + } catch (SQLException e) { + throw ErrorUtil.getFatalExceptionFor(e); + } finally { + Benchmark.stop("Database", "Remove Account"); + } + } + + @Override + public void player(UUID player, UUID server) throws DBException { + throw new FatalDBException("Not Implemented"); + } + + @Override + public void server(UUID serverUUID) throws DBException { + throw new FatalDBException("Not Implemented"); + } + + @Override + public void everything() throws DBException { + try { + for (Table table : db.getAllTablesInRemoveOrder()) { + table.removeAllData(); + } + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void webUser(String userName) throws DBException { + try { + securityTable.removeUser(userName); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLiteDB.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index e66d7daab9..ca838b264a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -1,6 +1,7 @@ -package com.djrapitops.plan.system.database.databases; +package com.djrapitops.plan.system.database.databases.sql; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; @@ -38,11 +39,11 @@ public SQLiteDB(String dbName) { * Setups the {@link BasicDataSource} */ @Override - public void setupDataSource() throws DatabaseInitException { + public void setupDataSource() throws DBInitException { try { connection = getNewConnection(dbName); } catch (SQLException e) { - throw new DatabaseInitException(e); + throw new DBInitException(e); } startConnectionPingTask(); } @@ -132,7 +133,7 @@ public Connection getConnection() throws SQLException { } @Override - public void close() throws SQLException { + public void close() { stopConnectionPingTask(); MiscUtils.close(connection); super.close(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/processing/ExecStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java similarity index 79% rename from Plan/src/main/java/com/djrapitops/plan/system/database/processing/ExecStatement.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java index 7f12a4cacd..5f843523df 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/processing/ExecStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java @@ -2,7 +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.database.processing; +package com.djrapitops.plan.system.database.databases.sql.processing; + +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.utility.log.Log; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -18,7 +21,9 @@ public abstract class ExecStatement { public ExecStatement(String sql) { this.sql = sql; -// Log.debug("Execute Statement: " + sql); + if (Settings.DEV_MODE.isTrue()) { + Log.debug("Execute Statement: " + sql); + } } public boolean execute(PreparedStatement statement) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryAllStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryAllStatement.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryAllStatement.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryAllStatement.java index d4cf06c7d2..563b6191ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryAllStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryAllStatement.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.database.processing; +package com.djrapitops.plan.system.database.databases.sql.processing; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryStatement.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java index b386876832..0e7c4ad089 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/processing/QueryStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java @@ -2,7 +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.database.processing; +package com.djrapitops.plan.system.database.databases.sql.processing; + +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.utility.log.Log; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -24,7 +27,9 @@ public QueryStatement(String sql) { public QueryStatement(String sql, int fetchSize) { this.sql = sql; -// Log.debug("Query Statement: " + sql); + if (Settings.DEV_MODE.isTrue()) { + Log.debug("Query Statement: " + sql); + } this.fetchSize = fetchSize; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Insert.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Insert.java new file mode 100644 index 0000000000..b3e7a44c20 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Insert.java @@ -0,0 +1,30 @@ +package com.djrapitops.plan.system.database.databases.sql.statements; + +public class Insert extends SqlParser { + + public Insert(String table) { + super("INSERT INTO " + table); + addSpace(); + } + + public static String values(String table, String... columns) { + Insert parser = new Insert(table); + parser.append("("); + int size = columns.length; + for (int i = 0; i < size; i++) { + if (size > 1 && i > 0) { + parser.append(", "); + } + parser.append(columns[i]); + } + parser.append(") VALUES ("); + for (int i = 0; i < size; i++) { + if (size > 1 && i > 0) { + parser.append(", "); + } + parser.append("?"); + } + parser.append(")"); + return parser.toString(); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Select.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Select.java new file mode 100644 index 0000000000..9ed55c38ca --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Select.java @@ -0,0 +1,26 @@ +package com.djrapitops.plan.system.database.databases.sql.statements; + +public class Select extends WhereParser { + + public Select(String start) { + super(start); + } + + public static Select from(String table, String... columns) { + Select parser = new Select("SELECT "); + int size = columns.length; + for (int i = 0; i < size; i++) { + if (size > 1 && i > 0) { + parser.append(", "); + } + parser.append(columns[i]); + } + + parser.append(" FROM ").append(table); + return parser; + } + + public static Select all(String table) { + return new Select("SELECT * FROM " + table); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Sql.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Sql.java new file mode 100644 index 0000000000..973c2d38b9 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Sql.java @@ -0,0 +1,16 @@ +package com.djrapitops.plan.system.database.databases.sql.statements; + +public class Sql { + public static final String INT = "integer"; + public static final String DOUBLE = "double"; + public static final String LONG = "bigint"; + public static final String BOOL = "boolean"; + + private Sql() { + throw new IllegalStateException("Variable Class"); + } + + public static String varchar(int length) { + return "varchar(" + length + ")"; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/SqlParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/SqlParser.java new file mode 100644 index 0000000000..0d6109bfec --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/SqlParser.java @@ -0,0 +1,35 @@ +package com.djrapitops.plan.system.database.databases.sql.statements; + +/** + * Class for parsing different SQL strings. + * + * @author Rsl1122 + * @since 3.7.0 + */ +public class SqlParser { + + private final StringBuilder s; + + public SqlParser() { + s = new StringBuilder(); + } + + public SqlParser(String start) { + s = new StringBuilder(start); + } + + public SqlParser addSpace() { + s.append(" "); + return this; + } + + public SqlParser append(String string) { + s.append(string); + return this; + } + + @Override + public String toString() { + return s.toString(); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/TableSqlParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/TableSqlParser.java new file mode 100644 index 0000000000..ec0a0df708 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/TableSqlParser.java @@ -0,0 +1,118 @@ +package com.djrapitops.plan.system.database.databases.sql.statements; + +/** + * SqlParser Class for parsing table creation, removal and modification statements. + * + * @author Rsl1122 + * @since 3.7.0 + */ +public class TableSqlParser extends SqlParser { + + private int columns = 0; + + public TableSqlParser(String start) { + super(start); + } + + public static TableSqlParser createTable(String tableName) { + return new TableSqlParser("CREATE TABLE IF NOT EXISTS " + tableName + " ("); + } + + public static String dropTable(String tableName) { + return "DROP TABLE IF EXISTS " + tableName; + } + + /** + * Used for ALTER TABLE sql statements. + * + * @param column column to modify + * @return TableSqlParser object + */ + public static TableSqlParser newColumn(String column, String type) { + return new TableSqlParser("").column(column, type); + } + + public TableSqlParser column(String column, String type) { + if (columns > 0) { + append(", "); + } + append(column).addSpace(); + append(type); + + columns++; + return this; + } + + public TableSqlParser foreignKey(String column, String refrencedTable, String referencedColumn) { + if (columns > 0) { + append(", "); + } + append("FOREIGN KEY(") + .append(column) + .append(") REFERENCES ") + .append(refrencedTable) + .append("(") + .append(referencedColumn) + .append(")"); + columns++; + return this; + } + + public TableSqlParser notNull() { + addSpace(); + append("NOT NULL"); + return this; + } + + public TableSqlParser unique() { + addSpace(); + append("UNIQUE"); + return this; + } + + public TableSqlParser defaultValue(boolean value) { + return defaultValue(value ? "1" : "0"); + } + + public TableSqlParser defaultValue(String value) { + addSpace(); + append("DEFAULT ").append(value); + return this; + } + + public TableSqlParser primaryKeyIDColumn(boolean mySQL, String column) { + if (columns > 0) { + append(", "); + } + append(column).addSpace(); + append(Sql.INT).addSpace(); + append((mySQL) ? "NOT NULL AUTO_INCREMENT" : "PRIMARY KEY"); + columns++; + return this; + } + + public TableSqlParser primaryKey(boolean mySQL, String column) { + if (mySQL) { + if (columns > 0) { + append(", "); + } + append("PRIMARY KEY (").append(column).append(")"); + columns++; + } + return this; + } + + public TableSqlParser charSetUTF8(boolean mySQL) { + if (mySQL) { + addSpace(); + append("CHARACTER SET utf8 COLLATE utf8mb4_general_ci"); + } + return this; + } + + @Override + public String toString() { + append(")"); + return super.toString(); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Update.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Update.java new file mode 100644 index 0000000000..9e9b4b73c7 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/Update.java @@ -0,0 +1,30 @@ +/* + * 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.database.databases.sql.statements; + +/** + * @author Fuzzlemann + */ +public class Update extends WhereParser { + + public Update(String table) { + super("UPDATE " + table + " SET"); + addSpace(); + } + + public static Update values(String table, String... values) { + Update parser = new Update(table); + + int size = values.length; + for (int i = 0; i < size; i++) { + if (size > 1 && i > 0) { + parser.append(", "); + } + parser.append(values[i] + "=?"); + } + + return parser; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/WhereParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/WhereParser.java new file mode 100644 index 0000000000..7b534abf3c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/statements/WhereParser.java @@ -0,0 +1,48 @@ +/* + * 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.database.databases.sql.statements; + +/** + * @author Fuzzlemann + */ +public abstract class WhereParser extends SqlParser { + + private int conditions = 0; + + public WhereParser() { + super(); + } + + public WhereParser(String start) { + super(start); + } + + public WhereParser where(String... conditions) { + append(" WHERE "); + for (String condition : conditions) { + if (this.conditions > 0) { + append(" AND "); + } + append("(").append(condition).append(")"); + this.conditions++; + } + + return this; + } + + public WhereParser and(String condition) { + append(" AND "); + append("(").append(condition).append(")"); + this.conditions++; + return this; + } + + public WhereParser or(String condition) { + append(" OR "); + append("(").append(condition).append(")"); + this.conditions++; + return this; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java index 4f752ad585..cfa90bc73b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ActionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java @@ -2,19 +2,19 @@ * 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.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Select; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -46,8 +46,8 @@ public class ActionsTable extends UserIDTable { private final ServerTable serverTable; private String insertStatement; - public ActionsTable(SQLDB db, boolean usingMySQL) { - super("plan_actions", db, usingMySQL); + public ActionsTable(SQLDB db) { + super("plan_actions", db); serverTable = db.getServerTable(); insertStatement = "INSERT INTO " + tableName + " (" + columnUserID + ", " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/CommandUseTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/CommandUseTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java index 428f66b144..5303d4a49f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/CommandUseTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java @@ -1,14 +1,14 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Select; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -31,8 +31,8 @@ public class CommandUseTable extends Table { private final ServerTable serverTable; private String insertStatement; - public CommandUseTable(SQLDB db, boolean usingMySQL) { - super("plan_commandusages", db, usingMySQL); + public CommandUseTable(SQLDB db) { + super("plan_commandusages", db); serverTable = db.getServerTable(); insertStatement = "INSERT INTO " + tableName + " (" + columnCommand + ", " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/IPsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/IPsTable.java similarity index 90% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/IPsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/IPsTable.java index 0d08561892..27e5746356 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/IPsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/IPsTable.java @@ -1,14 +1,14 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.GeoInfo; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Select; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -26,12 +26,8 @@ public class IPsTable extends UserIDTable { private final String columnLastUsed = "last_used"; private String insertStatement; - /** - * @param db The database - * @param usingMySQL if the server is using MySQL - */ - public IPsTable(SQLDB db, boolean usingMySQL) { - super("plan_ips", db, usingMySQL); + public IPsTable(SQLDB db) { + super("plan_ips", db); insertStatement = "INSERT INTO " + tableName + " (" + columnUserID + ", " + columnIP + ", " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/KillsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/KillsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java index eb67b74d8b..090a54d87a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/KillsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java @@ -1,14 +1,14 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -30,8 +30,8 @@ public class KillsTable extends UserIDTable { private final SessionsTable sessionsTable; private String insertStatement; - public KillsTable(SQLDB db, boolean usingMySQL) { - super("plan_kills", db, usingMySQL); + public KillsTable(SQLDB db) { + super("plan_kills", db); sessionsTable = db.getSessionsTable(); insertStatement = "INSERT INTO " + tableName + " (" + columnKillerUserID + ", " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/NicknamesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/NicknamesTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java index 8b4c1bdd94..76c4bc1e1c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/NicknamesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java @@ -1,13 +1,13 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -26,12 +26,8 @@ public class NicknamesTable extends UserIDTable { private final ServerTable serverTable; private String insertStatement; - /** - * @param db The database - * @param usingMySQL if the server is using MySQL - */ - public NicknamesTable(SQLDB db, boolean usingMySQL) { - super("plan_nicknames", db, usingMySQL); + public NicknamesTable(SQLDB db) { + super("plan_nicknames", db); serverTable = db.getServerTable(); insertStatement = "INSERT INTO " + tableName + " (" + columnUserID + ", " + diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SecurityTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SecurityTable.java similarity index 84% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/SecurityTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SecurityTable.java index 00ef2368b4..8070a75183 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SecurityTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SecurityTable.java @@ -3,18 +3,18 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Insert; -import com.djrapitops.plan.system.database.sql.Select; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Insert; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -33,8 +33,8 @@ public class SecurityTable extends Table { private final String columnPermLevel = "permission_level"; private String insertStatement; - public SecurityTable(SQLDB db, boolean usingMySQL) { - super("plan_security", db, usingMySQL); + public SecurityTable(SQLDB db) { + super("plan_security", db); insertStatement = Insert.values(tableName, columnUser, columnSaltedHash, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java index 12c42c6587..a69462922d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java @@ -2,14 +2,14 @@ * 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.database.tables; - -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.*; +package com.djrapitops.plan.system.database.databases.sql.tables; + +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.*; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; @@ -45,8 +45,8 @@ public class ServerTable extends Table { private final String columnMaxPlayers = "max_players"; private String insertStatement; - public ServerTable(SQLDB db, boolean usingMySQL) { - super("plan_servers", db, usingMySQL); + public ServerTable(SQLDB db) { + super("plan_servers", db); statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + ")"; statementSelectServerNameID = "(" + Select.from(tableName, tableName + "." + columnServerName).where(columnServerID + "=?").toString() + ")"; insertStatement = Insert.values(tableName, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/SessionsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java index 1b3ab61fb5..a454d192dd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java @@ -1,15 +1,15 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Select; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -34,8 +34,8 @@ public class SessionsTable extends UserIDTable { private final ServerTable serverTable; private String insertStatement; - public SessionsTable(SQLDB db, boolean usingMySQL) { - super("plan_sessions", db, usingMySQL); + public SessionsTable(SQLDB db) { + super("plan_sessions", db); serverTable = db.getServerTable(); insertStatement = "INSERT INTO " + tableName + " (" + columnUserID + ", " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/TPSTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java index 0cf5af36e5..0f3534c714 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/TPSTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java @@ -1,14 +1,15 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Select; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; @@ -39,8 +40,8 @@ public class TPSTable extends Table { private final ServerTable serverTable; private String insertStatement; - public TPSTable(SQLDB db, boolean usingMySQL) { - super("plan_tps", db, usingMySQL); + public TPSTable(SQLDB db) { + super("plan_tps", db); serverTable = db.getServerTable(); insertStatement = "INSERT INTO " + tableName + " (" + columnServerID + ", " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Table.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/Table.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java index 3837286ffd..9c776105f7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/Table.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java @@ -1,9 +1,9 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.utilities.Verify; import com.google.common.base.Objects; @@ -39,10 +39,15 @@ public abstract class Table { * @param db Database to use. * @param usingMySQL Is the database using MySQL? */ + @Deprecated public Table(String name, SQLDB db, boolean usingMySQL) { + this(name, db); + } + + public Table(String name, SQLDB db) { this.tableName = name; this.db = db; - this.usingMySQL = usingMySQL; + this.usingMySQL = db.isUsingMySQL(); } public abstract void createTable() throws DBCreateTableException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserIDTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserIDTable.java similarity index 74% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserIDTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserIDTable.java index 695154c697..5b71547515 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserIDTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserIDTable.java @@ -1,7 +1,7 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -18,8 +18,8 @@ public abstract class UserIDTable extends Table { protected final String columnUserID = "user_id"; protected final UsersTable usersTable; - public UserIDTable(String name, SQLDB db, boolean usingMySQL) { - super(name, db, usingMySQL); + public UserIDTable(String name, SQLDB db) { + super(name, db); usersTable = db.getUsersTable(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java index e8c27d4b62..cce01b8534 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java @@ -2,19 +2,20 @@ * 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.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Select; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; -import com.djrapitops.plan.system.database.sql.Update; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.statements.Update; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -39,8 +40,8 @@ public class UserInfoTable extends UserIDTable { private final ServerTable serverTable; - public UserInfoTable(SQLDB db, boolean usingMySQL) { - super("plan_user_info", db, usingMySQL); + public UserInfoTable(SQLDB db) { + super("plan_user_info", db); serverTable = db.getServerTable(); } @@ -341,4 +342,9 @@ public Integer processResults(ResultSet set) throws SQLException { return 0; } } + + // TODO improve performance of this method. + public Set getSavedUUIDs(UUID serverUUID) throws SQLException { + return getSavedUUIDs().get(serverUUID); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/UsersTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java index 9eea711155..80a1056d30 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java @@ -1,12 +1,12 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.*; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.*; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -27,8 +27,8 @@ public class UsersTable extends UserIDTable { private final String columnTimesKicked = "times_kicked"; private String insertStatement; - public UsersTable(SQLDB db, boolean usingMySQL) { - super("plan_users", db, usingMySQL); + public UsersTable(SQLDB db) { + super("plan_users", db); statementSelectID = "(" + Select.from(tableName, tableName + "." + columnID).where(columnUUID + "=?").toString() + ")"; insertStatement = Insert.values(tableName, columnUUID, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/VersionTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/VersionTable.java similarity index 75% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/VersionTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/VersionTable.java index 6fa3c818e9..77525036ca 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/VersionTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/VersionTable.java @@ -1,12 +1,12 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -17,8 +17,8 @@ */ public class VersionTable extends Table { - public VersionTable(SQLDB db, boolean usingMySQL) { - super("plan_version", db, usingMySQL); + public VersionTable(SQLDB db) { + super("plan_version", db); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java similarity index 86% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java index cc1f78a606..6ead4143c6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java @@ -1,12 +1,13 @@ -package com.djrapitops.plan.system.database.tables; - -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +package com.djrapitops.plan.system.database.databases.sql.tables; + +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -28,14 +29,8 @@ public class WorldTable extends Table { private final String columnWorldId = "id"; private final String columnWorldName = "world_name"; - /** - * Constructor. - * - * @param db Database this table is a part of. - * @param usingMySQL Database is a MySQL database. - */ - public WorldTable(SQLDB db, boolean usingMySQL) { - super("plan_worlds", db, usingMySQL); + public WorldTable(SQLDB db) { + super("plan_worlds", db); statementSelectID = "(SELECT " + columnWorldId + " FROM " + tableName + " WHERE (" + columnWorldName + "=?))"; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTimesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTimesTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java index 84f68dfa4f..98e93cbef9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/WorldTimesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java @@ -1,16 +1,16 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.processing.ExecStatement; -import com.djrapitops.plan.system.database.processing.QueryAllStatement; -import com.djrapitops.plan.system.database.processing.QueryStatement; -import com.djrapitops.plan.system.database.sql.Sql; -import com.djrapitops.plan.system.database.sql.TableSqlParser; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -38,14 +38,8 @@ public class WorldTimesTable extends UserIDTable { private final SessionsTable sessionsTable; private String insertStatement; - /** - * Constructor. - * - * @param db Database this table is a part of. - * @param usingMySQL Database is a MySQL database. - */ - public WorldTimesTable(SQLDB db, boolean usingMySQL) { - super("plan_world_times", db, usingMySQL); + public WorldTimesTable(SQLDB db) { + super("plan_world_times", db); worldTable = db.getWorldTable(); sessionsTable = db.getSessionsTable(); insertStatement = "INSERT INTO " + tableName + " (" + diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java similarity index 88% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java index dcced5574f..ac0558457d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java @@ -2,14 +2,14 @@ * 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.database.tables.move; +package com.djrapitops.plan.system.database.databases.sql.tables.move; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.tables.ServerTable; -import com.djrapitops.plan.system.database.tables.Table; -import com.djrapitops.plan.system.database.tables.UsersTable; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; +import com.djrapitops.plan.system.database.databases.sql.tables.Table; +import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.api.utility.log.Log; @@ -45,8 +45,8 @@ public class BatchOperationTable extends Table { * @throws IllegalStateException if database.init has not been called. * @throws ClassCastException if database is not SQLDB. */ - public BatchOperationTable(Database database) { - super("", (SQLDB) database, false); + public BatchOperationTable(SQLDB database) { + super("", database); if (!db.isOpen()) { throw new IllegalStateException("Given Database had not been initialized."); } @@ -63,7 +63,15 @@ public void clearTable(Table table) throws SQLException { @Override public void removeAllData() throws SQLException { - db.removeAllData(); + try { + db.remove().everything(); + } catch (DBException e) { + if (e.getCause() instanceof SQLException) { + throw (SQLException) e.getCause(); + } else { + Log.toLog(this.getClass(), e); + } + } } public void copyEverything(BatchOperationTable toDB) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java index 0648fcfe9f..4fd88394a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java @@ -2,12 +2,12 @@ * 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.database.tables.move; +package com.djrapitops.plan.system.database.databases.sql.tables.move; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.tables.*; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plugin.api.Benchmark; import java.sql.SQLException; 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/processors/importing/importers/Importer.java index 48e8c662ec..dc1cce8f3c 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/processors/importing/importers/Importer.java @@ -104,14 +104,14 @@ private void processServerData() { new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() { db.getTpsTable().insertAllTPS(ImmutableMap.of(uuid, serverImportData.getTpsData())); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() { db.getCommandUseTable().insertCommandUsage(ImmutableMap.of(uuid, serverImportData.getCommandUsages())); } }.submit(service); @@ -129,7 +129,7 @@ void execute() throws SQLException { Benchmark.stop(benchmarkName); } - private void processUserData() throws SQLException { + private void processUserData() { String benchmarkName = "Processing User Data"; String getDataBenchmarkName = "Getting User Data"; String insertDataIntoCollectionsBenchmarkName = "Insert User Data into Collections"; @@ -154,8 +154,8 @@ private void processUserData() throws SQLException { UUID serverUUID = plugin.getServerInfoManager().getServerUUID(); Database db = plugin.getDB(); - Set existingUUIDs = db.getSavedUUIDs(); - Set existingUserInfoTableUUIDs = db.getUserInfoTable().getSavedUUIDs().get(serverUUID); + Set existingUUIDs = db.fetch().getSavedUUIDs(); + Set existingUserInfoTableUUIDs = db.fetch().getSavedUUIDs(serverUUID); Benchmark.start(insertDataIntoCollectionsBenchmarkName); @@ -194,35 +194,35 @@ private void processUserData() throws SQLException { new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() { db.getSessionsTable().insertSessions(ImmutableMap.of(serverUUID, sessions), true); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() { db.getUsersTable().updateKicked(timesKicked); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() { db.getUserInfoTable().insertUserInfo(ImmutableMap.of(serverUUID, userInfo)); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() { db.getNicknamesTable().insertNicknames(ImmutableMap.of(serverUUID, nickNames)); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() { db.getIpsTable().insertAllGeoInfo(geoInfo); } }.submit(service); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java index 4dbcad6005..bf33ec617c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.system.database.tables.UsersTable; +import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java index 0a74b71e00..307f598ac2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.tables.NicknamesTable; +import com.djrapitops.plan.system.database.databases.sql.tables.NicknamesTable; import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index b4ddc83c0e..8918e43e7b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java @@ -8,8 +8,8 @@ import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.tables.UserInfoTable; -import com.djrapitops.plan.system.database.tables.UsersTable; +import com.djrapitops.plan.system.database.databases.sql.tables.UserInfoTable; +import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java index 3b3bb0bbd1..3fd888cc6e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; @@ -42,7 +43,7 @@ public Response getResponse(Request request, List target) { return notFound("Player has no UUID"); } - if (PlanPlugin.getInstance().getDB().wasSeenBefore(uuid)) { + if (Database.getActive().check().isPlayerRegistered(uuid)) { PlanPlugin.getInstance().getInfoManager().cachePlayer(uuid); Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); // TODO Create a new method that places NotFoundResponse to ResponseCache instead. diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index d288baaab8..ed33ead3a3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.*; +import com.djrapitops.plan.api.exceptions.webapi.*; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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 1f08ce47d3..6dfd6c16d4 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 @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; 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 6bc3714eab..7a4699a43b 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 @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index f4a92b0f54..16f92b044c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.settings.ServerSpecificSettings; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java index b0c8446e75..bd03e9f984 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java index 66df8b759a..b60573e93d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import org.bukkit.entity.Player; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java index 00dc96adc5..033b2bb425 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BukkitInformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java index b756187258..619fdb8d41 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.InformationManager; 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 09ec52f367..c88d7ce29a 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 @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java index c28a4b0049..7189704475 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BungeeInformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java index 45517b6075..fe727442f3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BungeeInformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java index 3ea7361643..0e46347270 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index f03d86e6c7..4ea46a7db7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index f59a7f37db..61d9fb1c51 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java index 51890fa519..f613d8eb4a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BukkitInformationManager; 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 index 525bf7608b..c0e24f40f7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -5,7 +5,11 @@ package com.djrapitops.plan.systems.info; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.*; +import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIConnectionFailException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIFailException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException; import com.djrapitops.plan.command.commands.AnalyzeCommand; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.data.element.InspectContainer; 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 index 3fa12400f9..e803f2613f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException; -import com.djrapitops.plan.api.exceptions.WebAPIException; -import com.djrapitops.plan.api.exceptions.WebAPINotFoundException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIConnectionFailException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; @@ -68,7 +68,7 @@ public BungeeInformationManager(PlanBungee plugin) throws SQLException { * * @throws SQLException If DB Error occurs. */ - private void refreshBukkitServerMap() throws SQLException { + private void refreshBukkitServerMap() { bukkitServers = plugin.getDB().getServerTable().getBukkitServers().stream().collect(Collectors.toMap(ServerInfo::getUuid, Function.identity())); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index 81fcc6bcac..6cf6ab70f6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -61,13 +61,13 @@ public String parse() throws ParseException { } Log.logDebug("Database", "Inspect Parse Fetch"); Benchmark.start("Inspect Parse, Fetch"); - Database db = plugin.getDB(); - PlayerProfile profile = db.getPlayerProfile(uuid); + Database db = Database.getActive(); + PlayerProfile profile = db.fetch().getPlayerProfile(uuid); if (profile == null) { throw new IllegalStateException("Player profile was null!"); } UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); - Map serverNames = db.getServerTable().getServerNames(); + Map serverNames = db.fetch().getServerNames(); Benchmark.stop("Inspect Parse, Fetch"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java index 3da833a584..fa8b6ad5eb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.tables.ServerTable; +import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index 90652893c4..c0ad885dd9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.api.exceptions.WebAPIException; +import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.tables.ServerTable; +import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI; import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plugin.api.TimeAmount; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java index 58506eb42e..0e773927b4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java @@ -1,11 +1,13 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.SQLiteDB; -import com.djrapitops.plan.system.database.tables.move.BatchOperationTable; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; +import com.djrapitops.plan.system.database.databases.sql.tables.move.BatchOperationTable; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; @@ -29,7 +31,7 @@ private ManageUtils() { * @param dbName Name of database (mysql/sqlite) * @param copyFromDB Database you want to backup. */ - public static void backup(String dbName, Database copyFromDB) throws DatabaseInitException, SQLException { + public static void backup(String dbName, Database copyFromDB) throws DBInitException, SQLException { Plan plugin = Plan.getInstance(); String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-"); String fileName = dbName + "-backup-" + timeStamp; @@ -52,9 +54,9 @@ public static void backup(String dbName, Database copyFromDB) throws DatabaseIni public static Collection getUUIDS(Database db) { final Set uuids = new HashSet<>(); try { - uuids.addAll(db.getSavedUUIDs()); - } catch (SQLException e) { - Log.toLog("ManageUtils.getUUIDS", e); + uuids.addAll(db.fetch().getSavedUUIDs()); + } catch (DBException e) { + Log.toLog(ManageUtils.class, e); } return uuids; } @@ -67,15 +69,15 @@ public static Collection getUUIDS(Database db) { * @param copyFromDB Database where data will be copied from */ public static void clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) throws SQLException { - BatchOperationTable toDB = new BatchOperationTable(clearAndCopyToDB); - BatchOperationTable fromDB = new BatchOperationTable(copyFromDB); + BatchOperationTable toDB = new BatchOperationTable((SQLDB) clearAndCopyToDB); + BatchOperationTable fromDB = new BatchOperationTable((SQLDB) copyFromDB); toDB.removeAllData(); fromDB.copyEverything(toDB); } @Deprecated - public static Database getDB(String dbName) throws DatabaseInitException { - return DBSystem.getActiveDatabase(dbName); + public static Database getDB(String dbName) throws DBInitException { + return DBSystem.getInstance().getActiveDatabase(dbName); } } diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index 6e24bc68ab..f7c0848dae 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -6,17 +6,18 @@ package com.djrapitops.plan.system.database; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DatabaseInitException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.MySQLDB; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.databases.SQLiteDB; -import com.djrapitops.plan.system.database.tables.*; +import com.djrapitops.plan.system.database.databases.sql.MySQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; +import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.server.ServerInfo; @@ -89,7 +90,7 @@ public void markFirstSession(UUID uuid) { } @After - public void tearDown() throws IOException, SQLException { + public void tearDown() throws IOException { db.close(); if (backup != null) { backup.close(); @@ -109,7 +110,7 @@ public void tearDown() throws IOException, SQLException { } @Test - public void testInit() throws DatabaseInitException { + public void testInit() throws DBInitException { db.init(); } @@ -143,7 +144,7 @@ public void testMySQLGetName() { } @Test(timeout = 3000) - public void testSaveCommandUse() throws SQLException, DatabaseInitException { + public void testSaveCommandUse() throws SQLException, DBInitException { CommandUseTable commandUseTable = db.getCommandUseTable(); Map expected = new HashMap<>(); @@ -247,7 +248,7 @@ private void saveUserOne() throws SQLException { saveUserOne(db); } - private void saveUserOne(Database database) throws SQLException { + private void saveUserOne(Database database) { database.getUsersTable().registerUser(uuid, 123456789L, "Test"); } @@ -255,7 +256,7 @@ private void saveUserTwo() throws SQLException { saveUserTwo(db); } - private void saveUserTwo(Database database) throws SQLException { + private void saveUserTwo(Database database) { database.getUsersTable().registerUser(uuid2, 123456789L, "Test"); } @@ -274,7 +275,7 @@ public void testActionsTable() throws SQLException { } @Test - public void testIPTable() throws SQLException, DatabaseInitException { + public void testIPTable() throws SQLException, DBInitException { saveUserOne(); IPsTable ipsTable = db.getIpsTable(); @@ -300,7 +301,7 @@ public void testIPTable() throws SQLException, DatabaseInitException { } @Test - public void testNicknamesTable() throws SQLException, DatabaseInitException { + public void testNicknamesTable() throws SQLException, DBInitException { saveUserOne(); NicknamesTable nickTable = db.getNicknamesTable(); @@ -318,7 +319,7 @@ public void testNicknamesTable() throws SQLException, DatabaseInitException { } @Test - public void testSecurityTable() throws SQLException, DatabaseInitException { + public void testSecurityTable() throws SQLException, DBInitException { SecurityTable securityTable = db.getSecurityTable(); WebUser expected = new WebUser("Test", "RandomGarbageBlah", 0); securityTable.addNewUser(expected); @@ -341,7 +342,7 @@ public void testSecurityTable() throws SQLException, DatabaseInitException { } @Test - public void testWorldTable() throws SQLException, DatabaseInitException { + public void testWorldTable() throws SQLException, DBInitException { WorldTable worldTable = db.getWorldTable(); List worlds = Arrays.asList("Test", "Test2", "Test3"); worldTable.saveWorlds(worlds); @@ -356,7 +357,7 @@ private void saveTwoWorlds() throws SQLException { saveTwoWorlds(db); } - private void saveTwoWorlds(Database database) throws SQLException { + private void saveTwoWorlds(Database database) { database.getWorldTable().saveWorlds(worlds); } @@ -381,7 +382,7 @@ private List createKills() { } @Test - public void testSessionPlaytimeSaving() throws SQLException, DatabaseInitException { + public void testSessionPlaytimeSaving() throws SQLException, DBInitException { saveTwoWorlds(); saveUserOne(); saveUserTwo(); @@ -411,7 +412,7 @@ public void testSessionPlaytimeSaving() throws SQLException, DatabaseInitExcepti } @Test - public void testSessionSaving() throws SQLException, DatabaseInitException { + public void testSessionSaving() throws SQLException, DBInitException { saveUserOne(); saveUserTwo(); @@ -452,7 +453,7 @@ public void testSessionSaving() throws SQLException, DatabaseInitException { } @Test - public void testUserInfoTableRegisterUnRegistered() throws SQLException, DatabaseInitException { + public void testUserInfoTableRegisterUnRegistered() throws SQLException, DBInitException { UserInfoTable userInfoTable = db.getUserInfoTable(); assertFalse(userInfoTable.isRegistered(uuid)); UsersTable usersTable = db.getUsersTable(); @@ -476,7 +477,7 @@ public void testUserInfoTableRegisterUnRegistered() throws SQLException, Databas } @Test - public void testUserInfoTableRegisterRegistered() throws SQLException, DatabaseInitException { + public void testUserInfoTableRegisterRegistered() throws SQLException, DBInitException { saveUserOne(); UsersTable usersTable = db.getUsersTable(); assertTrue(usersTable.isRegistered(uuid)); @@ -502,7 +503,7 @@ public void testUserInfoTableRegisterRegistered() throws SQLException, DatabaseI } @Test - public void testUserInfoTableUpdateBannedOpped() throws SQLException, DatabaseInitException { + public void testUserInfoTableUpdateBannedOpped() throws SQLException, DBInitException { UserInfoTable userInfoTable = db.getUserInfoTable(); userInfoTable.registerUserInfo(uuid, 223456789L); assertTrue(userInfoTable.isRegistered(uuid)); @@ -532,7 +533,7 @@ public void testUserInfoTableUpdateBannedOpped() throws SQLException, DatabaseIn } @Test - public void testUsersTableUpdateName() throws SQLException, DatabaseInitException { + public void testUsersTableUpdateName() throws SQLException, DBInitException { saveUserOne(); UsersTable usersTable = db.getUsersTable(); @@ -549,7 +550,7 @@ public void testUsersTableUpdateName() throws SQLException, DatabaseInitExceptio } @Test - public void testUsersTableKickSaving() throws SQLException, DatabaseInitException { + public void testUsersTableKickSaving() throws SQLException, DBInitException { saveUserOne(); UsersTable usersTable = db.getUsersTable(); assertEquals(0, usersTable.getTimesKicked(uuid)); @@ -564,7 +565,7 @@ public void testUsersTableKickSaving() throws SQLException, DatabaseInitExceptio } @Test - public void testRemovalSingleUser() throws SQLException { + public void testRemovalSingleUser() throws SQLException, DBException { saveUserTwo(); UserInfoTable userInfoTable = db.getUserInfoTable(); @@ -589,7 +590,7 @@ public void testRemovalSingleUser() throws SQLException { assertTrue(usersTable.isRegistered(uuid)); - db.removeAccount(uuid); + db.remove().player(uuid); assertFalse(usersTable.isRegistered(uuid)); assertFalse(userInfoTable.isRegistered(uuid)); @@ -600,7 +601,7 @@ public void testRemovalSingleUser() throws SQLException { } @Test - public void testRemovalEverything() throws SQLException { + public void testRemovalEverything() throws SQLException, DBException { UserInfoTable userInfoTable = db.getUserInfoTable(); UsersTable usersTable = db.getUsersTable(); SessionsTable sessionsTable = db.getSessionsTable(); @@ -612,7 +613,7 @@ public void testRemovalEverything() throws SQLException { saveAllData(db); - db.removeAllData(); + db.remove().everything(); assertFalse(usersTable.isRegistered(uuid)); assertFalse(usersTable.isRegistered(uuid2)); @@ -687,7 +688,7 @@ private void saveAllData(Database database) throws SQLException { } @Test - public void testServerTableBungeeSave() throws SQLException, DatabaseInitException { + public void testServerTableBungeeSave() throws SQLException, DBInitException { ServerTable serverTable = db.getServerTable(); Optional bungeeInfo = serverTable.getBungeeInfo(); @@ -711,7 +712,7 @@ public void testServerTableBungeeSave() throws SQLException, DatabaseInitExcepti } @Test - public void testServerTableBungee() throws SQLException, DatabaseInitException { + public void testServerTableBungee() throws SQLException, DBInitException { testServerTableBungeeSave(); ServerTable serverTable = db.getServerTable(); @@ -720,18 +721,18 @@ public void testServerTableBungee() throws SQLException, DatabaseInitException { } @Test - public void testSessionTableNPEWhenNoPlayers() throws SQLException { + public void testSessionTableNPEWhenNoPlayers() { Map lastSeen = db.getSessionsTable().getLastSeenForAllPlayers(); assertTrue(lastSeen.isEmpty()); } - private void commitTest() throws DatabaseInitException, SQLException { + private void commitTest() throws DBInitException { db.close(); db.init(); } @Test - public void testSessionTableGetInfoOfServer() throws SQLException, DatabaseInitException { + public void testSessionTableGetInfoOfServer() throws SQLException, DBInitException { saveUserOne(); saveUserTwo(); @@ -758,7 +759,7 @@ public void testSessionTableGetInfoOfServer() throws SQLException, DatabaseInitE } @Test - public void testKillTableGetKillsOfServer() throws SQLException, DatabaseInitException { + public void testKillTableGetKillsOfServer() throws SQLException, DBInitException { saveUserOne(); saveUserTwo(); @@ -777,7 +778,7 @@ public void testKillTableGetKillsOfServer() throws SQLException, DatabaseInitExc } @Test - public void testBackupAndRestore() throws SQLException, DatabaseInitException { + public void testBackupAndRestore() throws SQLException, DBInitException { SQLiteDB backup = new SQLiteDB("debug-backup" + MiscUtils.getTime()); backup.init(); @@ -872,7 +873,7 @@ public void testSaveSessionsWorldTimes() throws SQLException { } @Test - public void testRegisterProcessorRegisterException() throws SQLException { + public void testRegisterProcessorRegisterException() { assertFalse(db.getUsersTable().isRegistered(uuid)); assertFalse(db.getUserInfoTable().isRegistered(uuid)); for (int i = 0; i < 200; i++) { @@ -883,7 +884,7 @@ public void testRegisterProcessorRegisterException() throws SQLException { } @Test - public void testWorldTableGetWorldNamesNoException() throws SQLException { + public void testWorldTableGetWorldNamesNoException() { Set worldNames = db.getWorldTable().getWorldNames(); } } diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java similarity index 82% rename from Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java rename to Plan/test/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java index eed5686fae..52596db011 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/tables/ActionsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.database.tables; +package com.djrapitops.plan.system.database.databases.sql.tables; import com.djrapitops.plan.data.Actions; import org.junit.Test; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index 304a76cbac..7f565b9423 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -6,9 +6,9 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.database.databases.SQLDB; -import com.djrapitops.plan.system.database.databases.SQLiteDB; -import com.djrapitops.plan.system.database.tables.UsersTable; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; +import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.command.ISender; From 15c6e1717340804f8ece1c2e96dc0ddbac402e09 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 14 Jan 2018 21:31:31 +0200 Subject: [PATCH 017/166] Finished basic responses for ResponseHandler --- .../commands/manage/ManageClearCommand.java | 7 +- .../databases/operation/FetchOperations.java | 3 + .../system/database/databases/sql/SQLDB.java | 4 + .../sql/{ => operation}/SQLBackupOps.java | 3 +- .../sql/{ => operation}/SQLCheckOps.java | 4 +- .../sql/{ => operation}/SQLFetchOps.java | 13 +- .../databases/sql/{ => operation}/SQLOps.java | 3 +- .../sql/{ => operation}/SQLRemoveOps.java | 8 +- .../system/webserver/APIRequestHandler.java | 54 ------ .../system/webserver/APIResponseHandler.java | 167 ---------------- .../plan/system/webserver/RequestHandler.java | 3 + .../system/webserver/ResponseHandler.java | 183 ++++-------------- .../plan/system/webserver/WebServer.java | 42 ++-- .../system/webserver/WebServerSystem.java | 5 +- .../system/webserver/auth/Authentication.java | 3 +- .../webserver/pages/DebugPageHandler.java | 9 + .../system/webserver/pages/PageHandler.java | 16 +- .../webserver/pages/PlayerPageHandler.java | 47 +++-- .../webserver/pages/PlayersPageHandler.java | 11 +- .../webserver/pages/RootPageHandler.java | 64 ++++++ .../webserver/pages/ServerPageHandler.java | 39 +++- .../webserver/pages/TreePageHandler.java | 16 +- .../response/PromptAuthorizationResponse.java | 14 +- .../errors/InternalErrorResponse.java | 7 +- 24 files changed, 281 insertions(+), 444 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/{ => operation}/SQLBackupOps.java (76%) rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/{ => operation}/SQLCheckOps.java (85%) rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/{ => operation}/SQLFetchOps.java (87%) rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/{ => operation}/SQLOps.java (91%) rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/{ => operation}/SQLRemoveOps.java (87%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index dcefe343a2..311673208b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -3,6 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBInitException; +import com.djrapitops.plan.api.exceptions.database.FatalDBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; @@ -95,9 +96,13 @@ public void run() { new Session(now, player.getWorld().getName(), player.getGameMode().name())) ); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString()); + } catch (FatalDBException e) { + sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString() + + " Error was fatal, so all information may not have been removed."); + Log.toLog(this.getClass(), e); } catch (DBException e) { sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); - Log.toLog(this.getClass().getSimpleName() + "/" + this.getTaskName(), e); + Log.toLog(this.getClass(), e); } finally { this.cancel(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index af75bc269b..18099e2c9f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -5,6 +5,7 @@ import com.djrapitops.plan.data.ServerProfile; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -19,4 +20,6 @@ public interface FetchOperations { Set getSavedUUIDs(UUID server) throws DBException; Map getServerNames() throws DBException; + + Optional getServerUUID(String serverName) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 1136281a64..0e1c2ddb87 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -9,6 +9,10 @@ import com.djrapitops.plan.system.database.databases.operation.CheckOperations; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; +import com.djrapitops.plan.system.database.databases.sql.operation.SQLBackupOps; +import com.djrapitops.plan.system.database.databases.sql.operation.SQLCheckOps; +import com.djrapitops.plan.system.database.databases.sql.operation.SQLFetchOps; +import com.djrapitops.plan.system.database.databases.sql.operation.SQLRemoveOps; import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.database.databases.sql.tables.move.Version8TransferTable; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLBackupOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLBackupOps.java similarity index 76% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLBackupOps.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLBackupOps.java index 87a02138fc..f60f7c46d4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLBackupOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLBackupOps.java @@ -1,7 +1,8 @@ -package com.djrapitops.plan.system.database.databases.sql; +package com.djrapitops.plan.system.database.databases.sql.operation; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.operation.BackupOperations; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; public class SQLBackupOps implements BackupOperations { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLCheckOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java similarity index 85% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLCheckOps.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java index efa912c6f4..e8ed8518c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLCheckOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java @@ -1,7 +1,9 @@ -package com.djrapitops.plan.system.database.databases.sql; +package com.djrapitops.plan.system.database.databases.sql.operation; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.CheckOperations; +import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; import java.sql.SQLException; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java similarity index 87% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLFetchOps.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index 1957e421a1..c901f741e0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.database.databases.sql; +package com.djrapitops.plan.system.database.databases.sql.operation; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; @@ -6,6 +6,8 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; +import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; import java.sql.SQLException; import java.util.*; @@ -97,4 +99,13 @@ public Map getServerNames() throws DBException { throw ErrorUtil.getExceptionFor(e); } } + + @Override + public Optional getServerUUID(String serverName) throws DBException { + try { + return serverTable.getServerUUID(serverName); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLOps.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java index 9abd83bfd4..62d7655755 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java @@ -1,5 +1,6 @@ -package com.djrapitops.plan.system.database.databases.sql; +package com.djrapitops.plan.system.database.databases.sql.operation; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; public class SQLOps { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLRemoveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java similarity index 87% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLRemoveOps.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java index e78504cadd..b3905dfce4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLRemoveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java @@ -1,8 +1,10 @@ -package com.djrapitops.plan.system.database.databases.sql; +package com.djrapitops.plan.system.database.databases.sql.operation; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.FatalDBException; import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; +import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.tables.Table; import com.djrapitops.plan.system.database.databases.sql.tables.UserIDTable; import com.djrapitops.plugin.api.Benchmark; @@ -59,7 +61,7 @@ public void everything() throws DBException { table.removeAllData(); } } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw ErrorUtil.getFatalExceptionFor(e); } } @@ -68,7 +70,7 @@ public void webUser(String userName) throws DBException { try { securityTable.removeUser(userName); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw ErrorUtil.getFatalExceptionFor(e); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java deleted file mode 100644 index 87f8c05976..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIRequestHandler.java +++ /dev/null @@ -1,54 +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.system.webserver; - -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPIManager; -import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.utility.log.Log; -import com.sun.net.httpserver.Headers; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; - -/** - * HttpHandler for webserver request management. - * - * @author Rsl1122 - */ -public class APIRequestHandler implements HttpHandler { - - private final APIResponseHandler responseHandler; - - APIRequestHandler(WebAPIManager webAPI) { - responseHandler = new APIResponseHandler(webAPI); - } - - @Override - public void handle(HttpExchange exchange) { - Headers responseHeaders = exchange.getResponseHeaders(); - Request request = new Request(exchange); - String requestString = request.toString(); - Benchmark.start("", requestString); - int responseCode = -1; - try { - Response response = responseHandler.getAPIResponse(request); - responseCode = response.getCode(); - response.setResponseHeaders(responseHeaders); - response.send(exchange); - } catch (Exception e) { - if (Settings.DEV_MODE.isTrue()) { - Log.toLog(this.getClass().getName(), e); - } - } finally { - exchange.close(); - if (Settings.DEV_MODE.isTrue()) { - Log.debug(requestString + " Response code: " + responseCode + " took " + Benchmark.stop("", requestString) + " ms"); - } - } - } - - -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java deleted file mode 100644 index 6c2e4632ce..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/APIResponseHandler.java +++ /dev/null @@ -1,167 +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.system.webserver; - -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; -import com.djrapitops.plan.system.webserver.response.CSSResponse; -import com.djrapitops.plan.system.webserver.response.JavaScriptResponse; -import com.djrapitops.plan.system.webserver.response.RedirectResponse; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; -import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; -import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; -import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.system.webserver.webapi.WebAPIManager; -import com.djrapitops.plan.utilities.html.Html; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * Handles choosing of the correct API response to an API request. - * - * @author Rsl1122 - */ -public class APIResponseHandler { - - private final WebAPIManager webAPI; - - public APIResponseHandler(WebAPIManager webAPI) { - this.webAPI = webAPI; - } - - Response getAPIResponse(Request request) throws IOException { - String target = request.getTarget(); - String[] args = target.split("/"); - - if ("/favicon.ico".equalsIgnoreCase(target)) { - return ResponseCache.loadResponse(PageId.FAVICON_REDIRECT.id(), () -> new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); - } - if ("/debug".equalsIgnoreCase(target)) { - return new DebugPageResponse(); - } - if (target.endsWith(".css")) { - return ResponseCache.loadResponse(PageId.CSS.of(target), () -> new CSSResponse(target)); - } - - if (target.endsWith(".js")) { - return ResponseCache.loadResponse(PageId.JS.of(target), () -> new JavaScriptResponse(target)); - } - - if (args.length < 2 || !"api".equals(args[1])) { - String address = PlanPlugin.getInstance().getInfoManager().getWebServerAddress() + target; - String link = Html.LINK.parse(address, address); - return ResponseCache.loadResponse(PageId.ERROR.of("Non-API Request"), () -> new NotFoundResponse("WebServer is in WebAPI-only mode, " + - "connect to the Bungee server instead: " + link)); - } - - if (args.length < 3) { - String error = "API Method not specified"; - return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); - } - - String method = args[2]; - String requestBody; - try (InputStream inputStream = request.getRequestBody()) { - requestBody = readPOSTRequest(inputStream); - } - - if (requestBody == null) { - String error = "Error at reading the POST request." + - "Note that the Encoding must be ISO-8859-1."; - return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); - } - - Map variables = WebAPI.readVariables(requestBody); - String sender = variables.get("sender"); - Log.debug("Received WebAPI Request" + target + " from " + sender); - - boolean isPing = "pingwebapi".equalsIgnoreCase(method); - boolean isSetupRequest = "requestsetupwebapi".equalsIgnoreCase(method); - boolean isPostOriginalSettings = "postoriginalbukkitsettingswebapi".equalsIgnoreCase(method); - boolean skipAuthCheck = isPing || isSetupRequest || isPostOriginalSettings; - - // TODO refactor to more methods - if (!skipAuthCheck) { - String accessKey = variables.get("accessKey"); - if (accessKey == null) { - if (!checkKey(sender)) { - String error = "Server Key not given or invalid"; - Log.debug("Request had invalid Server key: " + sender); - return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> { - ForbiddenResponse forbidden = new ForbiddenResponse(); - forbidden.setContent(error); - return forbidden; - }); - } - } else { - if (!webAPI.isAuthorized(accessKey)) { - String error = "Access Key invalid"; - Log.debug("Request had invalid Access key: " + accessKey); - return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> { - ForbiddenResponse forbidden = new ForbiddenResponse(); - forbidden.setContent(error); - return forbidden; - }); - } - } - } - - WebAPI api = webAPI.getAPI(method); - - if (api == null) { - String error = "API Method not found"; - Log.debug(error); - return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); - } - - Response response = api.processRequest(PlanPlugin.getInstance(), variables); - - Log.debug("Response: " + response.getResponse().split("\r\n")[0]); - - return response; - } - - private String readPOSTRequest(InputStream in) throws IOException { - byte[] bytes; - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buf = new byte[4096]; - for (int n = in.read(buf); n > 0; n = in.read(buf)) { - out.write(buf, 0, n); - } - - bytes = out.toByteArray(); - - try { - return new String(bytes, StandardCharsets.ISO_8859_1); - } catch (Exception e) { - return null; - } - } - - private boolean checkKey(String sender) { - if (sender == null) { - return false; - } - - try { - List uuids = PlanPlugin.getInstance().getDB().getServerTable().getServerUUIDs(); - UUID keyUUID = UUID.fromString(sender); - return uuids.contains(keyUUID); - } catch (SQLException | IllegalArgumentException e) { - return false; - } - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java index 885ff36184..73326d38d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java @@ -75,4 +75,7 @@ private Authentication getAuthorization(Headers requestHeaders) { return null; } + public ResponseHandler getResponseHandler() { + return responseHandler; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index d353acc106..6b92e9f13a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -4,9 +4,7 @@ */ package com.djrapitops.plan.system.webserver; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebUserAuthException; -import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; @@ -14,17 +12,11 @@ import com.djrapitops.plan.system.webserver.response.*; import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; -import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; -import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; -import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse; -import com.djrapitops.plan.system.webserver.response.pages.PlayersPageResponse; -import com.djrapitops.plan.systems.webserver.response.*; import com.djrapitops.plugin.api.utility.log.Log; import java.util.Arrays; import java.util.List; import java.util.Optional; -import java.util.UUID; /** * Handles choosing of the correct response to a request. @@ -34,7 +26,6 @@ public class ResponseHandler extends TreePageHandler { private final boolean authRequired; - private final boolean usingHttps; public ResponseHandler(WebServer webServer) { @@ -43,7 +34,7 @@ public ResponseHandler(WebServer webServer) { } public void registerDefaultPages() { - registerPage("favicon.ico", new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); + registerPage("favicon.ico", new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico"), 5); registerPage("debug", new DebugPageHandler()); registerPage("players", new PlayersPageHandler()); registerPage("player", new PlayerPageHandler()); @@ -51,10 +42,35 @@ public void registerDefaultPages() { ServerPageHandler serverPageHandler = new ServerPageHandler(); registerPage("network", serverPageHandler); registerPage("server", serverPageHandler); + if (authRequired) { + registerPage("", new RootPageHandler(this)); + } } public void registerWebAPIPages() { - +// TODO WebAPIPageHandler +// private void registerWebAPIs() { +// webAPI.registerNewAPI( +// new AnalysisReadyWebAPI(), +// new AnalyzeWebAPI(), +// new ConfigurationWebAPI(), +// new InspectWebAPI(), +// new IsOnlineWebAPI(), +// new RequestInspectPluginsTabBukkitWebAPI(), +// new PingWebAPI() +// ); +// +// webAPI.registerNewAPI( +// new IsCachedWebAPI(), +// new PostHtmlWebAPI(), +// new PostInspectPluginsTabWebAPI(), +// new PostNetworkPageContentWebAPI(), +// new PostOriginalBukkitSettingsWebAPI(), +// new RequestPluginsTabWebAPI(), +// new RequestSetupWebAPI() +// ); +// } + //Log.infoColor("§aWebServer Running in WebAPI-only Mode"); } public Response getResponse(Request request) { @@ -65,12 +81,12 @@ public Response getResponse(Request request) { Optional authentication = Optional.empty(); if (authRequired) { authentication = request.getAuth(); - if (!authentication.isPresent() && usingHttps) { - return DefaultResponses.BASIC_AUTH.get(); - } - - if (authentication.isPresent() && !authentication.get().isAuthorized(null)) { - return forbiddenResponse(0, 0); + if (!authentication.isPresent()) { + if (usingHttps) { + return DefaultResponses.BASIC_AUTH.get(); + } else { + return forbiddenResponse(0, 0); + } } } @@ -84,7 +100,7 @@ public Response getResponse(Request request) { } return DefaultResponses.NOT_FOUND.get(); } else { - if (authentication.isPresent() && authentication.get().isAuthorized(pageHandler.getPermission())) { + if (authentication.isPresent() && pageHandler.isAuthorized(authentication.get(), target)) { return forbiddenResponse(0, 0); } return pageHandler.getResponse(request, target); @@ -93,142 +109,15 @@ public Response getResponse(Request request) { return PromptAuthorizationResponse.getBasicAuthResponse(e); } catch (Exception e) { Log.toLog(this.getClass().getName(), e); - return new InternalErrorResponse(e, request.getTarget()); - } - - try { - if ("/favicon.ico".equals(targetString)) { - return ResponseCache.loadResponse(PageId.FAVICON_REDIRECT.id(), () -> new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico")); - } - if (request.isAPIRequest()) { - return getAPIResponse(request); - } - - - UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); - - if (usingHttps) { - if (!request.hasAuth()) { - throw new WebUserAuthException("No Authorization"); - } - - WebUser user = getUser(request.getAuth()); - int required = getRequiredPermLevel(targetString, user.getName()); - int permLevel = user.getPermLevel(); - - if (!isAuthorized(required, permLevel)) { - return forbiddenResponse(required, permLevel); - } - if (args.length < 2) { - return rootPageResponse(user, serverUUID); - } - } else if (args.length < 2) { - return notFoundResponse(); - } - - String page = args[1]; - switch (page) { - case "debug": - return new DebugPageResponse(); - case "players": - return ResponseCache.loadResponse(PageId.PLAYERS.id(), PlayersPageResponse::new); - case "player": - return playerResponse(args); - case "network": - case "server": - if (args.length > 2) { - try { - Optional serverUUIDOptional = PlanPlugin.getInstance().getDB().getServerTable().getServerUUID(args[2].replace("%20", " ")); - if (serverUUIDOptional.isPresent()) { - serverUUID = serverUUIDOptional.get(); - } - } catch (IllegalArgumentException ignore) { - /*ignored*/ - } - } - return serverResponse(serverUUID); - default: - return notFoundResponse(); - } - - } catch (WebUserAuthException e) { - return ResponseCache.loadResponse(PageId.AUTH_PROMPT.id(), PromptAuthorizationResponse::getBasicAuthResponse); - } catch (Exception e) { - Log.toLog(this.getClass().getName(), e); - return new InternalErrorResponse(e, request.getTarget()); + return new InternalErrorResponse(request.getTarget(), e); } } - private Response forbiddenResponse(int required, int permLevel) { + public Response forbiddenResponse(int required, int permLevel) { return ResponseCache.loadResponse(PageId.FORBIDDEN.of(required + "/" + permLevel), () -> new ForbiddenResponse("Unauthorized User.
" + "Make sure your user has the correct access level.
" + "This page requires permission level of " + required + ",
" + "This user has permission level of " + permLevel)); } - - private boolean isAuthorized(int requiredPermLevel, int permLevel) { - return permLevel <= requiredPermLevel; - } - - private int getRequiredPermLevel(String target, String user) { - String[] t = target.split("/"); - if (t.length < 2) { - return 100; - } - if (t.length > 3) { - return 0; - } - String page = t[1]; - switch (page) { - case "players": - return 1; - case "player": - // /player/ - 404 for perm lvl 1 - if (t.length < 3) { - return 1; - } - - final String wantedUser = t[2].toLowerCase().trim(); - final String theUser = user.trim().toLowerCase(); - - return wantedUser.equals(theUser) ? 2 : 1; - default: - return 0; - } - } - - private Response rootPageResponse(WebUser user, UUID serverUUID) { - if (user == null) { - return notFoundResponse(); - } - - switch (user.getPermLevel()) { - case 0: - return serverResponse(serverUUID); - case 1: - return ResponseCache.loadResponse(PageId.PLAYERS.id(), PlayersPageResponse::new); - case 2: - return playerResponse(new String[]{"", "", user.getName()}); - default: - return forbiddenResponse(user.getPermLevel(), 0); - } - } - - private Response serverResponse(UUID serverUUID) { - return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(plugin.getInfoManager())); - } - - private Response notFoundResponse() { - String error = "404 Not Found"; - return ResponseCache.loadResponse(PageId.NOT_FOUND.of("Wrong Page"), () -> { - String url = plugin.getInfoManager().getWebServerAddress(); - return new NotFoundResponse("Make sure you're accessing a link given by a command, Examples:

" - + "

" + url + "/player/Playername
" + - url + "/server

"); - } - ); - } - - } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index 4a18fc6b59..71197d95a7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -40,15 +40,19 @@ public class WebServer implements SubSystem { private boolean usingHttps = false; + private RequestHandler requestHandler; + private ResponseHandler responseHandler; + @Override public void enable() { this.port = Settings.WEBSERVER_PORT.getNumber(); PlanPlugin plugin = PlanPlugin.getInstance(); - StaticHolder.saveInstance(APIRequestHandler.class, plugin.getClass()); StaticHolder.saveInstance(RequestHandler.class, plugin.getClass()); StaticHolder.saveInstance(ResponseHandler.class, plugin.getClass()); - StaticHolder.saveInstance(APIResponseHandler.class, plugin.getClass()); + + requestHandler = new RequestHandler(this); + responseHandler = requestHandler.getResponseHandler(); initServer(); } @@ -58,30 +62,6 @@ public void disable() { stop(); } - // TODO WebAPIPageHandler -// private void registerWebAPIs() { -// webAPI.registerNewAPI( -// new AnalysisReadyWebAPI(), -// new AnalyzeWebAPI(), -// new ConfigurationWebAPI(), -// new InspectWebAPI(), -// new IsOnlineWebAPI(), -// new RequestInspectPluginsTabBukkitWebAPI(), -// new PingWebAPI() -// ); -// -// webAPI.registerNewAPI( -// new IsCachedWebAPI(), -// new PostHtmlWebAPI(), -// new PostInspectPluginsTabWebAPI(), -// new PostNetworkPageContentWebAPI(), -// new PostOriginalBukkitSettingsWebAPI(), -// new RequestPluginsTabWebAPI(), -// new RequestSetupWebAPI() -// ); -// } - //Log.infoColor("§aWebServer Running in WebAPI-only Mode"); - /** * Starts up the WebServer in a new Thread Pool. */ @@ -107,7 +87,7 @@ public void initServer() { server = HttpServer.create(new InetSocketAddress(Settings.WEBSERVER_IP.toString(), port), 10); } - server.createContext("/", new RequestHandler(this)); + server.createContext("/", requestHandler); server.setExecutor(new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100))); server.start(); @@ -213,4 +193,12 @@ public boolean isAuthRequired() { public String getAccessAddress() { return isEnabled() ? getProtocol() + "://" + HtmlUtils.getIP() : Settings.EXTERNAL_WEBSERVER_LINK.toString(); } + + public RequestHandler getRequestHandler() { + return requestHandler; + } + + public ResponseHandler getResponseHandler() { + return responseHandler; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java index b581b5fde9..014b95b784 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java @@ -28,11 +28,14 @@ public static WebServerSystem getInstance() { @Override public void enable() throws EnableException { - webServer = new WebServer(PlanPlugin.getInstance()); + webServer = new WebServer(); webServer.initServer(); if (Check.isBungeeAvailable() && !webServer.isEnabled()) { throw new EnableException("WebServer did not initialize!"); } + ResponseHandler responseHandler = webServer.getResponseHandler(); + responseHandler.registerWebAPIPages(); + responseHandler.registerDefaultPages(); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java index 55a459c106..6e509c03ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.webserver.auth; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.data.WebUser; /** * //TODO Class Javadoc Comment @@ -13,6 +14,6 @@ */ public interface Authentication { - boolean isAuthorized(String permission) throws WebUserAuthException; + WebUser getWebUser() throws WebUserAuthException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java index 785d85acbb..f37386b72f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java @@ -4,7 +4,10 @@ */ package com.djrapitops.plan.system.webserver.pages; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.pages.DebugPageResponse; @@ -21,4 +24,10 @@ public class DebugPageHandler extends PageHandler { public Response getResponse(Request request, List target) { return new DebugPageResponse(); } + + @Override + public boolean isAuthorized(Authentication auth, List target) throws WebUserAuthException { + WebUser webUser = auth.getWebUser(); + return webUser.getPermLevel() == 0; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java index a87d788a67..3a8d80ee35 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java @@ -4,7 +4,9 @@ */ package com.djrapitops.plan.system.webserver.pages; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.response.Response; import java.util.List; @@ -16,11 +18,17 @@ */ public abstract class PageHandler { - protected String permission = "*"; - + /** + * Get the Response of a PageHandler. + * + * @param request Request in case it is useful for choosing page. + * @param target Rest of the target coordinates after this page has been solved. + * @return Response appropriate to the PageHandler. + */ public abstract Response getResponse(Request request, List target); - public String getPermission() { - return permission; + public boolean isAuthorized(Authentication auth, List target) throws WebUserAuthException { + return true; } + } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java index 3fd888cc6e..2c41f40848 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java @@ -6,8 +6,12 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.response.Response; @@ -15,6 +19,7 @@ import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import com.djrapitops.plan.utilities.uuid.UUIDUtility; +import com.djrapitops.plugin.api.utility.log.Log; import java.util.List; import java.util.UUID; @@ -26,10 +31,6 @@ */ public class PlayerPageHandler extends PageHandler { - public PlayerPageHandler() { - permission = "special_player"; - } - @Override public Response getResponse(Request request, List target) { if (target.isEmpty()) { @@ -43,21 +44,25 @@ public Response getResponse(Request request, List target) { return notFound("Player has no UUID"); } - if (Database.getActive().check().isPlayerRegistered(uuid)) { - PlanPlugin.getInstance().getInfoManager().cachePlayer(uuid); - Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); - // TODO Create a new method that places NotFoundResponse to ResponseCache instead. - if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) { - ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> { - try { - return new InspectPageResponse(PlanPlugin.getInstance().getInfoManager(), uuid); - } catch (ParseException e) { - return new InternalErrorResponse(e, this.getClass().getName()); - } - }); - response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); + try { + if (Database.getActive().check().isPlayerRegistered(uuid)) { + PlanPlugin.getInstance().getInfoManager().cachePlayer(uuid); + Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); + // TODO Create a new method that places NotFoundResponse to ResponseCache instead. + if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) { + ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> { + try { + return new InspectPageResponse(PlanPlugin.getInstance().getInfoManager(), uuid); + } catch (ParseException e) { + return new InternalErrorResponse(e, this.getClass().getName()); + } + }); + response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); + } + return response; } - return response; + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); } return notFound("Player has not played on this server."); } @@ -65,4 +70,10 @@ public Response getResponse(Request request, List target) { private Response notFound(String error) { return ResponseCache.loadResponse(PageId.NOT_FOUND.of(error), () -> new NotFoundResponse(error)); } + + @Override + public boolean isAuthorized(Authentication auth, List target) throws WebUserAuthException { + WebUser webUser = auth.getWebUser(); + return webUser.getPermLevel() <= 1 || webUser.getName().equalsIgnoreCase(target.get(target.size() - 1)); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java index 9104b12f40..14ed1809f7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java @@ -4,7 +4,9 @@ */ package com.djrapitops.plan.system.webserver.pages; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.response.Response; @@ -19,12 +21,13 @@ */ public class PlayersPageHandler extends PageHandler { - public PlayersPageHandler() { - permission = "players"; - } - @Override public Response getResponse(Request request, List target) { return ResponseCache.loadResponse(PageId.PLAYERS.id(), PlayersPageResponse::new); } + + @Override + public boolean isAuthorized(Authentication auth, List target) throws WebUserAuthException { + return auth.getWebUser().getPermLevel() <= 1; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java new file mode 100644 index 0000000000..cdae932fe5 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java @@ -0,0 +1,64 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.data.WebUser; +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.ResponseHandler; +import com.djrapitops.plan.system.webserver.auth.Authentication; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class RootPageHandler extends PageHandler { + + private final ResponseHandler responseHandler; + + public RootPageHandler(ResponseHandler responseHandler) { + this.responseHandler = responseHandler; + } + + @Override + public Response getResponse(Request request, List target) { + Optional auth = request.getAuth(); + if (!auth.isPresent()) { + return DefaultResponses.BASIC_AUTH.get(); + } + + try { + WebUser webUser = auth.get().getWebUser(); + + int permLevel = webUser.getPermLevel(); + switch (permLevel) { + case 0: + return responseHandler.getPageHandler("server").getResponse(request, Collections.emptyList()); + case 1: + return responseHandler.getPageHandler("players").getResponse(request, Collections.emptyList()); + case 2: + return responseHandler.getPageHandler("player").getResponse(request, Collections.singletonList(webUser.getName())); + default: + return responseHandler.forbiddenResponse(permLevel, 0); + } + } catch (WebUserAuthException e) { + Log.toLog(this.getClass(), e); + return new InternalErrorResponse("/", e); + } + } + + @Override + public boolean isAuthorized(Authentication auth, List target) { + return true; + } +} \ No newline at end of file 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 f4af237c3c..e8218710ad 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 @@ -4,24 +4,53 @@ */ package com.djrapitops.plan.system.webserver.pages; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.auth.Authentication; +import com.djrapitops.plan.system.webserver.pagecache.PageId; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; import java.util.List; +import java.util.Optional; +import java.util.UUID; /** - * //TODO Class Javadoc Comment + * PageHandler for /server and /network pages. * * @author Rsl1122 */ public class ServerPageHandler extends PageHandler { - public ServerPageHandler() { - permission = "server"; + @Override + public Response getResponse(Request request, List target) { + UUID serverUUID = getServerUUID(target); + return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), + () -> new AnalysisPageResponse(PlanPlugin.getInstance().getInfoManager()) + ); + } + + private UUID getServerUUID(List target) { + UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); + if (!target.isEmpty()) { + try { + String serverName = target.get(0).replace("%20", " "); + Optional serverUUIDOptional = Database.getActive().fetch().getServerUUID(serverName); + if (serverUUIDOptional.isPresent()) { + serverUUID = serverUUIDOptional.get(); + } + } catch (IllegalArgumentException ignore) { + /*ignored*/ + } + } + return serverUUID; } @Override - public Response getResponse(Request request, List target) { - return null; + public boolean isAuthorized(Authentication auth, List target) throws WebUserAuthException { + return auth.getWebUser().getPermLevel() <= 0; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java index b647094e02..9bd17f77d3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java @@ -4,7 +4,9 @@ */ package com.djrapitops.plan.system.webserver.pages; +import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.response.Response; import java.util.HashMap; @@ -28,12 +30,17 @@ public void registerPage(String targetPage, PageHandler handler) { pages.put(targetPage, handler); } - public void registerPage(String targetPage, Response response) { + public void registerPage(String targetPage, Response response, int requiredPerm) { pages.put(targetPage, new PageHandler() { @Override public Response getResponse(Request request, List target) { return response; } + + @Override + public boolean isAuthorized(Authentication auth, List target) throws WebUserAuthException { + return auth.getWebUser().getPermLevel() <= requiredPerm; + } }); } @@ -46,8 +53,15 @@ public Response getResponse(Request request, List target) { } public PageHandler getPageHandler(List target) { + if (target.isEmpty()) { + return pages.get(""); + } String targetPage = target.get(0); target.remove(0); return pages.get(targetPage); } + + public PageHandler getPageHandler(String targetPage) { + return pages.get(targetPage); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java index eb84815203..dbd93bfee3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/PromptAuthorizationResponse.java @@ -12,6 +12,11 @@ */ public class PromptAuthorizationResponse extends ErrorResponse { + private static final String TIPS = "
- Ensure you have registered a user with /plan register
" + + "- Check that the username and password are correct
" + + "- Username and password are case-sensitive
" + + "
If you have forgotten your password, ask a staff member to delete your old user and re-register."; + private PromptAuthorizationResponse() { super.setTitle(Html.FONT_AWESOME_ICON.parse("lock") + " 401 Unauthorized"); } @@ -20,11 +25,8 @@ public static PromptAuthorizationResponse getBasicAuthResponse() { PromptAuthorizationResponse response = new PromptAuthorizationResponse(); response.setHeader("HTTP/1.1 401 Access Denied\r\n" + "WWW-Authenticate: Basic realm=\"/\";"); - response.setParagraph("Authentication Failed.
" - + "- Ensure you have registered a user with /plan register
" - + "- Check that the username and password are correct
" - + "- Username and password are case-sensitive
" - + "
If you have forgotten your password, ask a staff member to delete your old user and re-register."); + + response.setParagraph("Authentication Failed." + TIPS); response.replacePlaceholders(); return response; } @@ -47,7 +49,7 @@ public static PromptAuthorizationResponse getBasicAuthResponse(WebUserAuthExcept reason += errorBuilder.toString(); } - response.setParagraph("Authentication Failed.
Reason: " + reason); + response.setParagraph("Authentication Failed.
Reason: " + reason + TIPS); response.replacePlaceholders(); return response; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/InternalErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/InternalErrorResponse.java index e9cf480e47..7ec3e6e1a8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/InternalErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/InternalErrorResponse.java @@ -8,7 +8,7 @@ */ public class InternalErrorResponse extends ErrorResponse { - public InternalErrorResponse(Throwable e, String cause) { + public InternalErrorResponse(String cause, Throwable e) { super.setHeader("HTTP/1.1 500 Internal Error"); super.setTitle(Html.FONT_AWESOME_ICON.parse("bug") + " 500 Internal Error occurred"); @@ -33,6 +33,11 @@ public InternalErrorResponse(Throwable e, String cause) { super.replacePlaceholders(); } + @Deprecated + public InternalErrorResponse(Throwable e, String cause) { + this(cause, e); + } + private void appendCause(Throwable cause, StringBuilder paragraph) { paragraph.append("
Caused by: ").append(cause); for (StackTraceElement element : cause.getStackTrace()) { From 0aed988e22ed325d6e1bc70fef6abf3de36e210d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 14 Jan 2018 21:41:51 +0200 Subject: [PATCH 018/166] Removed some redundant code & fixed IllegalPluginAccessError (#482) --- .../plan/settings/locale/Locale.java | 1 + .../databases/operation/FetchOperations.java | 7 +- .../system/database/databases/sql/SQLDB.java | 109 ++---------------- .../database/databases/sql/SQLiteDB.java | 53 ++++----- .../databases/sql/operation/SQLFetchOps.java | 71 +++++++++++- .../databases/sql/operation/SQLRemoveOps.java | 3 + .../tables/move/Version8TransferTable.java | 4 +- 7 files changed, 107 insertions(+), 141 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java index 1e85e61d99..3392889e8e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java @@ -1,5 +1,6 @@ package com.djrapitops.plan.settings.locale; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 18099e2c9f..311f2e68b5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -4,15 +4,14 @@ import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; +import java.util.*; public interface FetchOperations { ServerProfile getServerProfile(UUID serverUUID) throws DBException; + List getPlayers(UUID serverUUID) throws DBException; + PlayerProfile getPlayerProfile(UUID uuid) throws DBException; Set getSavedUUIDs() throws DBException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 0e1c2ddb87..8053e84a01 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -1,9 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql; import com.djrapitops.plan.api.exceptions.database.DBInitException; -import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.data.ServerProfile; -import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.operation.BackupOperations; import com.djrapitops.plan.system.database.databases.operation.CheckOperations; @@ -15,7 +12,6 @@ import com.djrapitops.plan.system.database.databases.sql.operation.SQLRemoveOps; import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.database.databases.sql.tables.move.Version8TransferTable; -import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -26,7 +22,6 @@ import java.sql.Connection; import java.sql.SQLException; -import java.util.*; /** * Class containing main logic for different data related save and load functionality. @@ -98,7 +93,7 @@ public SQLDB() { */ @Override public void init() throws DBInitException { - setStatus("Init"); + setStatus("Initiating"); String benchName = "Init " + getConfigName(); Benchmark.start("Database", benchName); try { @@ -109,6 +104,7 @@ public void init() throws DBInitException { Benchmark.stop("Database", benchName); Log.logDebug("Database"); } + setStatus("Open"); } public void scheduleClean(long secondsDelay) { @@ -137,17 +133,17 @@ public void run() { */ public void setupDatabase() throws DBInitException { try { - boolean newDatabase = isNewDatabase(); + boolean newDatabase = versionTable.isNewDatabase(); versionTable.createTable(); createTables(); if (newDatabase) { Log.info("New Database created."); - setVersion(13); + versionTable.setVersion(13); } - int version = getVersion(); + int version = versionTable.getVersion(); final SQLDB db = this; if (version < 10) { @@ -164,16 +160,16 @@ public void run() { } if (version < 11) { serverTable.alterTableV11(); - setVersion(11); + versionTable.setVersion(11); } if (version < 12) { actionsTable.alterTableV12(); ipsTable.alterTableV12(); - setVersion(12); + versionTable.setVersion(12); } if (version < 13) { ipsTable.alterTableV13(); - setVersion(13); + versionTable.setVersion(13); } } catch (SQLException e) { throw new DBInitException("Failed to set-up Database", e); @@ -245,91 +241,6 @@ public void setVersion(int version) throws SQLException { versionTable.setVersion(version); } - public boolean isNewDatabase() throws SQLException { - return versionTable.isNewDatabase(); - } - - @Override - public ServerProfile getServerProfile(UUID serverUUID) throws SQLException { - ServerProfile profile = new ServerProfile(serverUUID); - - profile.setPlayers(getPlayers(serverUUID)); - profile.setTps(tpsTable.getTPSData(serverUUID)); - Optional allTimePeak = tpsTable.getAllTimePeak(serverUUID); - if (allTimePeak.isPresent()) { - TPS peak = allTimePeak.get(); - profile.setAllTimePeak(peak.getDate()); - profile.setAllTimePeakPlayers(peak.getPlayers()); - } - Optional lastPeak = tpsTable.getPeakPlayerCount(serverUUID, MiscUtils.getTime() - (TimeAmount.DAY.ms() * 2L)); - if (lastPeak.isPresent()) { - TPS peak = lastPeak.get(); - profile.setLastPeakDate(peak.getDate()); - profile.setLastPeakPlayers(peak.getPlayers()); - } - - profile.setCommandUsage(commandUseTable.getCommandUse(serverUUID)); - profile.setServerWorldtimes(worldTimesTable.getWorldTimesOfServer(serverUUID)); - - return profile; - } - - private List getPlayers(UUID serverUUID) throws SQLException { - List serverUserInfo = userInfoTable.getServerUserInfo(serverUUID); - Map timesKicked = usersTable.getAllTimesKicked(); - Map> actions = actionsTable.getServerActions(serverUUID); - Map> geoInfo = ipsTable.getAllGeoInfo(); - - Map> sessions = sessionsTable.getSessionInfoOfServer(serverUUID); - Map>> map = new HashMap<>(); - map.put(serverUUID, sessions); - killsTable.addKillsToSessions(map); - worldTimesTable.addWorldTimesToSessions(map); - - List players = new ArrayList<>(); - - for (UserInfo userInfo : serverUserInfo) { - UUID uuid = userInfo.getUuid(); - PlayerProfile profile = new PlayerProfile(uuid, userInfo.getName(), userInfo.getRegistered()); - profile.setTimesKicked(timesKicked.getOrDefault(uuid, 0)); - if (userInfo.isBanned()) { - profile.bannedOnServer(serverUUID); - } - if (userInfo.isOpped()) { - profile.oppedOnServer(serverUUID); - } - profile.setActions(actions.getOrDefault(uuid, new ArrayList<>())); - profile.setGeoInformation(geoInfo.getOrDefault(uuid, new ArrayList<>())); - profile.setSessions(serverUUID, sessions.getOrDefault(uuid, new ArrayList<>())); - - players.add(profile); - } - return players; - } - - public void removeAccount(UUID uuid) throws SQLException { - if (uuid == null) { - return; - } - - try { - Log.logDebug("Database", "Removing Account: " + uuid); - Benchmark.start("Database", "Remove Account"); - - for (Table t : getAllTablesInRemoveOrder()) { - if (!(t instanceof UserIDTable)) { - continue; - } - - UserIDTable table = (UserIDTable) t; - table.removeUser(uuid); - } - } finally { - Benchmark.stop("Database", "Remove Account"); - setAvailable(); - } - } - private void clean() throws SQLException { Log.info("Cleaning the database."); tpsTable.clean(); @@ -340,10 +251,6 @@ private void setStatus(String status) { Log.logDebug("Database", status); } - public void setAvailable() { - Log.logDebug("Database"); - } - public abstract Connection getConnection() throws SQLException; /** diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index ca838b264a..e9a1f1fd15 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -66,45 +66,38 @@ public Connection getNewConnection(String dbName) throws SQLException { Log.info("SQLite WAL mode not supported on this server version, using default. This may or may not affect performance."); } connection.setAutoCommit(false); -// connection. - -// setJournalMode(connection); return connection; } - private void setJournalMode(Connection connection) throws SQLException { - try (Statement statement = connection.createStatement()) { - statement.execute(""); - } - } - private void startConnectionPingTask() { stopConnectionPingTask(); - - // Maintains Connection. - connectionPingTask = RunnableFactory.createNew(new AbsRunnable("DBConnectionPingTask " + getName()) { - @Override - public void run() { - Statement statement = null; - try { - if (connection != null && !connection.isClosed()) { - statement = connection.createStatement(); - statement.execute("/* ping */ SELECT 1"); - } - } catch (SQLException e) { + try { + // Maintains Connection. + connectionPingTask = RunnableFactory.createNew(new AbsRunnable("DBConnectionPingTask " + getName()) { + @Override + public void run() { + Statement statement = null; try { - connection = getNewConnection(dbName); - } catch (SQLException e1) { - Log.toLog(this.getClass().getName(), e1); - Log.error("SQLite connection maintaining task had to be closed due to exception."); - this.cancel(); + if (connection != null && !connection.isClosed()) { + statement = connection.createStatement(); + statement.execute("/* ping */ SELECT 1"); + } + } catch (SQLException e) { + try { + connection = getNewConnection(dbName); + } catch (SQLException e1) { + Log.toLog(this.getClass().getName(), e1); + Log.error("SQLite connection maintaining task had to be closed due to exception."); + this.cancel(); + } + } finally { + MiscUtils.close(statement); } - } finally { - MiscUtils.close(statement); } - } - }).runTaskTimerAsynchronously(60L * 20L, 60L * 20L); + }).runTaskTimerAsynchronously(60L * 20L, 60L * 20L); + } catch (Exception ignored) { + } } private void stopConnectionPingTask() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index c901f741e0..5f6511b04b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -3,11 +3,12 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; -import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.data.container.UserInfo; +import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.TimeAmount; import java.sql.SQLException; import java.util.*; @@ -19,8 +20,70 @@ public SQLFetchOps(SQLDB db) { } @Override - public ServerProfile getServerProfile(UUID serverUUID) { - return null; + public ServerProfile getServerProfile(UUID serverUUID) throws DBException { + try { + ServerProfile profile = new ServerProfile(serverUUID); + + profile.setPlayers(getPlayers(serverUUID)); + profile.setTps(tpsTable.getTPSData(serverUUID)); + Optional allTimePeak = tpsTable.getAllTimePeak(serverUUID); + if (allTimePeak.isPresent()) { + TPS peak = allTimePeak.get(); + profile.setAllTimePeak(peak.getDate()); + profile.setAllTimePeakPlayers(peak.getPlayers()); + } + Optional lastPeak = tpsTable.getPeakPlayerCount(serverUUID, MiscUtils.getTime() - (TimeAmount.DAY.ms() * 2L)); + if (lastPeak.isPresent()) { + TPS peak = lastPeak.get(); + profile.setLastPeakDate(peak.getDate()); + profile.setLastPeakPlayers(peak.getPlayers()); + } + + profile.setCommandUsage(commandUseTable.getCommandUse(serverUUID)); + profile.setServerWorldtimes(worldTimesTable.getWorldTimesOfServer(serverUUID)); + + return profile; + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public List getPlayers(UUID serverUUID) throws DBException { + try { + List serverUserInfo = userInfoTable.getServerUserInfo(serverUUID); + Map timesKicked = usersTable.getAllTimesKicked(); + Map> actions = actionsTable.getServerActions(serverUUID); + Map> geoInfo = ipsTable.getAllGeoInfo(); + + Map> sessions = sessionsTable.getSessionInfoOfServer(serverUUID); + Map>> map = new HashMap<>(); + map.put(serverUUID, sessions); + killsTable.addKillsToSessions(map); + worldTimesTable.addWorldTimesToSessions(map); + + List players = new ArrayList<>(); + + for (UserInfo userInfo : serverUserInfo) { + UUID uuid = userInfo.getUuid(); + PlayerProfile profile = new PlayerProfile(uuid, userInfo.getName(), userInfo.getRegistered()); + profile.setTimesKicked(timesKicked.getOrDefault(uuid, 0)); + if (userInfo.isBanned()) { + profile.bannedOnServer(serverUUID); + } + if (userInfo.isOpped()) { + profile.oppedOnServer(serverUUID); + } + profile.setActions(actions.getOrDefault(uuid, new ArrayList<>())); + profile.setGeoInformation(geoInfo.getOrDefault(uuid, new ArrayList<>())); + profile.setSessions(serverUUID, sessions.getOrDefault(uuid, new ArrayList<>())); + + players.add(profile); + } + return players; + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java index b3905dfce4..1f6aee27d5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java @@ -28,6 +28,7 @@ public void player(UUID uuid) throws DBException { try { Log.logDebug("Database", "Removing Account: " + uuid); Benchmark.start("Database", "Remove Account"); + String webUser = usersTable.getPlayerName(uuid); for (Table t : db.getAllTablesInRemoveOrder()) { if (!(t instanceof UserIDTable)) { @@ -37,6 +38,8 @@ public void player(UUID uuid) throws DBException { UserIDTable table = (UserIDTable) t; table.removeUser(uuid); } + + securityTable.removeUser(webUser); } catch (SQLException e) { throw ErrorUtil.getFatalExceptionFor(e); } finally { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java index 4fd88394a2..6fb9a502a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java @@ -24,8 +24,8 @@ public class Version8TransferTable extends Table { private final int serverID; - public Version8TransferTable(SQLDB db, boolean usingMySQL) throws SQLException { - super("", db, usingMySQL); + public Version8TransferTable(SQLDB db) throws SQLException { + super("", db); Optional serverID = db.getServerTable().getServerID(Plan.getServerUUID()); if (!serverID.isPresent()) { throw new IllegalStateException("Server UUID was not registered, try rebooting the plugin."); From 902c7c2470093e3d7cc6fc2811318ac0718486b5 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 15 Jan 2018 15:54:33 +0200 Subject: [PATCH 019/166] Fixed some method calls --- .../main/java/com/djrapitops/plan/Plan.java | 88 +------------ .../java/com/djrapitops/plan/PlanBungee.java | 33 +---- .../java/com/djrapitops/plan/PlanPlugin.java | 7 ++ .../java/com/djrapitops/plan/api/PlanAPI.java | 10 +- .../api/exceptions/PassEncryptException.java | 23 ++++ .../plan/data/plugin/HookHandler.java | 3 +- .../system/database/databases/Database.java | 9 +- .../databases/operation/CountOperations.java | 11 ++ .../databases/operation/FetchOperations.java | 16 +++ .../databases/operation/SearchOperations.java | 11 ++ .../database/databases/sql/MySQLDB.java | 8 +- .../system/database/databases/sql/SQLDB.java | 26 ++-- .../databases/sql/operation/SQLCountOps.java | 25 ++++ .../databases/sql/operation/SQLFetchOps.java | 30 +++++ .../databases/sql/operation/SQLSearchOps.java | 25 ++++ .../databases/sql/tables/UserInfoTable.java | 42 +++---- .../plan/system/database/sql/Insert.java | 30 ----- .../plan/system/database/sql/Select.java | 26 ---- .../plan/system/database/sql/Sql.java | 16 --- .../plan/system/database/sql/SqlParser.java | 35 ------ .../system/database/sql/TableSqlParser.java | 118 ------------------ .../plan/system/database/sql/Update.java | 30 ----- .../plan/system/database/sql/WhereParser.java | 48 ------- .../bungee/PlayerOnlineListener.java | 2 +- .../webserver/auth/BasicAuthentication.java | 24 ++-- .../djrapitops/plan/utilities/MiscUtils.java | 8 +- .../plan/utilities/PassEncryptUtil.java | 6 +- .../plan/utilities/analysis/Analysis.java | 7 +- .../plan/utilities/html/HtmlStructure.java | 9 +- .../plan/utilities/uuid/UUIDUtility.java | 15 ++- 30 files changed, 248 insertions(+), 493 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/sql/Insert.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/sql/Select.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/sql/Sql.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/sql/SqlParser.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/sql/TableSqlParser.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/sql/Update.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/sql/WhereParser.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 3e5855bb1c..54ced8353f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -19,7 +19,6 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.api.API; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.command.PlanCommand; import com.djrapitops.plan.data.plugin.HookHandler; @@ -31,11 +30,10 @@ import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.processing.ProcessingQueue; -import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.processing.processors.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; @@ -47,25 +45,21 @@ import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; -import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.TimeAmount; 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; import com.djrapitops.plugin.settings.ColorScheme; -import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.RunnableFactory; import org.bukkit.configuration.file.FileConfiguration; import java.io.IOException; import java.net.UnknownHostException; -import java.util.List; import java.util.UUID; /** @@ -79,11 +73,10 @@ */ public class Plan extends BukkitPlugin implements PlanPlugin { - private API api; - + private BukkitSystem system; + private Systems systems; - private ProcessingQueue processingQueue; private HookHandler hookHandler; // Manages 3rd party data sources private BukkitInformationManager infoManager; @@ -91,22 +84,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { private ServerVariableHolder serverVariableHolder; - /** - * Used to get the PlanAPI. @see API - * - * @return API of the current instance of Plan. - * @throws IllegalStateException If onEnable method has not been called on - * Plan and the instance is null. - * @throws NoClassDefFoundError If Plan is not installed. - */ - public static API getPlanAPI() throws NoClassDefFoundError { - Plan instance = getInstance(); - if (instance == null) { - throw new IllegalStateException("Plugin not enabled properly, Singleton instance is null."); - } - return instance.getApi(); - } - /** * Used to get the plugin-instance singleton. * @@ -162,7 +139,6 @@ public void onEnable() { DBSystem.getInstance().enable(); Benchmark.start("WebServer Initialization"); - processingQueue = new ProcessingQueue(); serverInfoManager = new BukkitServerInfoManager(this); infoManager = new BukkitInformationManager(this); @@ -182,8 +158,6 @@ public void onEnable() { TaskSystem.getInstance().enable(); - this.api = new API(this); - boolean usingBungeeWebServer = infoManager.isUsingAnotherWebServer(); boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); @@ -234,25 +208,6 @@ public void onDisable() { //Clears the page cache ResponseCache.clearCache(); - // Processes unprocessed processors - if (processingQueue != null) { - List processors = processingQueue.stopAndReturnLeftovers(); - if (!reloading) { - Log.info("Processing unprocessed processors. (" + processors.size() + ")"); // TODO Move to Locale - for (Processor processor : processors) { - processor.process(); - } - } else { - RunnableFactory.createNew("Re-Add processors", new AbsRunnable() { - @Override - public void run() { - addToProcessQueue(processors.toArray(new Processor[processors.size()])); - cancel(); - } - }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L); - } - } - systems.close(); Log.info(Locale.get(Msg.DISABLED).toString()); @@ -329,29 +284,6 @@ public BukkitServerInfoManager getServerInfoManager() { return serverInfoManager; } - public ProcessingQueue getProcessingQueue() { - return processingQueue; - } - - public void addToProcessQueue(Processor... processors) { - if (!reloading) { - for (Processor processor : processors) { - if (processor == null) { - continue; - } - processingQueue.addToQueue(processor); - } - } else { - RunnableFactory.createNew("Re-Add processors", new AbsRunnable() { - @Override - public void run() { - addToProcessQueue(processors); - cancel(); - } - }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L); - } - } - @Override public Config getMainConfig() { return ConfigSystem.getInstance().getConfig(); @@ -402,20 +334,6 @@ public void saveDefaultConfig() { throw new IllegalStateException("This method should be used on this plugin."); } - /** - * Method for getting the API. - *

- * Created due to necessity for testing, but can be used. - * For direct API getter use {@code Plan.getPlanAPI()}. - *

- * If Plan is reloaded a new API instance is created. - * - * @return Plan API instance. - */ - public API getApi() { - return api; - } - public Systems getSystems() { return systems; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 08315d2195..a10d8cd208 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -13,8 +13,6 @@ import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.processing.ProcessingQueue; -import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.tasks.TaskSystem; @@ -52,8 +50,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { private BungeeInformationManager infoManager; private ServerVariableHolder variableHolder; - private ProcessingQueue processingQueue; - + @Deprecated private boolean setupAllowed = false; private BungeeSystem system; @@ -93,8 +90,6 @@ public void onEnable() { TaskSystem.getInstance().enable(); - processingQueue = new ProcessingQueue(); - Log.logDebug("Enable", "WebServer Initialization"); Log.info(Locale.get(Msg.ENABLED).toString()); if (Settings.ANALYSIS_EXPORT.isTrue()) { @@ -113,13 +108,6 @@ public static PlanBungee getInstance() { @Override public void onDisable() { - if (processingQueue != null) { - try { - processingQueue.stop(); - } catch (IllegalArgumentException ignored) { - /*ignored*/ - } - } systems.close(); Log.info(Locale.get(Msg.DISABLED).toString()); Benchmark.pluginDisabled(PlanBungee.class); @@ -134,7 +122,6 @@ public String getVersion() { @Override public void onReload() { - ConfigSystem.reload(); } @Override @@ -158,19 +145,6 @@ public WebServer getWebServer() { return WebServerSystem.getInstance().getWebServer(); } - - @Override - public ProcessingQueue getProcessingQueue() { - return processingQueue; - } - - @Override - public void addToProcessQueue(Processor... processors) { - for (Processor processor : processors) { - processingQueue.addToQueue(processor); - } - } - @Override public InputStream getResource(String resource) { return getResourceAsStream(resource); @@ -215,4 +189,9 @@ public void setSetupAllowed(boolean setupAllowed) { public BungeeSystem getSystem() { return system; } + + @Override + public boolean isReloading() { + return reloading; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 7513469043..de932c1e9b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -28,27 +28,34 @@ public interface PlanPlugin extends IPlugin { @Deprecated Database getDB(); + @Deprecated ServerVariableHolder getVariable(); + @Deprecated UUID getServerUuid(); @Deprecated InformationManager getInfoManager(); + @Deprecated WebServer getWebServer(); File getDataFolder(); + @Deprecated ProcessingQueue getProcessingQueue(); + @Deprecated void addToProcessQueue(Processor... processors); InputStream getResource(String resource); + @Deprecated Config getMainConfig(); ColorScheme getColorScheme(); + @Deprecated Systems getSystems(); boolean isReloading(); diff --git a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java index 554e0f1f32..568cd5463e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java @@ -21,9 +21,15 @@ static PlanAPI getInstance() { throw new IllegalAccessError("Not yet implemented"); // TODO } - void registerPluginData(PluginData pluginData); + void addPluginDataSource(PluginData pluginData); - Map getKnownUsernames(); + String getPlayerInspectPageLink(String playerName); + + String getPlayerName(UUID uuid); + + UUID playerNameToUUID(String playerName); + + Map getKnownPlayerNames(); FetchOperations fetchFromPlanDB(); } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java new file mode 100644 index 0000000000..8c5a12b0fb --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java @@ -0,0 +1,23 @@ +package com.djrapitops.plan.api.exceptions; + +public class PassEncryptException extends Exception { + + public PassEncryptException() { + } + + public PassEncryptException(String s) { + super(s); + } + + public PassEncryptException(String s, Throwable throwable) { + super(s, throwable); + } + + public PassEncryptException(Throwable throwable) { + super(throwable); + } + + public PassEncryptException(String s, Throwable throwable, boolean b, boolean b1) { + super(s, throwable, b, b1); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java index 915821f5c1..d6e3c3e452 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java @@ -3,7 +3,6 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.pluginbridge.plan.Bridge; import java.util.ArrayList; import java.util.List; @@ -29,7 +28,7 @@ public HookHandler(Plan plugin) { additionalDataSources = new ArrayList<>(); configHandler = new PluginsConfigSection(); try { - Bridge.hook(this); +// Bridge.hook(this); } catch (Exception e) { Log.toLog(this.getClass().getName(), e); Log.error("Plan Plugin Bridge not included in the plugin jar."); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index aa861498d1..fe3c5b5c4d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -3,10 +3,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.plan.system.database.databases.operation.BackupOperations; -import com.djrapitops.plan.system.database.databases.operation.CheckOperations; -import com.djrapitops.plan.system.database.databases.operation.FetchOperations; -import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; +import com.djrapitops.plan.system.database.databases.operation.*; import com.djrapitops.plan.utilities.NullCheck; /** @@ -62,4 +59,8 @@ public String getConfigName() { public boolean isOpen() { return open; } + + public abstract SearchOperations search(); + + public abstract CountOperations count(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java new file mode 100644 index 0000000000..4d039f2ba0 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java @@ -0,0 +1,11 @@ +package com.djrapitops.plan.system.database.databases.operation; + +import com.djrapitops.plan.api.exceptions.database.DBException; + +import java.util.UUID; + +public interface CountOperations { + + int serverPlayerCount(UUID server) throws DBException; + +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 311f2e68b5..700ea2beba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -3,17 +3,23 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; +import com.djrapitops.plan.data.WebUser; +import com.djrapitops.plan.data.container.TPS; import java.util.*; public interface FetchOperations { + // Profiles + ServerProfile getServerProfile(UUID serverUUID) throws DBException; List getPlayers(UUID serverUUID) throws DBException; PlayerProfile getPlayerProfile(UUID uuid) throws DBException; + // UUIDs + Set getSavedUUIDs() throws DBException; Set getSavedUUIDs(UUID server) throws DBException; @@ -21,4 +27,14 @@ public interface FetchOperations { Map getServerNames() throws DBException; Optional getServerUUID(String serverName) throws DBException; + + UUID getUuidOf(String playerName) throws DBException; + + // WebUsers + + WebUser getWebUser(String username) throws DBException; + + // Raw Data + + List getTPSData(UUID serverUUID) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java new file mode 100644 index 0000000000..a6e564b19d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java @@ -0,0 +1,11 @@ +package com.djrapitops.plan.system.database.databases.operation; + +import com.djrapitops.plan.api.exceptions.database.DBException; + +import java.util.List; + +public interface SearchOperations { + + List matchingNames(String search) throws DBException; + +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java index 50dfa59402..136606e66d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java @@ -57,8 +57,12 @@ public Connection getConnection() throws SQLException { } @Override - public void close() throws SQLException { - dataSource.close(); + public void close() { + try { + dataSource.close(); + } catch (SQLException e) { + Log.toLog(this.getClass(), e); + } super.close(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 8053e84a01..e015bda413 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -2,14 +2,8 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.operation.BackupOperations; -import com.djrapitops.plan.system.database.databases.operation.CheckOperations; -import com.djrapitops.plan.system.database.databases.operation.FetchOperations; -import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; -import com.djrapitops.plan.system.database.databases.sql.operation.SQLBackupOps; -import com.djrapitops.plan.system.database.databases.sql.operation.SQLCheckOps; -import com.djrapitops.plan.system.database.databases.sql.operation.SQLFetchOps; -import com.djrapitops.plan.system.database.databases.sql.operation.SQLRemoveOps; +import com.djrapitops.plan.system.database.databases.operation.*; +import com.djrapitops.plan.system.database.databases.sql.operation.*; import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.database.databases.sql.tables.move.Version8TransferTable; import com.djrapitops.plugin.api.Benchmark; @@ -50,6 +44,8 @@ public abstract class SQLDB extends Database { private final SQLCheckOps checkOps; private final SQLFetchOps fetchOps; private final SQLRemoveOps removeOps; + private final SQLSearchOps searchOps; + private final SQLCountOps countOps; private final boolean usingMySQL; private boolean open = false; @@ -79,6 +75,8 @@ public SQLDB() { checkOps = new SQLCheckOps(this); fetchOps = new SQLFetchOps(this); removeOps = new SQLRemoveOps(this); + countOps = new SQLCountOps(this); + searchOps = new SQLSearchOps(this); } /** @@ -151,7 +149,7 @@ public void setupDatabase() throws DBInitException { @Override public void run() { try { - new Version8TransferTable(db, isUsingMySQL()).alterTablesToV10(); + new Version8TransferTable(db).alterTablesToV10(); } catch (DBInitException | SQLException e) { Log.toLog(this.getClass().getName(), e); } @@ -368,4 +366,14 @@ public FetchOperations fetch() { public RemoveOperations remove() { return removeOps; } + + @Override + public SearchOperations search() { + return searchOps; + } + + @Override + public CountOperations count() { + return countOps; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java new file mode 100644 index 0000000000..da435bbda2 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java @@ -0,0 +1,25 @@ +package com.djrapitops.plan.system.database.databases.sql.operation; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.operation.CountOperations; +import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; + +import java.sql.SQLException; +import java.util.UUID; + +public class SQLCountOps extends SQLOps implements CountOperations { + + public SQLCountOps(SQLDB db) { + super(db); + } + + @Override + public int serverPlayerCount(UUID server) throws DBException { + try { + return userInfoTable.getServerUserCount(server); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index 5f6511b04b..e1c30b7a28 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -3,6 +3,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; +import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; @@ -171,4 +172,33 @@ public Optional getServerUUID(String serverName) throws DBException { throw ErrorUtil.getExceptionFor(e); } } + + @Override + public UUID getUuidOf(String playerName) throws DBException { + try { + return usersTable.getUuidOf(playerName); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + + @Override + public WebUser getWebUser(String username) throws DBException { + try { + return securityTable.getWebUser(username); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + + @Override + public List getTPSData(UUID serverUUID) throws DBException { + try { + return tpsTable.getTPSData(serverUUID); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java new file mode 100644 index 0000000000..cf074ce51d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java @@ -0,0 +1,25 @@ +package com.djrapitops.plan.system.database.databases.sql.operation; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.operation.SearchOperations; +import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; + +import java.sql.SQLException; +import java.util.List; + +public class SQLSearchOps extends SQLOps implements SearchOperations { + + public SQLSearchOps(SQLDB db) { + super(db); + } + + @Override + public List matchingNames(String search) throws DBException { + try { + return usersTable.getMatchingNames(search); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java index cce01b8534..d887abba07 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java @@ -16,7 +16,6 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plan.system.database.databases.sql.statements.Update; -import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -316,31 +315,26 @@ public Map> processResults(ResultSet set) throws SQLException { }); } - public int getServerUserCount(UUID serverUUID) { - try { - String sql = "SELECT " + - " COUNT(" + columnRegistered + ") as c" + - " FROM " + tableName + - " WHERE " + columnServerID + "=" + serverTable.statementSelectServerID; - - return query(new QueryStatement(sql, 20000) { - @Override - public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, serverUUID.toString()); - } + public int getServerUserCount(UUID serverUUID) throws SQLException { + String sql = "SELECT " + + " COUNT(" + columnRegistered + ") as c" + + " FROM " + tableName + + " WHERE " + columnServerID + "=" + serverTable.statementSelectServerID; - @Override - public Integer processResults(ResultSet set) throws SQLException { - if (set.next()) { - return set.getInt("c"); - } - return 0; + return query(new QueryAllStatement(sql, 20000) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, serverUUID.toString()); + } + + @Override + public Integer processResults(ResultSet set) throws SQLException { + if (set.next()) { + return set.getInt("c"); } - }); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - return 0; - } + return 0; + } + }); } // TODO improve performance of this method. diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Insert.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Insert.java deleted file mode 100644 index ac63d3c0cf..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Insert.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.djrapitops.plan.system.database.sql; - -public class Insert extends SqlParser { - - public Insert(String table) { - super("INSERT INTO " + table); - addSpace(); - } - - public static String values(String table, String... columns) { - Insert parser = new Insert(table); - parser.append("("); - int size = columns.length; - for (int i = 0; i < size; i++) { - if (size > 1 && i > 0) { - parser.append(", "); - } - parser.append(columns[i]); - } - parser.append(") VALUES ("); - for (int i = 0; i < size; i++) { - if (size > 1 && i > 0) { - parser.append(", "); - } - parser.append("?"); - } - parser.append(")"); - return parser.toString(); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Select.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Select.java deleted file mode 100644 index 58e9a249c6..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Select.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.djrapitops.plan.system.database.sql; - -public class Select extends WhereParser { - - public Select(String start) { - super(start); - } - - public static Select from(String table, String... columns) { - Select parser = new Select("SELECT "); - int size = columns.length; - for (int i = 0; i < size; i++) { - if (size > 1 && i > 0) { - parser.append(", "); - } - parser.append(columns[i]); - } - - parser.append(" FROM ").append(table); - return parser; - } - - public static Select all(String table) { - return new Select("SELECT * FROM " + table); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Sql.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Sql.java deleted file mode 100644 index fdf964c556..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Sql.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.djrapitops.plan.system.database.sql; - -public class Sql { - public static final String INT = "integer"; - public static final String DOUBLE = "double"; - public static final String LONG = "bigint"; - public static final String BOOL = "boolean"; - - private Sql() { - throw new IllegalStateException("Variable Class"); - } - - public static String varchar(int length) { - return "varchar(" + length + ")"; - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/SqlParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/SqlParser.java deleted file mode 100644 index 3e51824fa6..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/SqlParser.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.djrapitops.plan.system.database.sql; - -/** - * Class for parsing different SQL strings. - * - * @author Rsl1122 - * @since 3.7.0 - */ -public class SqlParser { - - private final StringBuilder s; - - public SqlParser() { - s = new StringBuilder(); - } - - public SqlParser(String start) { - s = new StringBuilder(start); - } - - public SqlParser addSpace() { - s.append(" "); - return this; - } - - public SqlParser append(String string) { - s.append(string); - return this; - } - - @Override - public String toString() { - return s.toString(); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/TableSqlParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/TableSqlParser.java deleted file mode 100644 index 3edb43fdb9..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/TableSqlParser.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.djrapitops.plan.system.database.sql; - -/** - * SqlParser Class for parsing table creation, removal and modification statements. - * - * @author Rsl1122 - * @since 3.7.0 - */ -public class TableSqlParser extends SqlParser { - - private int columns = 0; - - public TableSqlParser(String start) { - super(start); - } - - public static TableSqlParser createTable(String tableName) { - return new TableSqlParser("CREATE TABLE IF NOT EXISTS " + tableName + " ("); - } - - public static String dropTable(String tableName) { - return "DROP TABLE IF EXISTS " + tableName; - } - - /** - * Used for ALTER TABLE sql statements. - * - * @param column column to modify - * @return TableSqlParser object - */ - public static TableSqlParser newColumn(String column, String type) { - return new TableSqlParser("").column(column, type); - } - - public TableSqlParser column(String column, String type) { - if (columns > 0) { - append(", "); - } - append(column).addSpace(); - append(type); - - columns++; - return this; - } - - public TableSqlParser foreignKey(String column, String refrencedTable, String referencedColumn) { - if (columns > 0) { - append(", "); - } - append("FOREIGN KEY(") - .append(column) - .append(") REFERENCES ") - .append(refrencedTable) - .append("(") - .append(referencedColumn) - .append(")"); - columns++; - return this; - } - - public TableSqlParser notNull() { - addSpace(); - append("NOT NULL"); - return this; - } - - public TableSqlParser unique() { - addSpace(); - append("UNIQUE"); - return this; - } - - public TableSqlParser defaultValue(boolean value) { - return defaultValue(value ? "1" : "0"); - } - - public TableSqlParser defaultValue(String value) { - addSpace(); - append("DEFAULT ").append(value); - return this; - } - - public TableSqlParser primaryKeyIDColumn(boolean mySQL, String column) { - if (columns > 0) { - append(", "); - } - append(column).addSpace(); - append(Sql.INT).addSpace(); - append((mySQL) ? "NOT NULL AUTO_INCREMENT" : "PRIMARY KEY"); - columns++; - return this; - } - - public TableSqlParser primaryKey(boolean mySQL, String column) { - if (mySQL) { - if (columns > 0) { - append(", "); - } - append("PRIMARY KEY (").append(column).append(")"); - columns++; - } - return this; - } - - public TableSqlParser charSetUTF8(boolean mySQL) { - if (mySQL) { - addSpace(); - append("CHARACTER SET utf8 COLLATE utf8mb4_general_ci"); - } - return this; - } - - @Override - public String toString() { - append(")"); - return super.toString(); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Update.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Update.java deleted file mode 100644 index 178b1e43dd..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/Update.java +++ /dev/null @@ -1,30 +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.system.database.sql; - -/** - * @author Fuzzlemann - */ -public class Update extends WhereParser { - - public Update(String table) { - super("UPDATE " + table + " SET"); - addSpace(); - } - - public static Update values(String table, String... values) { - Update parser = new Update(table); - - int size = values.length; - for (int i = 0; i < size; i++) { - if (size > 1 && i > 0) { - parser.append(", "); - } - parser.append(values[i] + "=?"); - } - - return parser; - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/WhereParser.java b/Plan/src/main/java/com/djrapitops/plan/system/database/sql/WhereParser.java deleted file mode 100644 index 8e03a3d3a2..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/sql/WhereParser.java +++ /dev/null @@ -1,48 +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.system.database.sql; - -/** - * @author Fuzzlemann - */ -public abstract class WhereParser extends SqlParser { - - private int conditions = 0; - - public WhereParser() { - super(); - } - - public WhereParser(String start) { - super(start); - } - - public WhereParser where(String... conditions) { - append(" WHERE "); - for (String condition : conditions) { - if (this.conditions > 0) { - append(" AND "); - } - append("(").append(condition).append(")"); - this.conditions++; - } - - return this; - } - - public WhereParser and(String condition) { - append(" AND "); - append("(").append(condition).append(")"); - this.conditions++; - return this; - } - - public WhereParser or(String condition) { - append(" OR "); - append("(").append(condition).append(")"); - this.conditions++; - return this; - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java index 8937317f39..7a97f7a618 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java @@ -36,7 +36,7 @@ public void onPostLogin(PostLoginEvent event) { String name = player.getName(); long now = MiscUtils.getTime(); - plugin.getProcessingQueue().addToQueue(new BungeePlayerRegisterProcessor(uuid, name, now)); + plugin.getSystem().getProcessingQueue().addToQueue(new BungeePlayerRegisterProcessor(uuid, name, now)); } catch (Exception e) { Log.toLog(this.getClass(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java index d0f141f8a3..bede10e1f3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java @@ -4,10 +4,11 @@ */ package com.djrapitops.plan.system.webserver.auth; -import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.PassEncryptException; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.database.tables.SecurityTable; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.utilities.PassEncryptUtil; import java.util.Base64; @@ -28,15 +29,7 @@ public BasicAuthentication(String authenticationString) { } @Override - public boolean isAuthorized(String permission) throws WebUserAuthException { - if (user == null) { - user = getUser(); - return user.hasPermission(permission); - } - return false; - } - - public WebUser getUser() throws WebUserAuthException { + public WebUser getWebUser() throws WebUserAuthException { Base64.Decoder decoder = Base64.getDecoder(); byte[] decoded = decoder.decode(authenticationString); String[] userInfo = new String(decoded).split(":"); @@ -48,19 +41,20 @@ public WebUser getUser() throws WebUserAuthException { String passwordRaw = userInfo[1]; try { - SecurityTable securityTable = PlanPlugin.getInstance().getDB().getSecurityTable(); - if (!securityTable.userExists(user)) { + + Database database = Database.getActive(); + if (!database.check().doesWebUserExists(user)) { throw new WebUserAuthException(FailReason.USER_DOES_NOT_EXIST); } - WebUser webUser = securityTable.getWebUser(user); + WebUser webUser = database.fetch().getWebUser(user); boolean correctPass = PassEncryptUtil.verifyPassword(passwordRaw, webUser.getSaltedPassHash()); if (!correctPass) { throw new WebUserAuthException(FailReason.USER_PASS_MISMATCH); } return webUser; - } catch (Exception e) { + } catch (DBException | PassEncryptException e) { throw new WebUserAuthException(e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index f46009bd34..032d96d936 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -3,6 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; @@ -16,7 +17,6 @@ import java.io.Closeable; import java.io.IOException; -import java.sql.SQLException; import java.util.*; import java.util.stream.Collectors; @@ -99,9 +99,9 @@ public static List getMatchingPlayerNames(String search) { Database db = PlanPlugin.getInstance().getDB(); List matches; try { - matches = db.getUsersTable().getMatchingNames(search); - } catch (SQLException e) { - Log.toLog("MiscUtils.getMatchingPlayerNames", e); + matches = db.search().matchingPlayerNames(search); + } catch (DBException e) { + Log.toLog(MiscUtils.class, e); return new ArrayList<>(); } Collections.sort(matches); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java b/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java index 1bab179858..fa5115f271 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java @@ -1,5 +1,7 @@ package com.djrapitops.plan.utilities; +import com.djrapitops.plan.api.exceptions.PassEncryptException; + import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.xml.bind.DatatypeConverter; @@ -167,7 +169,7 @@ private static String toBase64(byte[] array) { } @SuppressWarnings("serial") - public static class InvalidHashException extends Exception { + public static class InvalidHashException extends PassEncryptException { InvalidHashException(String message) { super(message); @@ -179,7 +181,7 @@ public static class InvalidHashException extends Exception { } @SuppressWarnings("serial") - public static class CannotPerformOperationException extends Exception { + public static class CannotPerformOperationException extends PassEncryptException { CannotPerformOperationException() { super("Unsupported hash type."); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index ee191dd8b0..40e1c1d51c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -9,15 +9,16 @@ import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.tasks.BukkitTaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.system.tasks.BukkitTaskSystem; -import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; @@ -114,7 +115,7 @@ public boolean analyzeData(InformationManager infoManager, Database db) { Benchmark.stop("Analysis", "Create Empty dataset"); Benchmark.start("Fetch Phase"); - ServerProfile profile = db.getServerProfile(Plan.getServerUUID()); + ServerProfile profile = db.fetch().getServerProfile(Plan.getServerUUID()); DataCache dataCache = plugin.getDataCache(); profile.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions())); serverProfile = profile; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index a1a7e85cd2..5f94143804 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.ServerVariableHolder; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Settings; @@ -17,7 +18,6 @@ import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; -import java.sql.SQLException; import java.util.*; /** @@ -122,11 +122,12 @@ public static String createServerContainer(Plan plugin) { UUID serverUUID = plugin.getServerUuid(); String id = serverUUID.toString().replace("-", ""); - int playerCount = db.getUserInfoTable().getServerUserCount(serverUUID); + int playerCount = 0; String playerData = "[]"; try { - playerData = PlayerActivityGraph.createSeries(db.getTpsTable().getTPSData(serverUUID)); - } catch (SQLException e) { + playerCount = db.count().serverPlayerCount(serverUUID); + playerData = PlayerActivityGraph.createSeries(db.fetch().getTPSData(serverUUID)); + } catch (DBException e) { Log.toLog(HtmlStructure.class.getClass().getName(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java index e3261fbcf9..6c44440ee6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java @@ -6,12 +6,13 @@ package com.djrapitops.plan.utilities.uuid; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.api.exceptions.database.FatalDBException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.UUIDFetcher; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -34,7 +35,7 @@ private UUIDUtility() { */ public static UUID getUUIDOf(String playerName) { try { - return getUUIDOf(playerName, PlanPlugin.getInstance().getDB()); + return getUUIDOf(playerName, Database.getActive()); } catch (Exception e) { return null; } @@ -47,7 +48,7 @@ public static UUID getUUIDOf(String playerName) { * @param db Database to check from. * @return UUID of the player */ - public static UUID getUUIDOf(String playerName, Database db) { + private static UUID getUUIDOf(String playerName, Database db) { UUID uuid = null; if (Check.isBukkitAvailable()) { UUID uuidOf = Plan.getInstance().getDataCache().getUUIDof(playerName); @@ -56,9 +57,11 @@ public static UUID getUUIDOf(String playerName, Database db) { } } try { - uuid = db.getUsersTable().getUuidOf(playerName); - } catch (SQLException e) { - Log.toLog("UUIDUtility", e); + uuid = db.fetch().getUuidOf(playerName); + } catch (FatalDBException e) { + Log.toLog(UUIDUtility.class, e); + } catch (DBException e) { + /* Ignored */ } try { if (uuid == null) { From 9bbe4b27b221b5edb8d09036f663d2da1db0d524 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 15 Jan 2018 20:15:44 +0200 Subject: [PATCH 020/166] Move ops to database --- .../main/java/com/djrapitops/plan/Plan.java | 14 +- .../java/com/djrapitops/plan/PlanBungee.java | 13 +- .../java/com/djrapitops/plan/PlanPlugin.java | 4 - .../plan/api/exceptions/ParseException.java | 2 +- .../plan/command/commands/AnalyzeCommand.java | 5 +- .../plan/command/commands/InspectCommand.java | 2 +- .../plan/command/commands/ListCommand.java | 1 + .../djrapitops/plan/data/AnalysisData.java | 1 + .../djrapitops/plan/data/ServerProfile.java | 1 + .../djrapitops/plan/system/PlanSystem.java | 12 ++ .../plan/system/database/DBSystem.java | 19 +- .../system/database/databases/Database.java | 10 +- .../databases/operation/CheckOperations.java | 4 + .../databases/operation/CountOperations.java | 3 +- .../databases/operation/FetchOperations.java | 38 +++- .../databases/operation/SaveOperations.java | 65 ++++++ .../databases/operation/SearchOperations.java | 2 +- .../system/database/databases/sql/SQLDB.java | 23 +- .../databases/sql/operation/SQLCountOps.java | 11 +- .../databases/sql/operation/SQLFetchOps.java | 121 ++++++++++- .../databases/sql/operation/SQLOps.java | 4 +- .../databases/sql/operation/SQLSaveOps.java | 199 ++++++++++++++++++ .../databases/sql/operation/SQLSearchOps.java | 2 +- .../{IPsTable.java => GeoInfoTable.java} | 4 +- .../databases/sql/tables/UserInfoTable.java | 23 +- .../sql/tables/move/BatchOperationTable.java | 2 +- .../tables/move/Version8TransferTable.java | 2 +- .../system/listeners/bukkit/ChatListener.java | 2 +- .../bukkit/CommandPreprocessListener.java | 2 +- .../listeners/bukkit/DeathEventListener.java | 40 ++-- .../bungee/PlayerOnlineListener.java | 2 +- .../system/processing/ProcessingQueue.java | 6 +- .../processors/CommandProcessor.java | 9 +- .../processors/NewNickActionProcessor.java | 8 +- .../processing/processors/Processor.java | 11 +- .../processors/TPSInsertProcessor.java | 8 +- .../importing/importers/Importer.java | 40 ++-- .../processors/player/BanAndOpProcessor.java | 11 +- .../player/BungeePlayerRegisterProcessor.java | 13 +- .../player/FirstLeaveProcessor.java | 7 +- .../processors/player/IPUpdateProcessor.java | 8 +- .../processors/player/KickProcessor.java | 8 +- .../processors/player/NameProcessor.java | 30 ++- .../processors/player/RegisterProcessor.java | 24 +-- .../system/webserver/WebServerSystem.java | 16 +- .../response/pages/DebugPageResponse.java | 17 +- .../response/pages/PlayersPageResponse.java | 26 ++- .../plan/system/webserver/webapi/WebAPI.java | 1 + .../webserver/webapi/WebAPIManager.java | 4 +- .../webapi/bungee/PostHtmlWebAPI.java | 4 +- .../com/djrapitops/plan/systems/Systems.java | 135 ------------ .../plan/systems/cache/DataCache.java | 14 +- .../plan/systems/cache/SessionCache.java | 7 +- .../info/BukkitInformationManager.java | 16 +- .../info/BungeeInformationManager.java | 8 +- ...lysisPageParser.java => AnalysisPage.java} | 6 +- ...nspectPageParser.java => InspectPage.java} | 6 +- ...etworkPageParser.java => NetworkPage.java} | 24 +-- .../parsing/{PageParser.java => Page.java} | 6 +- .../djrapitops/plan/utilities/MiscUtils.java | 5 +- .../utilities/analysis/AnalysisUtils.java | 9 +- .../utilities/file/export/HtmlExport.java | 25 +-- .../utilities/file/export/SpecificExport.java | 1 + .../plan/utilities/html/HtmlStructure.java | 2 +- .../plan/utilities/html/HtmlUtils.java | 4 +- .../structure/SessionTabStructureCreator.java | 3 +- .../html/tables/KillsTableCreator.java | 3 +- .../html/tables/PlayersTableCreator.java | 6 +- .../html/tables/SessionsTableCreator.java | 3 +- .../plan/system/database/DatabaseTest.java | 22 +- 70 files changed, 760 insertions(+), 429 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/{IPsTable.java => GeoInfoTable.java} (98%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/systems/Systems.java rename Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/{AnalysisPageParser.java => AnalysisPage.java} (88%) rename Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/{InspectPageParser.java => InspectPage.java} (98%) rename Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/{NetworkPageParser.java => NetworkPage.java} (83%) rename Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/{PageParser.java => Page.java} (87%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 54ced8353f..e4bb731eb3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -37,8 +37,6 @@ 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.system.webserver.pagecache.ResponseCache; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.GeolocationCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; @@ -74,8 +72,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { private BukkitSystem system; - - private Systems systems; private HookHandler hookHandler; // Manages 3rd party data sources @@ -110,7 +106,6 @@ public UUID getServerUuid() { public void onEnable() { super.onEnable(); try { - systems = new Systems(this); FileSystem.getInstance().enable(); ConfigSystem.getInstance().enable(); @@ -205,10 +200,7 @@ public ColorScheme getColorScheme() { */ @Override public void onDisable() { - //Clears the page cache - ResponseCache.clearCache(); - - systems.close(); + system.disable(); Log.info(Locale.get(Msg.DISABLED).toString()); Benchmark.pluginDisabled(Plan.class); @@ -334,10 +326,6 @@ public void saveDefaultConfig() { throw new IllegalStateException("This method should be used on this plugin."); } - public Systems getSystems() { - return systems; - } - public BukkitSystem getSystem() { return system; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index a10d8cd208..753aabe8f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -19,7 +19,6 @@ 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.Systems; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; @@ -44,7 +43,7 @@ */ public class PlanBungee extends BungeePlugin implements PlanPlugin { - private Systems systems; + private BungeeSystem system; private BungeeServerInfoManager serverInfoManager; private BungeeInformationManager infoManager; @@ -52,13 +51,11 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { @Deprecated private boolean setupAllowed = false; - private BungeeSystem system; @Override public void onEnable() { super.onEnable(); try { - systems = new Systems(this); FileSystem.getInstance().enable(); ConfigSystem.getInstance().enable(); @@ -108,7 +105,8 @@ public static PlanBungee getInstance() { @Override public void onDisable() { - systems.close(); + system.disable(); + Log.info(Locale.get(Msg.DISABLED).toString()); Benchmark.pluginDisabled(PlanBungee.class); DebugLog.pluginDisabled(PlanBungee.class); @@ -173,11 +171,6 @@ public UUID getServerUuid() { return serverInfoManager.getServerUUID(); } - @Override - public Systems getSystems() { - return systems; - } - public boolean isSetupAllowed() { return setupAllowed; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index de932c1e9b..c3f16e0143 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -8,7 +8,6 @@ import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.WebServer; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.api.Check; @@ -55,9 +54,6 @@ public interface PlanPlugin extends IPlugin { ColorScheme getColorScheme(); - @Deprecated - Systems getSystems(); - boolean isReloading(); static PlanPlugin getInstance() { diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java index ed891f7af2..b9cdd4270b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/ParseException.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.api.exceptions; /** - * Exception thrown when PageParser encounters an Exception. + * Exception thrown when Page encounters an Exception. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 6166606457..10d9f28aa5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -1,6 +1,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; @@ -48,12 +49,12 @@ public AnalyzeCommand(Plan plugin) { infoManager = plugin.getInfoManager(); } - public static void sendAnalysisMessage(Collection senders, UUID serverUUID) throws SQLException { + public static void sendAnalysisMessage(Collection senders, UUID serverUUID) throws DBException { if (Verify.isEmpty(senders)) { return; } Plan plugin = Plan.getInstance(); - Optional serverName = plugin.getDB().getServerTable().getServerName(serverUUID); + Optional serverName = plugin.getDB().fetch().getServerName(serverUUID); serverName.ifPresent(name -> { String target = "/server/" + name; String url = plugin.getInfoManager().getLinkTo(target); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 8822ee8e46..0415241449 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -82,7 +82,7 @@ public void run() { sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); } } - plugin.addToProcessQueue(new InspectCacheRequestProcessor(uuid, sender, playerName)); + new InspectCacheRequestProcessor(uuid, sender, playerName).queue(); } catch (DBException ex) { if (ex instanceof FatalDBException) { Log.toLog(this.getClass().getName(), ex); 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 0ecc3a5638..3b8851fce2 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,5 +1,6 @@ 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.settings.Permissions; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java index 3bd8b92a97..20473945e2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java @@ -1,5 +1,6 @@ package com.djrapitops.plan.data; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.StickyData; import com.djrapitops.plan.data.container.TPS; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java index 58e8c775a2..d7856667ba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 04efebdbd8..9f5346436f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -12,6 +12,8 @@ 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.WebServerSystem; +import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Check; @@ -26,6 +28,7 @@ public abstract class PlanSystem implements SubSystem { // Initialized in this class protected final ProcessingQueue processingQueue; + protected final WebServerSystem webServerSystem; // These need to be initialized in the sub class. protected VersionCheckSystem versionCheckSystem; @@ -38,6 +41,7 @@ public abstract class PlanSystem implements SubSystem { public PlanSystem() { processingQueue = new ProcessingQueue(); + webServerSystem = new WebServerSystem(); } @Override @@ -131,4 +135,12 @@ public ListenerSystem getListenerSystem() { public TaskSystem getTaskSystem() { return taskSystem; } + + public WebServerSystem getWebServerSystem() { + return webServerSystem; + } + + public ServerInfo getServerInfo() { + return null; // TODO + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index 387a446e37..511b6df65a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -5,19 +5,18 @@ package com.djrapitops.plan.system.database; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; 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.sql.SQLDB; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; -import java.sql.SQLException; import java.util.HashSet; import java.util.Set; @@ -28,8 +27,8 @@ */ public abstract class DBSystem implements SubSystem { - protected SQLDB db; - protected Set databases; + protected Database db; + protected Set databases; public DBSystem() { databases = new HashSet<>(); @@ -49,7 +48,7 @@ public void enable() throws EnableException { initDatabase(); db.scheduleClean(10L); Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName())); - Benchmark.stop("Systems", "Init Database"); + Benchmark.stop("Enable", "Init Database"); } catch (DBInitException e) { throw new EnableException(db.getName() + "-Database failed to initialize", e); } @@ -57,11 +56,11 @@ public void enable() throws EnableException { protected abstract void initDatabase() throws DBInitException; - public Set getDatabases() { + public Set getDatabases() { return databases; } - public void setDatabases(Set databases) { + public void setDatabases(Set databases) { this.databases = databases; } @@ -71,7 +70,7 @@ public void disable() { if (db != null) { db.close(); } - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } @@ -80,8 +79,8 @@ public Database getActiveDatabase() { return db; } - public SQLDB getActiveDatabase(String dbName) throws DBInitException { - for (SQLDB database : getDatabases()) { + public Database getActiveDatabase(String dbName) throws DBInitException { + for (Database database : getDatabases()) { String dbConfigName = database.getConfigName(); if (Verify.equalsIgnoreCase(dbName, dbConfigName)) { database.init(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index fe3c5b5c4d..2390a4e114 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -34,6 +34,12 @@ public static Database getActive() { public abstract RemoveOperations remove(); + public abstract SearchOperations search(); + + public abstract CountOperations count(); + + public abstract SaveOperations save(); + /** * Used to get the name of the database type. *

@@ -60,7 +66,5 @@ public boolean isOpen() { return open; } - public abstract SearchOperations search(); - - public abstract CountOperations count(); + public abstract void scheduleClean(long delay); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java index ff8ecb763c..d24f5f8bc8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java @@ -1,6 +1,7 @@ package com.djrapitops.plan.system.database.databases.operation; import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.PlanSystem; import java.util.UUID; @@ -12,4 +13,7 @@ public interface CheckOperations { boolean doesWebUserExists(String username) throws DBException; + default boolean isPlayerRegisteredOnThisServer(UUID player) throws DBException { + return isPlayerRegistered(player, PlanSystem.getInstance().getServerInfo().getUuid()); + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java index 4d039f2ba0..8ab728d064 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CountOperations.java @@ -6,6 +6,7 @@ public interface CountOperations { - int serverPlayerCount(UUID server) throws DBException; + int getServerPlayerCount(UUID server) throws DBException; + int getNetworkPlayerCount() throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 700ea2beba..9f7b7ac584 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -4,14 +4,14 @@ import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.data.container.*; import java.util.*; public interface FetchOperations { // Profiles - + ServerProfile getServerProfile(UUID serverUUID) throws DBException; List getPlayers(UUID serverUUID) throws DBException; @@ -19,7 +19,7 @@ public interface FetchOperations { PlayerProfile getPlayerProfile(UUID uuid) throws DBException; // UUIDs - + Set getSavedUUIDs() throws DBException; Set getSavedUUIDs(UUID server) throws DBException; @@ -37,4 +37,36 @@ public interface FetchOperations { // Raw Data List getTPSData(UUID serverUUID) throws DBException; + + List getNetworkOnlineData() throws DBException; + + List getRegisterDates() throws DBException; + + Optional getAllTimePeak(UUID serverUUID) throws DBException; + + Optional getPeakPlayerCount(UUID serverUUID, long afterDate) throws DBException; + + Map>> getSessionsWithNoExtras() throws DBException; + + Map>> getSessionsAndExtras() throws DBException; + + Set getWorldNames(UUID serverUuid) throws DBException; + + List getNicknamesOfPlayerOnServer(UUID uuid, UUID serverUUID) throws DBException; + + List getActions(UUID uuid) throws DBException; + + Map getUsers() throws DBException; + + Map getLastSeenForAllPlayers() throws DBException; + + Map> getAllGeoInfo() throws DBException; + + Map getPlayerNames() throws DBException; + + String getPlayerName(UUID playerUUID) throws DBException; + + Optional getServerName(UUID serverUUID) throws DBException; + + List getNicknames(UUID uuid) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java new file mode 100644 index 0000000000..e450704567 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java @@ -0,0 +1,65 @@ +/* + * 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.database.databases.operation; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.container.*; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public interface SaveOperations { + + // Bulk save + + void insertTPS(Map> ofServers) throws DBException; + + void insertCommandUsage(Map> ofServers) throws DBException; + + void insertUsers(Map ofServers) throws DBException; + + void insertSessions(Map>> ofServers, boolean containsExtraData) + throws DBException; + + void kickAmount(Map ofUsers) throws DBException; + + void insertUserInfo(Map> ofServers) throws DBException; + + void insertNicknames(Map>> ofServers) throws DBException; + + void insertAllGeoInfo(Map> ofUsers) throws DBException; + + // Single data point + + void banStatus(UUID uuid, boolean banned) throws DBException; + + void opStatus(UUID uuid, boolean op) throws DBException; + + void registerNewUser(UUID uuid, long registered, String name) throws DBException; + + void action(UUID uuid, Action action) throws DBException; + + void geoInfo(UUID uuid, GeoInfo geoInfo) throws DBException; + + void playerWasKicked(UUID uuid) throws DBException; + + void playerName(UUID uuid, String playerName) throws DBException; + + void playerDisplayName(UUID uuid, String displayName) throws DBException; + + void registerNewUserOnThisServer(UUID uuid, long registered) throws DBException; + + void commandUsed(String commandName) throws DBException; + + void insertTPSforThisServer(TPS tps) throws DBException; + + void session(UUID uuid, Session session) throws DBException; +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java index a6e564b19d..a4662b1e38 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SearchOperations.java @@ -6,6 +6,6 @@ public interface SearchOperations { - List matchingNames(String search) throws DBException; + List matchingPlayers(String search) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index e015bda413..5e65123edc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -31,7 +31,7 @@ public abstract class SQLDB extends Database { private final KillsTable killsTable; private final NicknamesTable nicknamesTable; private final SessionsTable sessionsTable; - private final IPsTable ipsTable; + private final GeoInfoTable geoInfoTable; private final CommandUseTable commandUseTable; private final TPSTable tpsTable; private final VersionTable versionTable; @@ -46,6 +46,7 @@ public abstract class SQLDB extends Database { private final SQLRemoveOps removeOps; private final SQLSearchOps searchOps; private final SQLCountOps countOps; + private final SQLSaveOps saveOps; private final boolean usingMySQL; private boolean open = false; @@ -64,7 +65,7 @@ public SQLDB() { usersTable = new UsersTable(this); userInfoTable = new UserInfoTable(this); actionsTable = new ActionsTable(this); - ipsTable = new IPsTable(this); + geoInfoTable = new GeoInfoTable(this); nicknamesTable = new NicknamesTable(this); sessionsTable = new SessionsTable(this); killsTable = new KillsTable(this); @@ -77,6 +78,7 @@ public SQLDB() { removeOps = new SQLRemoveOps(this); countOps = new SQLCountOps(this); searchOps = new SQLSearchOps(this); + saveOps = new SQLSaveOps(this); } /** @@ -162,11 +164,11 @@ public void run() { } if (version < 12) { actionsTable.alterTableV12(); - ipsTable.alterTableV12(); + geoInfoTable.alterTableV12(); versionTable.setVersion(12); } if (version < 13) { - ipsTable.alterTableV13(); + geoInfoTable.alterTableV13(); versionTable.setVersion(13); } } catch (SQLException e) { @@ -194,7 +196,7 @@ private void createTables() throws DBInitException { */ public Table[] getAllTables() { return new Table[]{ - serverTable, usersTable, userInfoTable, ipsTable, + serverTable, usersTable, userInfoTable, geoInfoTable, nicknamesTable, sessionsTable, killsTable, commandUseTable, actionsTable, tpsTable, worldTable, worldTimesTable, securityTable @@ -208,7 +210,7 @@ public Table[] getAllTables() { */ public Table[] getAllTablesInRemoveOrder() { return new Table[]{ - ipsTable, nicknamesTable, killsTable, + geoInfoTable, nicknamesTable, killsTable, worldTimesTable, sessionsTable, actionsTable, worldTable, userInfoTable, usersTable, commandUseTable, tpsTable, securityTable, @@ -303,8 +305,8 @@ public KillsTable getKillsTable() { return killsTable; } - public IPsTable getIpsTable() { - return ipsTable; + public GeoInfoTable getGeoInfoTable() { + return geoInfoTable; } public NicknamesTable getNicknamesTable() { @@ -376,4 +378,9 @@ public SearchOperations search() { public CountOperations count() { return countOps; } + + @Override + public SaveOperations save() { + return saveOps; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java index da435bbda2..32537b4d9c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java @@ -15,11 +15,20 @@ public SQLCountOps(SQLDB db) { } @Override - public int serverPlayerCount(UUID server) throws DBException { + public int getServerPlayerCount(UUID server) throws DBException { try { return userInfoTable.getServerUserCount(server); } catch (SQLException e) { throw ErrorUtil.getExceptionFor(e); } } + + @Override + public int getNetworkPlayerCount() throws DBException { + try { + return usersTable.getPlayerCount(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index e1c30b7a28..1905375d8f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -55,7 +55,7 @@ public List getPlayers(UUID serverUUID) throws DBException { List serverUserInfo = userInfoTable.getServerUserInfo(serverUUID); Map timesKicked = usersTable.getAllTimesKicked(); Map> actions = actionsTable.getServerActions(serverUUID); - Map> geoInfo = ipsTable.getAllGeoInfo(); + Map> geoInfo = geoInfoTable.getAllGeoInfo(); Map> sessions = sessionsTable.getSessionInfoOfServer(serverUUID); Map>> map = new HashMap<>(); @@ -109,7 +109,7 @@ public PlayerProfile getPlayerProfile(UUID uuid) throws DBException { profile.setActions(actionsTable.getActions(uuid)); profile.setNicknames(nicknamesTable.getAllNicknames(uuid)); - profile.setGeoInformation(ipsTable.getGeoInfo(uuid)); + profile.setGeoInformation(geoInfoTable.getGeoInfo(uuid)); Map> sessions = sessionsTable.getSessions(uuid); profile.setSessions(sessions); @@ -201,4 +201,121 @@ public List getTPSData(UUID serverUUID) throws DBException { throw ErrorUtil.getExceptionFor(e); } } + + @Override + public List getNetworkOnlineData() throws DBException { + try { + return tpsTable.getNetworkOnlineData(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public List getRegisterDates() throws DBException { + try { + return usersTable.getRegisterDates(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Optional getAllTimePeak(UUID serverUUID) throws DBException { + try { + return tpsTable.getAllTimePeak(serverUUID); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Optional getPeakPlayerCount(UUID serverUUID, long afterDate) throws DBException { + try { + return tpsTable.getPeakPlayerCount(serverUUID, afterDate); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map>> getSessionsWithNoExtras() throws DBException { + try { + return sessionsTable.getAllSessions(false); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map>> getSessionsAndExtras() throws DBException { + try { + return sessionsTable.getAllSessions(true); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Set getWorldNames(UUID serverUuid) throws DBException { + try { + return worldTable.getWorldNames(serverUuid); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public List getNicknamesOfPlayerOnServer(UUID uuid, UUID serverUUID) throws DBException { + try { + return nicknamesTable.getNicknames(uuid, serverUUID); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public List getActions(UUID uuid) throws DBException { + try { + return actionsTable.getActions(uuid); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getUsers() throws DBException { + try { + return usersTable.getUsers(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getLastSeenForAllPlayers() throws DBException { + try { + return sessionsTable.getLastSeenForAllPlayers(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map> getAllGeoInfo() throws DBException { + try { + return geoInfoTable.getAllGeoInfo(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getPlayerNames() throws DBException { + try { + return usersTable.getPlayerNames(); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java index 62d7655755..406537830d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java @@ -13,7 +13,7 @@ public class SQLOps { protected final KillsTable killsTable; protected final NicknamesTable nicknamesTable; protected final SessionsTable sessionsTable; - protected final IPsTable ipsTable; + protected final GeoInfoTable geoInfoTable; protected final CommandUseTable commandUseTable; protected final TPSTable tpsTable; protected final SecurityTable securityTable; @@ -30,7 +30,7 @@ public SQLOps(SQLDB db) { killsTable = db.getKillsTable(); nicknamesTable = db.getNicknamesTable(); sessionsTable = db.getSessionsTable(); - ipsTable = db.getIpsTable(); + geoInfoTable = db.getGeoInfoTable(); commandUseTable = db.getCommandUseTable(); tpsTable = db.getTpsTable(); securityTable = db.getSecurityTable(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java new file mode 100644 index 0000000000..6f0e9add4b --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java @@ -0,0 +1,199 @@ +/* + * 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.database.databases.sql.operation; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.container.*; +import com.djrapitops.plan.system.database.databases.operation.SaveOperations; +import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class SQLSaveOps extends SQLOps implements SaveOperations { + + public SQLSaveOps(SQLDB db) { + super(db); + } + + @Override + public void insertTPS(Map> ofServers) throws DBException { + try { + tpsTable.insertAllTPS(ofServers); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void insertCommandUsage(Map> ofServers) throws DBException { + try { + commandUseTable.insertCommandUsage(ofServers); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void insertUsers(Map ofServers) throws DBException { + try { + usersTable.insertUsers(ofServers); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void insertSessions(Map>> ofServers, boolean containsExtraData) throws DBException { + try { + sessionsTable.insertSessions(ofServers, containsExtraData); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void kickAmount(Map ofUsers) throws DBException { + try { + usersTable.updateKicked(ofUsers); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void insertUserInfo(Map> ofServers) throws DBException { + try { + userInfoTable.insertUserInfo(ofServers); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void insertNicknames(Map>> ofServers) throws DBException { + try { + nicknamesTable.insertNicknames(ofServers); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void insertAllGeoInfo(Map> ofUsers) throws DBException { + try { + geoInfoTable.insertAllGeoInfo(ofUsers); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void banStatus(UUID uuid, boolean banned) throws DBException { + try { + userInfoTable.updateBanStatus(uuid, banned); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void opStatus(UUID uuid, boolean op) throws DBException { + try { + userInfoTable.updateOpStatus(uuid, op); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void registerNewUser(UUID uuid, long registered, String name) throws DBException { + try { + usersTable.registerUser(uuid, registered, name); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void action(UUID uuid, Action action) throws DBException { + try { + actionsTable.insertAction(uuid, action); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void geoInfo(UUID uuid, GeoInfo geoInfo) throws DBException { + try { + geoInfoTable.saveGeoInfo(uuid, geoInfo); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void playerWasKicked(UUID uuid) throws DBException { + try { + usersTable.kicked(uuid); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void playerName(UUID uuid, String playerName) throws DBException { + try { + usersTable.updateName(uuid, playerName); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void playerDisplayName(UUID uuid, String displayName) throws DBException { + try { + nicknamesTable.saveUserName(uuid, displayName); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void registerNewUserOnThisServer(UUID uuid, long registered) throws DBException { + try { + userInfoTable.registerUserInfo(uuid, registered); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void commandUsed(String commandName) throws DBException { + try { + commandUseTable.commandUsed(commandName); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public void insertTPSforThisServer(TPS tps) throws DBException { + try { + tpsTable.insertTPS(tps); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java index cf074ce51d..fca34c47fd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java @@ -15,7 +15,7 @@ public SQLSearchOps(SQLDB db) { } @Override - public List matchingNames(String search) throws DBException { + public List matchingPlayers(String search) throws DBException { try { return usersTable.getMatchingNames(search); } catch (SQLException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/IPsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/GeoInfoTable.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/IPsTable.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/GeoInfoTable.java index 27e5746356..a78a78a543 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/IPsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/GeoInfoTable.java @@ -19,14 +19,14 @@ /** * @author Rsl1122 */ -public class IPsTable extends UserIDTable { +public class GeoInfoTable extends UserIDTable { private final String columnIP = "ip"; private final String columnGeolocation = "geolocation"; private final String columnLastUsed = "last_used"; private String insertStatement; - public IPsTable(SQLDB db) { + public GeoInfoTable(SQLDB db) { super("plan_ips", db); insertStatement = "INSERT INTO " + tableName + " (" + columnUserID + ", " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java index d887abba07..9a1804aaec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java @@ -105,17 +105,30 @@ public Boolean processResults(ResultSet set) throws SQLException { }); } - public void updateOpAndBanStatus(UUID uuid, boolean opped, boolean banned) throws SQLException { - String sql = Update.values(tableName, columnOP, columnBanned) + public void updateOpStatus(UUID uuid, boolean op) throws SQLException { + String sql = Update.values(tableName, columnOP) .where(columnUserID + "=" + usersTable.statementSelectID) .toString(); execute(new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { - statement.setBoolean(1, opped); - statement.setBoolean(2, banned); - statement.setString(3, uuid.toString()); + statement.setBoolean(1, op); + statement.setString(2, uuid.toString()); + } + }); + } + + public void updateBanStatus(UUID uuid, boolean banned) throws SQLException { + String sql = Update.values(tableName, columnBanned) + .where(columnUserID + "=" + usersTable.statementSelectID) + .toString(); + + execute(new ExecStatement(sql) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setBoolean(1, banned); + statement.setString(2, uuid.toString()); } }); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java index ac0558457d..b065808cec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java @@ -115,7 +115,7 @@ public void copyIPsAndGeolocs(BatchOperationTable toDB) throws SQLException { return; } Log.debug("Batch Copy IPs, Geolocations & Last used dates"); - toDB.getDb().getIpsTable().insertAllGeoInfo(db.getIpsTable().getAllGeoInfo()); + toDB.getDb().getGeoInfoTable().insertAllGeoInfo(db.getGeoInfoTable().getAllGeoInfo()); } public void copyNicknames(BatchOperationTable toDB) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java index 6fb9a502a5..ae7d382432 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java @@ -58,7 +58,7 @@ public void alterTablesToV10() throws SQLException, DBCreateTableException { copyUsers(); execute(dropTableSql("plan_ips")); - db.getIpsTable().createTable(); + db.getGeoInfoTable().createTable(); execute(dropTableSql("plan_world_times")); execute(dropTableSql("plan_worlds")); db.getWorldTable().createTable(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java index 53c0ba6455..d0e4e2588a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java @@ -53,7 +53,7 @@ public void onChat(AsyncPlayerChatEvent event) { dataCache.firstSessionMessageSent(uuid); } - plugin.addToProcessQueue(new NameProcessor(uuid, name, displayName)); + new NameProcessor(uuid, name, displayName).queue(); } catch (Exception e) { Log.toLog(this.getClass(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java index 0a20f3dec6..f97de50b09 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/CommandPreprocessListener.java @@ -69,7 +69,7 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent event) { commandName = command.getName(); } } - plugin.addToProcessQueue(new CommandProcessor(commandName)); + new CommandProcessor(commandName).queue(); } catch (Exception e) { Log.toLog(this.getClass(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java index 9a3545f261..71555aea77 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java @@ -58,19 +58,27 @@ public void onDeath(EntityDeathEvent event) { EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) entityDamageEvent; Entity killerEntity = entityDamageByEntityEvent.getDamager(); - if (killerEntity instanceof Player) { - handlePlayerKill(time, dead, (Player) killerEntity); - } else if (killerEntity instanceof Wolf) { - handleWolfKill(time, dead, (Wolf) killerEntity); - } else if (killerEntity instanceof Arrow) { - handleArrowKill(time, dead, (Arrow) killerEntity); - } + handleKill(time, dead, killerEntity); } catch (Exception e) { Log.toLog(this.getClass(), e); } } - private void handlePlayerKill(long time, LivingEntity dead, Player killer) { + private void handleKill(long time, LivingEntity dead, Entity killerEntity) { + KillProcessor processor = null; + if (killerEntity instanceof Player) { + processor = handlePlayerKill(time, dead, (Player) killerEntity); + } else if (killerEntity instanceof Wolf) { + processor = handleWolfKill(time, dead, (Wolf) killerEntity); + } else if (killerEntity instanceof Arrow) { + processor = handleArrowKill(time, dead, (Arrow) killerEntity); + } + if (processor != null) { + processor.queue(); + } + } + + private KillProcessor handlePlayerKill(long time, LivingEntity dead, Player killer) { Material itemInHand; try { itemInHand = killer.getInventory().getItemInMainHand().getType(); @@ -82,31 +90,31 @@ private void handlePlayerKill(long time, LivingEntity dead, Player killer) { } } - plugin.addToProcessQueue(new KillProcessor(killer.getUniqueId(), time, dead, normalizeMaterialName(itemInHand))); + return new KillProcessor(killer.getUniqueId(), time, dead, normalizeMaterialName(itemInHand)); } - private void handleWolfKill(long time, LivingEntity dead, Wolf wolf) { + private KillProcessor handleWolfKill(long time, LivingEntity dead, Wolf wolf) { if (!wolf.isTamed()) { - return; + return null; } AnimalTamer owner = wolf.getOwner(); if (!(owner instanceof Player)) { - return; + return null; } - plugin.addToProcessQueue(new KillProcessor(owner.getUniqueId(), time, dead, "Wolf")); + return new KillProcessor(owner.getUniqueId(), time, dead, "Wolf"); } - private void handleArrowKill(long time, LivingEntity dead, Arrow arrow) { + private KillProcessor handleArrowKill(long time, LivingEntity dead, Arrow arrow) { ProjectileSource source = arrow.getShooter(); if (!(source instanceof Player)) { - return; + return null; } Player player = (Player) source; - plugin.addToProcessQueue(new KillProcessor(player.getUniqueId(), time, dead, "Bow")); + return new KillProcessor(player.getUniqueId(), time, dead, "Bow"); } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java index 7a97f7a618..bdcc5bac36 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bungee/PlayerOnlineListener.java @@ -36,7 +36,7 @@ public void onPostLogin(PostLoginEvent event) { String name = player.getName(); long now = MiscUtils.getTime(); - plugin.getSystem().getProcessingQueue().addToQueue(new BungeePlayerRegisterProcessor(uuid, name, now)); + plugin.getSystem().getProcessingQueue().queue(new BungeePlayerRegisterProcessor(uuid, name, now)); } catch (Exception e) { Log.toLog(this.getClass(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index ddf5fe84f5..0f8dd49c0f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -52,7 +52,7 @@ public void disable() { public void run() { ProcessingQueue que = ProcessingQueue.getInstance(); for (Processor processor : processors) { - que.addToQueue(processor); + que.queue(processor); } cancel(); } @@ -70,9 +70,9 @@ public void run() { * * @param processor processing object. */ - public void addToQueue(Processor processor) { + public void queue(Processor processor) { if (!queue.offer(processor)) { - Log.toLog("ProcessingQueue.addToQueue", new IllegalStateException("Processor was not added to Queue")); + Log.toLog("ProcessingQueue.queue", new IllegalStateException("Processor was not added to Queue")); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java index 00a01bc37e..e107873c72 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java @@ -4,11 +4,10 @@ */ package com.djrapitops.plan.system.processing.processors; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; - /** * Updates Command usage amount in the database. * @@ -23,8 +22,8 @@ public CommandProcessor(String object) { @Override public void process() { try { - Plan.getInstance().getDB().getCommandUseTable().commandUsed(object); - } catch (SQLException e) { + Database.getActive().save().commandUsed(object); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java index ca81b41dde..f47a9f7746 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java @@ -4,15 +4,15 @@ */ package com.djrapitops.plan.system.processing.processors; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -39,8 +39,8 @@ public void process() { Action action = new Action(MiscUtils.getTime(), Actions.NEW_NICKNAME, info); try { - Plan.getInstance().getDB().getActionsTable().insertAction(uuid, action); - } catch (SQLException e) { + Database.getActive().save().action(uuid, action); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java index 88575dcd8b..15ececd2a8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java @@ -24,11 +24,14 @@ public T getObject() { return object; } - public void que() { - que(this); + public void queue() { + queue(this); } - public static void que(Processor processor) { - ProcessingQueue.getInstance().addToQueue(processor); + public static void queue(Processor... processors) { + ProcessingQueue processingQueue = ProcessingQueue.getInstance(); + for (Processor processor : processors) { + processingQueue.queue(processor); + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java index 7b3664a26e..ac30c9fa5d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java @@ -4,12 +4,12 @@ */ package com.djrapitops.plan.system.processing.processors; -import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.List; /** @@ -36,8 +36,8 @@ public void process() { TPS tps = new TPS(lastDate, averageTPS, averagePlayersOnline, averageCPUUsage, averageUsedMemory, averageEntityCount, averageChunksLoaded); try { - PlanPlugin.getInstance().getDB().getTpsTable().insertTPS(tps); - } catch (SQLException e) { + Database.getActive().save().insertTPSforThisServer(tps); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } 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/processors/importing/importers/Importer.java index dc1cce8f3c..e9e4d84c63 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/processors/importing/importers/Importer.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.processing.processors.importing.importers; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; @@ -20,7 +21,6 @@ import com.djrapitops.plugin.utilities.Verify; import com.google.common.collect.ImmutableMap; -import java.sql.SQLException; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -59,7 +59,7 @@ void execute() { new ImportExecutorHelper() { @Override - void execute() throws SQLException { + void execute() throws DBException { Benchmark.start(userDataBenchmarkName); processUserData(); Benchmark.stop(userDataBenchmarkName); @@ -104,15 +104,15 @@ private void processServerData() { new ImportExecutorHelper() { @Override - void execute() { - db.getTpsTable().insertAllTPS(ImmutableMap.of(uuid, serverImportData.getTpsData())); + void execute() throws DBException { + db.save().insertTPS(ImmutableMap.of(uuid, serverImportData.getTpsData())); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() { - db.getCommandUseTable().insertCommandUsage(ImmutableMap.of(uuid, serverImportData.getCommandUsages())); + void execute() throws DBException { + db.save().insertCommandUsage(ImmutableMap.of(uuid, serverImportData.getCommandUsages())); } }.submit(service); @@ -129,7 +129,7 @@ void execute() { Benchmark.stop(benchmarkName); } - private void processUserData() { + private void processUserData() throws DBException { String benchmarkName = "Processing User Data"; String getDataBenchmarkName = "Getting User Data"; String insertDataIntoCollectionsBenchmarkName = "Insert User Data into Collections"; @@ -190,40 +190,40 @@ private void processUserData() { Benchmark.start(insertDataIntoDatabaseBenchmarkName); - db.getUsersTable().insertUsers(users); + db.save().insertUsers(users); new ImportExecutorHelper() { @Override - void execute() { - db.getSessionsTable().insertSessions(ImmutableMap.of(serverUUID, sessions), true); + void execute() throws DBException { + db.save().insertSessions(ImmutableMap.of(serverUUID, sessions), true); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() { - db.getUsersTable().updateKicked(timesKicked); + void execute() throws DBException { + db.save().kickAmount(timesKicked); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() { - db.getUserInfoTable().insertUserInfo(ImmutableMap.of(serverUUID, userInfo)); + void execute() throws DBException { + db.save().insertUserInfo(ImmutableMap.of(serverUUID, userInfo)); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() { - db.getNicknamesTable().insertNicknames(ImmutableMap.of(serverUUID, nickNames)); + void execute() throws DBException { + db.save().insertNicknames(ImmutableMap.of(serverUUID, nickNames)); } }.submit(service); new ImportExecutorHelper() { @Override - void execute() { - db.getIpsTable().insertAllGeoInfo(geoInfo); + void execute() throws DBException { + db.save().insertAllGeoInfo(geoInfo); } }.submit(service); @@ -273,7 +273,7 @@ private List convertGeoInfo(UserImportData userImportData) { } private abstract class ImportExecutorHelper { - abstract void execute() throws SQLException; + abstract void execute() throws DBException; void submit(ExecutorService service) { service.submit(new Runnable() { @@ -281,7 +281,7 @@ void submit(ExecutorService service) { public void run() { try { execute(); - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BanAndOpProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BanAndOpProcessor.java index 6f1382759c..45e479f03f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BanAndOpProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BanAndOpProcessor.java @@ -4,10 +4,11 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.operation.SaveOperations; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -30,8 +31,10 @@ public BanAndOpProcessor(UUID uuid, boolean banned, boolean op) { public void process() { UUID uuid = getUUID(); try { - Plan.getInstance().getDB().getUserInfoTable().updateOpAndBanStatus(uuid, opped, banned); - } catch (SQLException e) { + SaveOperations save = Database.getActive().save(); + save.banStatus(uuid, banned); + save.opStatus(uuid, opped); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java index bf33ec617c..995b6d8f0d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/BungeePlayerRegisterProcessor.java @@ -4,11 +4,10 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -30,13 +29,13 @@ public BungeePlayerRegisterProcessor(UUID uuid, String name, long registered) { @Override public void process() { UUID uuid = getUUID(); - UsersTable usersTable = PlanBungee.getInstance().getDB().getUsersTable(); + Database database = Database.getActive(); try { - if (usersTable.isRegistered(uuid)) { + if (database.check().isPlayerRegistered(uuid)) { return; } - usersTable.registerUser(uuid, registered, name); - } catch (SQLException e) { + database.save().registerNewUser(uuid, registered, name); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java index aff15ce6c3..f010de8378 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java @@ -5,11 +5,12 @@ package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -32,8 +33,8 @@ public void process() { Plan plugin = Plan.getInstance(); UUID uuid = getUUID(); try { - plugin.getDB().getActionsTable().insertAction(uuid, leaveAction); - } catch (SQLException e) { + Database.getActive().save().action(uuid, leaveAction); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } finally { plugin.getDataCache().endFirstSessionActionTracking(uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java index c1b5cc17ac..a42c4d9fc2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java @@ -4,12 +4,12 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.GeoInfo; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.systems.cache.GeolocationCache; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -33,8 +33,8 @@ public void process() { UUID uuid = getUUID(); String country = GeolocationCache.getCountry(ip); try { - Plan.getInstance().getDB().getIpsTable().saveGeoInfo(uuid, new GeoInfo(ip, country, time)); - } catch (SQLException e) { + Database.getActive().save().geoInfo(uuid, new GeoInfo(ip, country, time)); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KickProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KickProcessor.java index 79361ae929..45298f4d78 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KickProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KickProcessor.java @@ -4,10 +4,10 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -24,8 +24,8 @@ public KickProcessor(UUID uuid) { public void process() { UUID uuid = getUUID(); try { - Plan.getInstance().getDB().getUsersTable().kicked(uuid); - } catch (SQLException e) { + Database.getActive().save().playerWasKicked(uuid); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java index 307f598ac2..421f6106fb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java @@ -5,13 +5,13 @@ package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.sql.tables.NicknamesTable; +import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor; import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.List; import java.util.UUID; @@ -45,30 +45,24 @@ public void process() { return; } - Database db = plugin.getDB(); - NicknamesTable nicknamesTable = db.getNicknamesTable(); - cueNameChangeActionProcessor(uuid, plugin, nicknamesTable); - + Database database = Database.getActive(); try { - db.getUsersTable().updateName(uuid, playerName); + cueNameChangeActionProcessor(uuid, database); + database.save().playerName(uuid, playerName); - nicknamesTable.saveUserName(uuid, displayName); - } catch (SQLException e) { + database.save().playerDisplayName(uuid, displayName); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } dataCache.updateNames(uuid, playerName, displayName); } - private void cueNameChangeActionProcessor(UUID uuid, Plan plugin, NicknamesTable nicknamesTable) { - try { - List nicknames = nicknamesTable.getNicknames(uuid, Plan.getServerUUID()); - if (nicknames.contains(displayName)) { - return; - } - plugin.addToProcessQueue(new NewNickActionProcessor(uuid, displayName)); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); + private void cueNameChangeActionProcessor(UUID uuid, Database db) throws DBException { + List nicknames = db.fetch().getNicknamesOfPlayerOnServer(uuid, Plan.getServerUUID()); + if (nicknames.contains(displayName)) { + return; } + ProcessingQueue.getInstance().queue(new NewNickActionProcessor(uuid, displayName)); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index 8918e43e7b..2b8573bff8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java @@ -5,15 +5,13 @@ package com.djrapitops.plan.system.processing.processors.player; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.sql.tables.UserInfoTable; -import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.UUID; /** @@ -42,25 +40,23 @@ public RegisterProcessor(UUID uuid, long registered, long time, String name, int public void process() { UUID uuid = getUUID(); Plan plugin = Plan.getInstance(); - Database db = plugin.getDB(); - UsersTable usersTable = db.getUsersTable(); - UserInfoTable userInfoTable = db.getUserInfoTable(); + Database db = Database.getActive(); try { - if (!usersTable.isRegistered(uuid)) { - usersTable.registerUser(uuid, registered, name); + if (!db.check().isPlayerRegistered(uuid)) { + db.save().registerNewUser(uuid, registered, name); } - if (!userInfoTable.isRegistered(uuid)) { - userInfoTable.registerUserInfo(uuid, registered); + if (!db.check().isPlayerRegisteredOnThisServer(uuid)) { + db.save().registerNewUserOnThisServer(uuid, registered); } - if (db.getActionsTable().getActions(uuid).size() > 0) { + if (db.fetch().getActions(uuid).size() > 0) { return; } plugin.getDataCache().markFirstSession(uuid); - db.getActionsTable().insertAction(uuid, new Action(time, Actions.FIRST_SESSION, "Online: " + playersOnline + " Players")); - } catch (SQLException e) { + db.save().action(uuid, new Action(time, Actions.FIRST_SESSION, "Online: " + playersOnline + " Players")); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } finally { - plugin.addToProcessQueue(afterProcess); + Processor.queue(afterProcess); } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java index 014b95b784..0432766c05 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java @@ -5,12 +5,13 @@ package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.systems.Systems; +import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plugin.api.Check; /** - * //TODO Class Javadoc Comment + * WebServer subsystem for managing WebServer initialization. * * @author Rsl1122 */ @@ -19,16 +20,15 @@ public class WebServerSystem implements SubSystem { private WebServer webServer; public WebServerSystem() { - + webServer = new WebServer(); } public static WebServerSystem getInstance() { - return Systems.getInstance().getWebServerSystem(); + return PlanSystem.getInstance().getWebServerSystem(); } @Override public void enable() throws EnableException { - webServer = new WebServer(); webServer.initServer(); if (Check.isBungeeAvailable() && !webServer.isEnabled()) { throw new EnableException("WebServer did not initialize!"); @@ -40,10 +40,8 @@ public void enable() throws EnableException { @Override public void disable() { - // TODO Remove after WebServer setting requirement is gone. - if (webServer != null) { - webServer.stop(); - } + ResponseCache.clearCache(); + webServer.stop(); } public static boolean isWebServerEnabled() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 855ee3cd8d..0699a8b164 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -7,6 +7,8 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.ServerVariableHolder; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.info.server.ServerInfo; @@ -75,12 +77,17 @@ private void appendServerInformation(StringBuilder content) { .append(" ").append(variable.getVersion()); content.append("
"); - content.append("**Database:** ").append(plugin.getDB().getName()); - try { - content.append(" schema v").append(plugin.getDB().getVersion()); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); + Database database = plugin.getDB(); + content.append("**Database:** ").append(database.getName()); + + if (database instanceof SQLDB) { + try { + content.append(" schema v").append(((SQLDB) database).getVersion()); + } catch (SQLException e) { + Log.toLog(this.getClass().getName(), e); + } } + content.append("

"); RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java index 9be634220e..3e9750a0ac 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java @@ -1,11 +1,13 @@ package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; @@ -21,7 +23,6 @@ import org.apache.commons.lang3.text.StrSubstitutor; import java.io.IOException; -import java.sql.SQLException; import java.util.*; /** @@ -33,8 +34,11 @@ public class PlayersPageResponse extends Response { public PlayersPageResponse() { super.setHeader("HTTP/1.1 200 OK"); try { + PlanSystem system = PlanSystem.getInstance(); + PlanPlugin plugin = PlanPlugin.getInstance(); - List names = new ArrayList<>(plugin.getDB().getUsersTable().getPlayerNames().values()); + Database db = system.getDatabaseSystem().getActiveDatabase(); + List names = new ArrayList<>(db.fetch().getPlayerNames().values()); Collections.sort(names); Map replace = new HashMap<>(); if (Check.isBukkitAvailable()) { @@ -42,22 +46,22 @@ public PlayersPageResponse() { } else { replace.put("networkName", Settings.BUNGEE_NETWORK_NAME.toString()); } - replace.put("playersTable", buildPlayersTable(plugin.getDB())); + replace.put("playersTable", buildPlayersTable(db)); replace.put("version", plugin.getVersion()); super.setContent(Theme.replaceColors(StrSubstitutor.replace(FileUtil.getStringFromResource("web/players.html"), replace))); - } catch (SQLException | IOException e) { + } catch (DBException | IOException e) { Log.toLog(this.getClass().getName(), e); - setContent(new InternalErrorResponse(e, "/players").getContent()); + setContent(new InternalErrorResponse("/players", e).getContent()); } } - public static String buildPlayersTable(Database db) { + private String buildPlayersTable(Database db) { try { - List users = new ArrayList<>(db.getUsersTable().getUsers().values()); + List users = new ArrayList<>(db.fetch().getUsers().values()); users.sort(new UserInfoLastPlayedComparator()); - Map lastSeenForAllPlayers = db.getSessionsTable().getLastSeenForAllPlayers(); - Map> sessionsByUser = AnalysisUtils.sortSessionsByUser(db.getSessionsTable().getAllSessions(false)); - Map> geoInfos = db.getIpsTable().getAllGeoInfo(); + Map lastSeenForAllPlayers = db.fetch().getLastSeenForAllPlayers(); + Map> sessionsByUser = AnalysisUtils.sortSessionsByUser(db.fetch().getSessionsWithNoExtras()); + Map> geoInfos = db.fetch().getAllGeoInfo(); String userS = Html.FONT_AWESOME_ICON.parse("user") + " Player"; String playtimeS = Html.FONT_AWESOME_ICON.parse("clock-o") + " Playtime"; @@ -120,7 +124,7 @@ public static String buildPlayersTable(Database db) { } catch (IllegalArgumentException ignored) { } return html.append("").toString(); - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(PlayersPageResponse.class.getClass().getName(), e); return new InternalErrorResponse(e, "/players").getContent(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index ed33ead3a3..fc22058982 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -41,6 +41,7 @@ public WebAPI() { this.variables = new HashMap<>(); } + public Response processRequest(PlanPlugin plugin, Map variables) { String sender = variables.get("sender"); if (sender == null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java index b6cbfddebb..e9974d4daf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.system.webserver.webapi; +import com.djrapitops.plan.system.webserver.pages.TreePageHandler; import com.djrapitops.plan.utilities.PassEncryptUtil; import java.util.*; @@ -11,7 +12,8 @@ /** * @author Fuzzlemann and Rsl1122 */ -public class WebAPIManager { +@Deprecated +public class WebAPIManager extends TreePageHandler { private final Map registry; private static final Set accessKeys = new HashSet<>(); 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 c88d7ce29a..bbfdb5674a 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 @@ -57,14 +57,14 @@ public Response onRequest(PlanPlugin plugin, Map variables) { ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(infoManager, UUID.fromString(uuid), StrSubstitutor.replace(html, map))); if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportPlayer(plugin, UUID.fromString(uuid)); + 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(plugin, UUID.fromString(sender)); + HtmlExport.exportServer(UUID.fromString(sender)); } break; default: diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java deleted file mode 100644 index 23ae9617f2..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ /dev/null @@ -1,135 +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; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.system.database.BukkitDBSystem; -import com.djrapitops.plan.system.database.BungeeDBSystem; -import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.plan.system.file.FileSystem; -import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; -import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; -import com.djrapitops.plan.system.settings.config.ConfigSystem; -import com.djrapitops.plan.system.tasks.BukkitTaskSystem; -import com.djrapitops.plan.system.tasks.BungeeTaskSystem; -import com.djrapitops.plan.system.tasks.TaskSystem; -import com.djrapitops.plan.system.update.VersionCheckSystem; -import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plugin.api.utility.log.Log; -import org.apache.commons.lang3.ArrayUtils; - -/** - * Layer for reducing - * - * @author Rsl1122 - */ -@Deprecated -public class Systems { - - private FileSystem fileSystem; - private ConfigSystem configSystem; - private DBSystem databaseSystem; - private Theme themeSystem; - - private WebServerSystem webServerSystem; - - private TaskSystem taskSystem; - - private VersionCheckSystem versionCheckSystem; - - /** - * Constructor for Bukkit version. - * - * @param plugin Plan instance - */ - public Systems(Plan plugin) { - fileSystem = new FileSystem(plugin); - configSystem = new BukkitConfigSystem(); - databaseSystem = new BukkitDBSystem(); - versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); - - taskSystem = new BukkitTaskSystem(); - - webServerSystem = new WebServerSystem(); - themeSystem = new Theme(); - } - - /** - * Constructor for Bungee version. - * - * @param plugin PlanBungee instance - */ - public Systems(PlanBungee plugin) { - fileSystem = new FileSystem(plugin); - configSystem = new BungeeConfigSystem(); - databaseSystem = new BungeeDBSystem(); - versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); - - taskSystem = new BungeeTaskSystem(); - - webServerSystem = new WebServerSystem(); - themeSystem = new Theme(); - } - - private SubSystem[] getSubSystems() { - return new SubSystem[]{ - fileSystem, - configSystem, - versionCheckSystem, - databaseSystem, - taskSystem, - webServerSystem, - themeSystem - }; - } - - public void close() { - SubSystem[] subSystems = getSubSystems(); - ArrayUtils.reverse(subSystems); - for (SubSystem subSystem : subSystems) { - try { - subSystem.disable(); - } catch (Exception e) { - Log.toLog(Systems.class, e); - } - } - } - - public static Systems getInstance() { - return PlanPlugin.getInstance().getSystems(); - } - - public FileSystem getFileSystem() { - return fileSystem; - } - - public DBSystem getDatabaseSystem() { - return databaseSystem; - } - - public ConfigSystem getConfigSystem() { - return configSystem; - } - - public WebServerSystem getWebServerSystem() { - return webServerSystem; - } - - public VersionCheckSystem getVersionCheckSystem() { - return versionCheckSystem; - } - - public Theme getThemeSystem() { - return themeSystem; - } - - public TaskSystem getTaskSystem() { - return taskSystem; - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java index 2521e19c35..20e3cc4773 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java @@ -1,10 +1,10 @@ package com.djrapitops.plan.systems.cache; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.*; /** @@ -61,12 +61,12 @@ public void updateNames(UUID uuid, String playerName, String displayName) { public void cacheSavedNames() { try { - Map playerNames = db.getUsersTable().getPlayerNames(); + Map playerNames = db.fetch().getPlayerNames(); this.playerNames.putAll(playerNames); for (Map.Entry entry : playerNames.entrySet()) { uuids.put(entry.getValue(), entry.getKey()); } - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } @@ -81,9 +81,9 @@ public String getName(UUID uuid) { String name = playerNames.get(uuid); if (name == null) { try { - name = db.getUsersTable().getPlayerName(uuid); + name = db.fetch().getPlayerName(uuid); playerNames.put(uuid, name); - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); name = "Error occurred"; } @@ -104,11 +104,11 @@ public String getDisplayName(UUID uuid) { if (cached == null) { List nicknames; try { - nicknames = db.getNicknamesTable().getNicknames(uuid); + nicknames = db.fetch().getNicknames(uuid); if (!nicknames.isEmpty()) { return nicknames.get(nicknames.size() - 1); } - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java index 3ace0c79c4..f4de02f559 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java @@ -1,12 +1,13 @@ package com.djrapitops.plan.systems.cache; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -47,8 +48,8 @@ public void endSession(UUID uuid, long time) { return; } session.endSession(time); - plugin.getDB().getSessionsTable().saveSession(uuid, session); - } catch (SQLException e) { + Database.getActive().save().session(uuid, session); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } finally { activeSessions.remove(uuid); 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 index c0e24f40f7..842556d5a1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -35,8 +35,8 @@ import com.djrapitops.plan.system.webserver.webapi.bungee.*; import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.info.parsing.AnalysisPageParser; -import com.djrapitops.plan.systems.info.parsing.InspectPageParser; +import com.djrapitops.plan.systems.info.parsing.AnalysisPage; +import com.djrapitops.plan.systems.info.parsing.InspectPage; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.file.export.HtmlExport; @@ -139,15 +139,15 @@ public void cachePlayer(UUID uuid) { } }); if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportPlayer(plugin, uuid); + HtmlExport.exportPlayer(uuid); } } - plugin.addToProcessQueue(new Processor(uuid) { + new Processor(uuid) { @Override public void process() { cacheInspectPluginsTab(object); } - }); + }.queue(); } public void cacheInspectPluginsTab(UUID uuid) { @@ -265,7 +265,7 @@ public String getAnalysisHtml() { return analysisRefreshPage.getContent(); } try { - return Theme.replaceColors(new AnalysisPageParser(analysisData, plugin).parse()); + return Theme.replaceColors(new AnalysisPage(analysisData, plugin).toHtml()); } catch (ParseException e) { return new InternalErrorResponse(e, this.getClass().getSimpleName()).getContent(); } @@ -273,7 +273,7 @@ public String getAnalysisHtml() { @Override public String getPlayerHtml(UUID uuid) throws ParseException { - return Theme.replaceColors(new InspectPageParser(uuid, plugin).parse()); + return Theme.replaceColors(new InspectPage(uuid, plugin).toHtml()); } @Override @@ -318,7 +318,7 @@ public void cacheAnalysisHtml(String html) { UUID serverUUID = Plan.getServerUUID(); ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportServer(plugin, serverUUID); + HtmlExport.exportServer(serverUUID); } } } 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 index e803f2613f..8155726935 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -25,7 +25,7 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI; import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.info.parsing.NetworkPageParser; +import com.djrapitops.plan.systems.info.parsing.NetworkPage; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.utilities.file.export.HtmlExport; @@ -54,7 +54,7 @@ public class BungeeInformationManager extends InformationManager { private final Map> pluginsTabContent; private final BungeeServerInfoManager serverInfoManager; - public BungeeInformationManager(PlanBungee plugin) throws SQLException { + public BungeeInformationManager(PlanBungee plugin) { usingAnotherWebServer = false; pluginsTabContent = new HashMap<>(); networkPageContent = new HashMap<>(); @@ -268,7 +268,7 @@ public String getPlayerHtml(UUID uuid) { @Override public String getAnalysisHtml() { try { - return new NetworkPageParser(plugin).parse(); + return new NetworkPage(plugin).toHtml(); } catch (ParseException e) { return new InternalErrorResponse(e, this.getClass().getSimpleName()).getContent(); } @@ -376,7 +376,7 @@ public void updateNetworkPageContent() { UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(this)); if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportServer(plugin, serverUUID); + HtmlExport.exportServer(serverUUID); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPage.java similarity index 88% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java rename to Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPage.java index 2c1576c4d3..5fab0f0b52 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPage.java @@ -20,18 +20,18 @@ * * @author Rsl1122 */ -public class AnalysisPageParser extends PageParser { +public class AnalysisPage extends Page { private final AnalysisData data; private final PlanPlugin plugin; - public AnalysisPageParser(AnalysisData analysisData, PlanPlugin plugin) { + public AnalysisPage(AnalysisData analysisData, PlanPlugin plugin) { this.data = analysisData; this.plugin = plugin; } @Override - public String parse() throws ParseException { + public String toHtml() throws ParseException { addValues(data.getReplaceMap()); try { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java rename to Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java index 6cf6ab70f6..0d5b446511 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java @@ -44,17 +44,17 @@ * * @author Rsl1122 */ -public class InspectPageParser extends PageParser { +public class InspectPage extends Page { private final UUID uuid; private final PlanPlugin plugin; - public InspectPageParser(UUID uuid, PlanPlugin plugin) { + public InspectPage(UUID uuid, PlanPlugin plugin) { this.uuid = uuid; this.plugin = plugin; } - public String parse() throws ParseException { + public String toHtml() throws ParseException { try { if (uuid == null) { throw new IllegalStateException("UUID was null!"); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java similarity index 83% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java rename to Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java index 700f5e907f..013d7c1123 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.settings.theme.Theme; @@ -22,7 +23,6 @@ import com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraph; import com.djrapitops.plugin.api.TimeAmount; -import java.sql.SQLException; import java.util.List; import java.util.Map; import java.util.Optional; @@ -33,21 +33,21 @@ * * @author Rsl1122 */ -public class NetworkPageParser extends PageParser { +public class NetworkPage extends Page { private final PlanBungee plugin; - public NetworkPageParser(PlanBungee plugin) { + public NetworkPage(PlanBungee plugin) { this.plugin = plugin; } @Override - public String parse() throws ParseException { + public String toHtml() throws ParseException { try { UUID serverUUID = plugin.getServerUuid(); long now = MiscUtils.getTime(); Database db = plugin.getDB(); - List networkOnlineData = db.getTpsTable().getNetworkOnlineData(); + List networkOnlineData = db.fetch().getNetworkOnlineData(); peakTimes(serverUUID, now, db); @@ -60,9 +60,9 @@ public String parse() throws ParseException { addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE)); addValue("playersOnline", plugin.getProxy().getOnlineCount()); - addValue("playersTotal", db.getUsersTable().getPlayerCount()); + addValue("playersTotal", db.count().getNetworkPlayerCount()); - List registerDates = db.getUsersTable().getRegisterDates(); + List registerDates = db.fetch().getRegisterDates(); addValue("playersNewDay", AnalysisUtils.getNewPlayers(registerDates, TimeAmount.DAY.ms(), now)); addValue("playersNewWeek", AnalysisUtils.getNewPlayers(registerDates, TimeAmount.WEEK.ms(), now)); addValue("playersNewMonth", AnalysisUtils.getNewPlayers(registerDates, TimeAmount.MONTH.ms(), now)); @@ -76,8 +76,8 @@ public String parse() throws ParseException { } } - private void uniquePlayers(long now, Database db) throws SQLException { - Map>> allSessions = db.getSessionsTable().getAllSessions(false); + private void uniquePlayers(long now, Database db) throws DBException { + Map>> allSessions = db.fetch().getSessionsWithNoExtras(); Map> userSessions = AnalysisUtils.sortSessionsByUser(allSessions); long dayAgo = now - TimeAmount.DAY.ms(); @@ -89,9 +89,9 @@ private void uniquePlayers(long now, Database db) throws SQLException { addValue("playersUniqueMonth", AnalysisUtils.getUniqueJoinsPerDay(userSessions, monthAgo)); } - private void peakTimes(UUID serverUUID, long now, Database db) throws SQLException { - Optional allTimePeak = db.getTpsTable().getAllTimePeak(serverUUID); - Optional lastPeak = db.getTpsTable().getPeakPlayerCount(serverUUID, now - TimeAmount.DAY.ms() * 2L); + private void peakTimes(UUID serverUUID, long now, Database db) throws DBException { + Optional allTimePeak = db.fetch().getAllTimePeak(serverUUID); + Optional lastPeak = db.fetch().getPeakPlayerCount(serverUUID, now - TimeAmount.DAY.ms() * 2L); if (allTimePeak.isPresent()) { TPS tps = allTimePeak.get(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/Page.java similarity index 87% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java rename to Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/Page.java index 159d16d402..6fe13967ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/PageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/Page.java @@ -15,11 +15,11 @@ * * @author Rsl1122 */ -public abstract class PageParser { +public abstract class Page { protected final Map placeHolders; - public PageParser() { + public Page() { this.placeHolders = new HashMap<>(); } @@ -31,5 +31,5 @@ protected void addValues(Map values) { placeHolders.putAll(values); } - public abstract String parse() throws ParseException; + public abstract String toHtml() throws ParseException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index 032d96d936..bdfea7f512 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -2,7 +2,6 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; @@ -96,10 +95,10 @@ public static String getPlayerName(String[] args, ISender sender, Permissions pe * @return Alphabetically sorted list of matching player names. */ public static List getMatchingPlayerNames(String search) { - Database db = PlanPlugin.getInstance().getDB(); + Database db = Database.getActive(); List matches; try { - matches = db.search().matchingPlayerNames(search); + matches = db.search().matchingPlayers(search); } catch (DBException e) { Log.toLog(MiscUtils.class, e); return new ArrayList<>(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index b4a99a730c..f9e8c6c728 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -1,16 +1,17 @@ package com.djrapitops.plan.utilities.analysis; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.StickyData; import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.*; import java.util.stream.Collectors; @@ -141,14 +142,14 @@ public static void addMissingWorlds(WorldTimes worldTimes) { // Add 0 time for worlds not present. Set nonZeroWorlds = worldTimes.getWorldTimes().keySet(); PlanPlugin plugin = PlanPlugin.getInstance(); - for (String world : plugin.getDB().getWorldTable().getWorldNames(plugin.getServerUuid())) { + for (String world : Database.getActive().fetch().getWorldNames(plugin.getServerUuid())) { if (nonZeroWorlds.contains(world)) { continue; } worldTimes.setGMTimesForWorld(world, new GMTimes()); } - } catch (SQLException e) { - Log.toLog("AnalysisUtils.addMissingWorlds", e); + } catch (DBException e) { + Log.toLog(AnalysisUtils.class, e); } } 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 ff16542943..8f9be87e01 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 @@ -5,9 +5,11 @@ package com.djrapitops.plan.utilities.file.export; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBException; 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.webserver.response.pages.PlayersPageResponse; import com.djrapitops.plan.system.webserver.webapi.bungee.PostHtmlWebAPI; import com.djrapitops.plan.utilities.file.FileUtil; @@ -16,7 +18,6 @@ import java.io.File; import java.io.IOException; -import java.sql.SQLException; import java.util.*; /** @@ -33,22 +34,22 @@ public HtmlExport(PlanPlugin plugin) { this.plugin = plugin; } - public static void exportServer(PlanPlugin plugin, UUID serverUUID) { + public static void exportServer(UUID serverUUID) { try { - Optional serverName = plugin.getDB().getServerTable().getServerName(serverUUID); + Optional serverName = Database.getActive().fetch().getServerName(serverUUID); serverName.ifPresent(s -> RunnableFactory.createNew(new AnalysisExport(serverUUID, s)).runTaskAsynchronously()); - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(PostHtmlWebAPI.class.getClass().getName(), e); } } - public static void exportPlayer(PlanPlugin plugin, UUID playerUUID) { + public static void exportPlayer(UUID playerUUID) { try { - String playerName = plugin.getDB().getUsersTable().getPlayerName(playerUUID); + String playerName = Database.getActive().fetch().getPlayerName(playerUUID); if (playerName != null) { RunnableFactory.createNew(new PlayerExport(playerUUID, playerName)).runTaskAsynchronously(); } - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(PostHtmlWebAPI.class.getClass().getName(), e); } } @@ -68,7 +69,7 @@ public void run() { exportAvailableServerPages(); exportAvailablePlayers(); exportPlayersPage(); - } catch (IOException | SQLException e) { + } catch (IOException | DBException e) { Log.toLog(this.getClass().getName(), e); } finally { try { @@ -94,14 +95,14 @@ private void exportPlayersPage() throws IOException { export(exportFile, lines); } - private void exportAvailablePlayers() throws SQLException, IOException { - for (Map.Entry entry : plugin.getDB().getUsersTable().getUsers().entrySet()) { + private void exportAvailablePlayers() throws DBException, IOException { + for (Map.Entry entry : Database.getActive().fetch().getUsers().entrySet()) { exportAvailablePlayerPage(entry.getKey(), entry.getValue().getName()); } } - private void exportAvailableServerPages() throws SQLException, IOException { - Map serverNames = plugin.getDB().getServerTable().getServerNames(); + private void exportAvailableServerPages() throws IOException, DBException { + Map serverNames = Database.getActive().fetch().getServerNames(); for (Map.Entry entry : serverNames.entrySet()) { exportAvailableServerPage(entry.getKey(), entry.getValue()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index df67b81d29..3042ba55ca 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.utilities.file.export; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 5f94143804..0ae910ee0e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -125,7 +125,7 @@ public static String createServerContainer(Plan plugin) { int playerCount = 0; String playerData = "[]"; try { - playerCount = db.count().serverPlayerCount(serverUUID); + playerCount = db.count().getServerPlayerCount(serverUUID); playerData = PlayerActivityGraph.createSeries(db.fetch().getTPSData(serverUUID)); } catch (DBException e) { Log.toLog(HtmlStructure.class.getClass().getName(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java index e57c5f8998..b669c5b33c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java @@ -1,6 +1,8 @@ package com.djrapitops.plan.utilities.html; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.system.settings.Settings; import org.apache.commons.lang3.text.StrSubstitutor; @@ -58,7 +60,7 @@ public static String getRelativeInspectUrl(String playerName) { } public static String getRelativeInspectUrl(UUID uuid) { - return Plan.getPlanAPI().getPlayerInspectPageLink(Plan.getInstance().getDataCache().getName(uuid)); + return PlanAPI.getInstance().getPlayerInspectPageLink(Plan.getInstance().getDataCache().getName(uuid)); } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index 8690136d7a..a9406871e3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.utilities.html.structure; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.settings.theme.Theme; @@ -70,7 +71,7 @@ public static String[] createStructure(Map>> ses int playerKillCount = session.getPlayerKills().size(); String name = Plan.getInstance().getDataCache().getName(uuid); - String link = Plan.getPlanAPI().getPlayerInspectPageLink(name); + String link = PlanAPI.getInstance().getPlayerInspectPageLink(name); String dotSeparated2 = appendWorldPerc ? HtmlStructure.separateWithDots(sessionStart, SessionsTableCreator.getLongestWorldPlayed(session)) diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java index cf14b6e3c3..07a108d2c6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java @@ -1,6 +1,7 @@ package com.djrapitops.plan.utilities.html.tables; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; @@ -47,7 +48,7 @@ public static String createTable(List playerKills) { String name = Plan.getInstance().getDataCache().getName(kill.getVictim()); html.append(Html.TABLELINE_3_CUSTOMKEY_1.parse( String.valueOf(date), FormatUtils.formatTimeStamp(date), - Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(name), name), + Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), kill.getWeapon() )); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java index 877ec3f852..3ef3763fee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.utilities.html.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.element.AnalysisContainer; @@ -64,7 +64,7 @@ public static String createTable(List players) { String geoLocation = profile.getMostRecentGeoInfo().getGeolocation(); html.append(Html.TABLELINE_PLAYERS.parse( - Html.LINK_EXTERNAL.parse(Plan.getPlanAPI().getPlayerInspectPageLink(profile.getName()), profile.getName()), + Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(profile.getName()), profile.getName()), activityString, String.valueOf(playtime), FormatUtils.formatTimeAmount(playtime), String.valueOf(loginTimes), @@ -133,7 +133,7 @@ public static String createPluginsTable(Map conta break; } UUID uuid = profile.getUuid(); - String link = Html.LINK_EXTERNAL.parse(Plan.getPlanAPI().getPlayerInspectPageLink(profile.getName()), profile.getName()); + String link = Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(profile.getName()), profile.getName()); String[] playerData = FormatUtils.mergeArrays(new String[]{link}, sortedData.getOrDefault(uuid, new String[]{})); tableContainer.addRow(ArrayUtils.addAll(playerData)); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index f3541a23ee..cbf528ce4f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.utilities.html.tables; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.settings.WorldAliasSettings; @@ -81,7 +82,7 @@ public static String[] createTable(Map> sessionsByUser, List String length = session.getSessionEnd() != -1 ? FormatUtils.formatTimeAmount(session.getLength()) : "Online"; String world = getLongestWorldPlayed(session); - String inspectUrl = Plan.getPlanAPI().getPlayerInspectPageLink(name); + String inspectUrl = PlanAPI.getInstance().getPlayerInspectPageLink(name); String toolTip = "Session ID: " + (session.isFetchedFromDB() ? session.getSessionID() : "Not Saved."); sessionTableBuilder.append(Html.TABLELINE_4.parse( Html.LINK_TOOLTIP.parse(inspectUrl, name, toolTip), diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index f7c0848dae..9172b32a8e 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -244,7 +244,7 @@ public void testTPSSaving() throws Exception { assertEquals(expected, tpsTable.getTPSData()); } - private void saveUserOne() throws SQLException { + private void saveUserOne() { saveUserOne(db); } @@ -252,7 +252,7 @@ private void saveUserOne(Database database) { database.getUsersTable().registerUser(uuid, 123456789L, "Test"); } - private void saveUserTwo() throws SQLException { + private void saveUserTwo() { saveUserTwo(db); } @@ -277,7 +277,7 @@ public void testActionsTable() throws SQLException { @Test public void testIPTable() throws SQLException, DBInitException { saveUserOne(); - IPsTable ipsTable = db.getIpsTable(); + GeoInfoTable ipsTable = db.getIpsTable(); String expectedIP = "1.2.3.4"; String expectedGeoLoc = "TestLocation"; @@ -353,7 +353,7 @@ public void testWorldTable() throws SQLException, DBInitException { assertEquals(new HashSet<>(worlds), new HashSet<>(saved)); } - private void saveTwoWorlds() throws SQLException { + private void saveTwoWorlds() { saveTwoWorlds(db); } @@ -508,14 +508,14 @@ public void testUserInfoTableUpdateBannedOpped() throws SQLException, DBInitExce userInfoTable.registerUserInfo(uuid, 223456789L); assertTrue(userInfoTable.isRegistered(uuid)); - userInfoTable.updateOpAndBanStatus(uuid, true, true); + userInfoTable.updateOpStatus(uuid, true, true); commitTest(); UserInfo userInfo = userInfoTable.getUserInfo(uuid); assertTrue(userInfo.isBanned()); assertTrue(userInfo.isOpped()); - userInfoTable.updateOpAndBanStatus(uuid, false, true); + userInfoTable.updateOpStatus(uuid, false, true); commitTest(); userInfo = userInfoTable.getUserInfo(uuid); @@ -523,7 +523,7 @@ public void testUserInfoTableUpdateBannedOpped() throws SQLException, DBInitExce assertTrue(userInfo.isBanned()); assertFalse(userInfo.isOpped()); - userInfoTable.updateOpAndBanStatus(uuid, false, false); + userInfoTable.updateOpStatus(uuid, false, false); commitTest(); userInfo = userInfoTable.getUserInfo(uuid); @@ -572,7 +572,7 @@ public void testRemovalSingleUser() throws SQLException, DBException { UsersTable usersTable = db.getUsersTable(); SessionsTable sessionsTable = db.getSessionsTable(); NicknamesTable nicknamesTable = db.getNicknamesTable(); - IPsTable ipsTable = db.getIpsTable(); + GeoInfoTable ipsTable = db.getIpsTable(); ActionsTable actionsTable = db.getActionsTable(); userInfoTable.registerUserInfo(uuid, 223456789L); @@ -606,7 +606,7 @@ public void testRemovalEverything() throws SQLException, DBException { UsersTable usersTable = db.getUsersTable(); SessionsTable sessionsTable = db.getSessionsTable(); NicknamesTable nicknamesTable = db.getNicknamesTable(); - IPsTable ipsTable = db.getIpsTable(); + GeoInfoTable ipsTable = db.getIpsTable(); ActionsTable actionsTable = db.getActionsTable(); TPSTable tpsTable = db.getTpsTable(); SecurityTable securityTable = db.getSecurityTable(); @@ -636,7 +636,7 @@ private void saveAllData(Database database) throws SQLException { UsersTable usersTable = database.getUsersTable(); SessionsTable sessionsTable = database.getSessionsTable(); NicknamesTable nicknamesTable = database.getNicknamesTable(); - IPsTable ipsTable = database.getIpsTable(); + GeoInfoTable ipsTable = database.getIpsTable(); ActionsTable actionsTable = database.getActionsTable(); TPSTable tpsTable = database.getTpsTable(); SecurityTable securityTable = database.getSecurityTable(); @@ -790,7 +790,7 @@ public void testBackupAndRestore() throws SQLException, DBInitException { UsersTable usersTable = backup.getUsersTable(); SessionsTable sessionsTable = backup.getSessionsTable(); NicknamesTable nicknamesTable = backup.getNicknamesTable(); - IPsTable ipsTable = backup.getIpsTable(); + GeoInfoTable ipsTable = backup.getGeoInfoTable(); ActionsTable actionsTable = backup.getActionsTable(); TPSTable tpsTable = backup.getTpsTable(); SecurityTable securityTable = backup.getSecurityTable(); From 47f061edcb579a13cc9b33f6a2657320fa47ee42 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 15 Jan 2018 20:17:39 +0200 Subject: [PATCH 021/166] Rearranged code --- .../java/com/djrapitops/plan/PlanBungee.java | 16 +- .../java/com/djrapitops/plan/PlanPlugin.java | 26 +- .../plan/command/commands/InspectCommand.java | 2 +- .../djrapitops/plan/data/PlayerProfile.java | 158 ++++++------ .../djrapitops/plan/data/ServerProfile.java | 242 +++++++++--------- .../plan/data/element/ActivityIndex.java | 8 +- .../plan/data/element/HealthNotes.java | 3 +- .../plan/settings/ServerSpecificSettings.java | 30 +-- .../plan/settings/locale/Locale.java | 8 +- .../djrapitops/plan/settings/theme/Theme.java | 16 +- .../djrapitops/plan/system/PlanSystem.java | 26 +- .../plan/system/database/BungeeDBSystem.java | 2 +- .../plan/system/listeners/ListenerSystem.java | 2 +- .../bukkit/PlayerOnlineListener.java | 10 +- .../processing/processors/Processor.java | 14 +- .../plan/system/settings/Settings.java | 16 +- .../plan/system/tasks/BukkitTaskSystem.java | 4 +- .../plan/system/tasks/TPSCountTimer.java | 2 +- .../system/update/VersionCheckSystem.java | 8 +- .../plan/system/webserver/Request.java | 3 +- .../system/webserver/WebServerSystem.java | 10 +- .../system/webserver/response/Response.java | 8 +- .../response/pages/InspectPageResponse.java | 8 +- .../plan/system/webserver/webapi/WebAPI.java | 49 ++-- .../webserver/webapi/WebAPIManager.java | 2 +- .../plan/systems/cache/GeolocationCache.java | 3 +- .../plan/systems/cache/SessionCache.java | 30 +-- .../info/BukkitInformationManager.java | 4 +- .../info/BungeeInformationManager.java | 3 +- .../info/server/BukkitServerInfoManager.java | 2 +- .../info/server/BungeeServerInfoManager.java | 3 +- .../plan/utilities/analysis/Analysis.java | 20 +- 32 files changed, 365 insertions(+), 373 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 753aabe8f5..47d22eede5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -52,6 +52,14 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { @Deprecated private boolean setupAllowed = false; + public static PlanBungee getInstance() { + return (PlanBungee) StaticHolder.getInstance(PlanBungee.class); + } + + public static UUID getServerUUID() { + return getInstance().getServerUuid(); + } + @Override public void onEnable() { super.onEnable(); @@ -99,10 +107,6 @@ public void onEnable() { registerCommand("planbungee", new PlanBungeeCommand(this)); } - public static PlanBungee getInstance() { - return (PlanBungee) StaticHolder.getInstance(PlanBungee.class); - } - @Override public void onDisable() { system.disable(); @@ -163,10 +167,6 @@ public ServerVariableHolder getVariable() { return variableHolder; } - public static UUID getServerUUID() { - return getInstance().getServerUuid(); - } - public UUID getServerUuid() { return serverInfoManager.getServerUUID(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index c3f16e0143..1b39877aee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -24,6 +24,19 @@ * @author Rsl1122 */ public interface PlanPlugin extends IPlugin { + static PlanPlugin getInstance() { + boolean bukkitAvailable = Check.isBukkitAvailable(); + boolean bungeeAvailable = Check.isBungeeAvailable(); + if (bukkitAvailable && bungeeAvailable) { + // TODO Test Plugin + } else if (bungeeAvailable) { + return Plan.getInstance(); + } else if (bukkitAvailable) { + return PlanBungee.getInstance(); + } + throw new IllegalAccessError("Plugin instance not available"); + } + @Deprecated Database getDB(); @@ -55,17 +68,4 @@ public interface PlanPlugin extends IPlugin { ColorScheme getColorScheme(); boolean isReloading(); - - static PlanPlugin getInstance() { - boolean bukkitAvailable = Check.isBukkitAvailable(); - boolean bungeeAvailable = Check.isBungeeAvailable(); - if (bukkitAvailable && bungeeAvailable) { - // TODO Test Plugin - } else if (bungeeAvailable) { - return Plan.getInstance(); - } else if (bukkitAvailable) { - return PlanBungee.getInstance(); - } - throw new IllegalAccessError("Plugin instance not available"); - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 0415241449..449122e01e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -77,7 +77,7 @@ public void run() { } if (CommandUtils.isPlayer(sender) && plugin.getWebServer().isAuthRequired()) { boolean senderHasWebUser = activeDB.check().doesWebUserExists(sender.getName()); - + if (!senderHasWebUser) { sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index d5fc03b72f..e1bffd4641 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -79,6 +79,57 @@ public PlayerProfile(UUID uuid, String name, long registered) { activityIndexCache = new HashMap<>(); } + public static long getPlaytime(Stream s) { + return s.map(Session::getLength) + .mapToLong(i -> i) + .sum(); + } + + public static long getLongestSession(Stream s) { + OptionalLong longestSession = s.map(Session::getLength) + .mapToLong(i -> i) + .max(); + if (longestSession.isPresent()) { + return longestSession.getAsLong(); + } + return -1; + } + + public static long getSessionMedian(Stream s) { + List sessionLenghts = s.map(Session::getLength) + .sorted() + .collect(Collectors.toList()); + if (sessionLenghts.isEmpty()) { + return 0; + } + return sessionLenghts.get(sessionLenghts.size() / 2); + } + + public static long getSessionAverage(Stream s) { + OptionalDouble average = s.map(Session::getLength) + .mapToLong(i -> i) + .average(); + if (average.isPresent()) { + return (long) average.getAsDouble(); + } + return 0L; + } + + public static Stream getPlayerKills(Stream s) { + return s.map(Session::getPlayerKills) + .flatMap(Collection::stream); + } + + public static long getDeathCount(Stream s) { + return s.mapToLong(Session::getDeaths) + .sum(); + } + + public static long getMobKillCount(Stream s) { + return s.mapToLong(Session::getMobKills) + .sum(); + } + // Calculating Getters public ActivityIndex getActivityIndex(long date) { ActivityIndex index = activityIndexCache.get(date); @@ -98,6 +149,10 @@ public WorldTimes getWorldTimes() { return worldTimesMap.getOrDefault(null, new WorldTimes(new HashMap<>())); } + public void setWorldTimes(Map worldTimes) { + worldTimesMap.putAll(worldTimes); + } + /** * Get world times per server for this player. * @@ -151,12 +206,6 @@ public long getPlaytime(UUID serverUUID) { return getPlaytime(getSessions(serverUUID).stream()); } - public static long getPlaytime(Stream s) { - return s.map(Session::getLength) - .mapToLong(i -> i) - .sum(); - } - public long getLongestSession() { return getLongestSession(-1, MiscUtils.getTime() + 1L); } @@ -169,16 +218,6 @@ public long getLongestSession(UUID serverUUID) { return getLongestSession(getSessions(serverUUID).stream()); } - public static long getLongestSession(Stream s) { - OptionalLong longestSession = s.map(Session::getLength) - .mapToLong(i -> i) - .max(); - if (longestSession.isPresent()) { - return longestSession.getAsLong(); - } - return -1; - } - public long getSessionMedian() { return getSessionMedian(-1, MiscUtils.getTime() + 1L); } @@ -191,15 +230,7 @@ public long getSessionMedian(UUID serverUUID) { return getSessionMedian(getSessions(serverUUID).stream()); } - public static long getSessionMedian(Stream s) { - List sessionLenghts = s.map(Session::getLength) - .sorted() - .collect(Collectors.toList()); - if (sessionLenghts.isEmpty()) { - return 0; - } - return sessionLenghts.get(sessionLenghts.size() / 2); - } + // Special Getters public long getSessionAverage() { return getSessionAverage(-1, MiscUtils.getTime() + 1L); @@ -213,22 +244,10 @@ public long getSessionAverage(UUID serverUUID) { return getSessionAverage(getSessions(serverUUID).stream()); } - public static long getSessionAverage(Stream s) { - OptionalDouble average = s.map(Session::getLength) - .mapToLong(i -> i) - .average(); - if (average.isPresent()) { - return (long) average.getAsDouble(); - } - return 0L; - } - public boolean playedBetween(long after, long before) { return getSessions(after, before).findFirst().isPresent(); } - // Special Getters - public Stream getAllSessions() { return sessions.values().stream().flatMap(Collection::stream); } @@ -261,11 +280,6 @@ public Stream getPlayerKills(UUID serverUUID) { return getPlayerKills(getSessions(serverUUID).stream()); } - public static Stream getPlayerKills(Stream s) { - return s.map(Session::getPlayerKills) - .flatMap(Collection::stream); - } - public long getPlayerKillCount() { return getPlayerKills().count(); } @@ -282,11 +296,6 @@ public long getDeathCount(UUID serverUUID) { return getDeathCount(getSessions(serverUUID).stream()); } - public static long getDeathCount(Stream s) { - return s.mapToLong(Session::getDeaths) - .sum(); - } - public long getMobKillCount() { return getMobKillCount(getAllSessions()); } @@ -295,11 +304,6 @@ public long getMobKillCount(UUID serverUUID) { return getMobKillCount(getSessions(serverUUID).stream()); } - public static long getMobKillCount(Stream s) { - return s.mapToLong(Session::getMobKills) - .sum(); - } - public long getSessionCount() { return getAllSessions().count(); } @@ -308,12 +312,12 @@ public long getSessionCount(UUID serverUUID) { return getSessions(serverUUID).size(); } + // Setters & Adders + public long getRegistered(UUID serverUUID) { return registeredMap.getOrDefault(serverUUID, -1L); } - // Setters & Adders - public void bannedOnServer(UUID serverUUID) { bannedOnServers.add(serverUUID); } @@ -334,10 +338,6 @@ public void setSessions(UUID serverUUID, List sessions) { this.sessions.put(serverUUID, sessions); } - public void setSessions(Map> sessions) { - this.sessions.putAll(sessions); - } - public void addActiveSession(Session activeSession) { UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); List sessions = getSessions(serverUUID); @@ -357,10 +357,6 @@ public void setWorldTimes(UUID serverUUID, WorldTimes worldTimes) { worldTimesMap.put(serverUUID, worldTimes); } - public void setWorldTimes(Map worldTimes) { - worldTimesMap.putAll(worldTimes); - } - public void setTotalWorldTimes(WorldTimes worldTimes) { worldTimesMap.put(null, worldTimes); } @@ -369,38 +365,34 @@ public void setRegistered(UUID serverUUID, long registered) { registeredMap.put(serverUUID, registered); } - // Default Setters - - public void setActions(List actions) { - this.actions = actions; - } - - public void setNicknames(Map> nicknames) { - this.nicknames = nicknames; + public int getTimesKicked() { + return timesKicked; } - public void setGeoInformation(List geoInformation) { - this.geoInformation = geoInformation; - } + // Default Setters public void setTimesKicked(int timesKicked) { this.timesKicked = timesKicked; } - // Default Getters - - public int getTimesKicked() { - return timesKicked; - } - public Map> getNicknames() { return nicknames; } + public void setNicknames(Map> nicknames) { + this.nicknames = nicknames; + } + public List getGeoInformation() { return geoInformation; } + // Default Getters + + public void setGeoInformation(List geoInformation) { + this.geoInformation = geoInformation; + } + public UUID getUuid() { return uuid; } @@ -425,10 +417,18 @@ public Map> getSessions() { return sessions; } + public void setSessions(Map> sessions) { + this.sessions.putAll(sessions); + } + public List getActions() { return actions; } + public void setActions(List actions) { + this.actions = actions; + } + public Map getPluginReplaceMap() { return pluginReplaceMap; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java index d7856667ba..99ef745206 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java @@ -64,6 +64,125 @@ public ServerProfile(UUID serverUUID) { lastPeakPlayers = -1; } + public static long getLowSpikeCount(List tpsData) { + int mediumThreshold = Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber(); + + boolean wasLow = false; + long spikeCount = 0L; + + for (TPS tpsObj : tpsData) { + double tps = tpsObj.getTicksPerSecond(); + if (tps < mediumThreshold) { + if (!wasLow) { + spikeCount++; + wasLow = true; + } + } else { + wasLow = false; + } + } + + return spikeCount; + } + + public static List getPlayerKills(List s) { + List kills = new ArrayList<>(); + for (Session session : s) { + kills.addAll(session.getPlayerKills()); + } + return kills; + } + + public static long getMobKillCount(List s) { + long total = 0; + for (Session session : s) { + total += session.getMobKills(); + } + return total; + } + + public static long getDeathCount(List s) { + long total = 0; + for (Session session : s) { + total += session.getDeaths(); + } + return total; + } + + public static int getPlayersOnline() { + if (Check.isBungeeAvailable()) { + return PlanBungee.getInstance().getProxy().getOnlineCount(); + } else { + return Plan.getInstance().getServer().getOnlinePlayers().size(); + } + } + + public static int getPlayersMax() { + return PlanPlugin.getInstance().getVariable().getMaxPlayers(); + } + + public static long serverDownTime(List tpsData) { + long lastDate = -1; + long downTime = 0; + for (TPS tps : tpsData) { + long date = tps.getDate(); + if (lastDate == -1) { + lastDate = date; + continue; + } + + long diff = date - lastDate; + if (diff > TimeAmount.MINUTE.ms() * 3L) { + downTime += diff; + } + lastDate = date; + } + + return downTime; + } + + public static long serverIdleTime(List tpsData) { + long lastDate = -1; + int lastPlayers = 0; + long idleTime = 0; + for (TPS tps : tpsData) { + long date = tps.getDate(); + int players = tps.getPlayers(); + if (lastDate == -1) { + lastDate = date; + lastPlayers = players; + continue; + } + + long diff = date - lastDate; + if (lastPlayers == 0 && players == 0) { + idleTime += diff; + } + + lastDate = date; + lastPlayers = players; + } + + return idleTime; + } + + public static double aboveLowThreshold(List tpsData) { + if (tpsData.isEmpty()) { + return 1; + } + + int threshold = Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber(); + + long count = 0; + for (TPS tps : tpsData) { + if (tps.getTicksPerSecond() >= threshold) { + count++; + } + } + + return count * 1.0 / tpsData.size(); + } + public List getPlayers() { return players; } @@ -88,27 +207,6 @@ public void setCommandUsage(Map commandUsage) { this.commandUsage = commandUsage; } - public static long getLowSpikeCount(List tpsData) { - int mediumThreshold = Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber(); - - boolean wasLow = false; - long spikeCount = 0L; - - for (TPS tpsObj : tpsData) { - double tps = tpsObj.getTicksPerSecond(); - if (tps < mediumThreshold) { - if (!wasLow) { - spikeCount++; - wasLow = true; - } - } else { - wasLow = false; - } - } - - return spikeCount; - } - public double getAverageTPS(long after, long before) { OptionalDouble average = getTPSData(after, before) .mapToDouble(TPS::getTicksPerSecond) @@ -200,6 +298,8 @@ public List getGeoLocations() { .collect(Collectors.toList()); } + // Default setters & getters + public long getTotalPlaytime() { return serverWorldtimes.getTotal(); } @@ -220,32 +320,6 @@ public List getAllSessions() { return players.stream().map(p -> p.getSessions(serverUUID)).flatMap(Collection::stream).collect(Collectors.toList()); } - public static List getPlayerKills(List s) { - List kills = new ArrayList<>(); - for (Session session : s) { - kills.addAll(session.getPlayerKills()); - } - return kills; - } - - public static long getMobKillCount(List s) { - long total = 0; - for (Session session : s) { - total += session.getMobKills(); - } - return total; - } - - public static long getDeathCount(List s) { - long total = 0; - for (Session session : s) { - total += session.getDeaths(); - } - return total; - } - - // Default setters & getters - public WorldTimes getServerWorldtimes() { return serverWorldtimes; } @@ -286,18 +360,6 @@ public void setAllTimePeakPlayers(int allTimePeakPlayers) { this.allTimePeakPlayers = allTimePeakPlayers; } - public static int getPlayersOnline() { - if (Check.isBungeeAvailable()) { - return PlanBungee.getInstance().getProxy().getOnlineCount(); - } else { - return Plan.getInstance().getServer().getOnlinePlayers().size(); - } - } - - public static int getPlayersMax() { - return PlanPlugin.getInstance().getVariable().getMaxPlayers(); - } - public Stream getOps() { return players.stream().filter(PlayerProfile::isOp); } @@ -316,74 +378,12 @@ public long serverDownTime(long after, long before) { .collect(Collectors.toList())); } - public static long serverDownTime(List tpsData) { - long lastDate = -1; - long downTime = 0; - for (TPS tps : tpsData) { - long date = tps.getDate(); - if (lastDate == -1) { - lastDate = date; - continue; - } - - long diff = date - lastDate; - if (diff > TimeAmount.MINUTE.ms() * 3L) { - downTime += diff; - } - lastDate = date; - } - - return downTime; - } - public long serverIdleTime(long after, long before) { return serverIdleTime(getTPSData(after, before) .sorted(new TPSComparator()) .collect(Collectors.toList())); } - public static long serverIdleTime(List tpsData) { - long lastDate = -1; - int lastPlayers = 0; - long idleTime = 0; - for (TPS tps : tpsData) { - long date = tps.getDate(); - int players = tps.getPlayers(); - if (lastDate == -1) { - lastDate = date; - lastPlayers = players; - continue; - } - - long diff = date - lastDate; - if (lastPlayers == 0 && players == 0) { - idleTime += diff; - } - - lastDate = date; - lastPlayers = players; - } - - return idleTime; - } - - public static double aboveLowThreshold(List tpsData) { - if (tpsData.isEmpty()) { - return 1; - } - - int threshold = Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber(); - - long count = 0; - for (TPS tps : tpsData) { - if (tps.getTicksPerSecond() >= threshold) { - count++; - } - } - - return count * 1.0 / tpsData.size(); - } - public PlayerProfile getPlayer(UUID uuid) { if (playerMap == null) { playerMap = players.stream().collect(Collectors.toMap(PlayerProfile::getUuid, Function.identity())); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java index d79102c61d..e719e86d37 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java @@ -11,16 +11,16 @@ public class ActivityIndex { - private static long loadSetting(long value) { - return value < 0 ? 1 : value; - } - private final double value; public ActivityIndex(PlayerProfile player, long date) { value = calculate(player, date); } + private static long loadSetting(long value) { + return value < 0 ? 1 : value; + } + private double calculate(PlayerProfile player, long date) { long week = TimeAmount.WEEK.ms(); long weekAgo = date - week; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java b/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java index 7959596401..e66d5be307 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java @@ -26,13 +26,12 @@ public class HealthNotes { private final List healthNotes; - private double serverHealth; - private final AnalysisData analysisData; private final TreeMap>> activityData; private final List tpsDataMonth; private final long now; private final long fourWeeksAgo; + private double serverHealth; public HealthNotes(AnalysisData analysisData, TreeMap>> activityData, List tpsDataMonth, long now) { this.healthNotes = new ArrayList<>(); diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java index 361bd1d6cf..3b7760a9f6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java @@ -25,21 +25,6 @@ */ public class ServerSpecificSettings { - public void addOriginalBukkitSettings(PlanBungee plugin, UUID serverUUID, Map settings) { - try { - Config config = plugin.getMainConfig(); - if (!Verify.isEmpty(config.getString("Servers." + serverUUID + ".ServerName"))) { - return; - } - for (Map.Entry entry : settings.entrySet()) { - config.set("Servers." + serverUUID + "." + entry.getKey(), entry.getValue()); - } - config.save(); - } catch (IOException e) { - Log.toLog(this.getClass().getName(), e); - } - } - public static void updateSettings(Plan plugin, Map settings) { Log.debug("Checking new settings.."); Config config = plugin.getMainConfig(); @@ -92,6 +77,21 @@ private static Object getValue(String value) { return value; } + public void addOriginalBukkitSettings(PlanBungee plugin, UUID serverUUID, Map settings) { + try { + Config config = plugin.getMainConfig(); + if (!Verify.isEmpty(config.getString("Servers." + serverUUID + ".ServerName"))) { + return; + } + for (Map.Entry entry : settings.entrySet()) { + config.set("Servers." + serverUUID + "." + entry.getKey(), entry.getValue()); + } + config.save(); + } catch (IOException e) { + Log.toLog(this.getClass().getName(), e); + } + } + private String getPath(UUID serverUUID, Settings setting) { String path = "Servers." + serverUUID; switch (setting) { diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java index 3392889e8e..e79fd1a937 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java @@ -44,10 +44,6 @@ public Locale() { messages = new EnumMap<>(Msg.class); } - public void unload() { - messages.clear(); - } - public static Locale getInstance() { Locale locale = ConfigSystem.getInstance().getLocale(); NullCheck.check(locale, new IllegalStateException("Locale has not been initialized.")); @@ -58,6 +54,10 @@ public static Message get(Msg msg) { return getInstance().getMessage(msg); } + public void unload() { + messages.clear(); + } + public void loadLocale() { String locale = Settings.LOCALE.toString().toUpperCase(); Benchmark.start("Initializing locale"); diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java b/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java index 05d2bacc2e..5b1cc3081c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java @@ -33,6 +33,14 @@ public static Theme getInstance() { return themeSystem; } + public static String getValue(ThemeVal variable) { + return getInstance().getThemeValue(variable); + } + + public static String replaceColors(String resourceString) { + return getInstance().replaceThemeColors(resourceString); + } + @Override public void enable() throws EnableException { String themeName = Settings.THEME_BASE.toString(); @@ -95,12 +103,4 @@ public String replaceThemeColors(String resourceString) { public String getThemeValue(ThemeVal color) { return config.getString(color.getThemePath()); } - - public static String getValue(ThemeVal variable) { - return getInstance().getThemeValue(variable); - } - - public static String replaceColors(String resourceString) { - return getInstance().replaceThemeColors(resourceString); - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 9f5346436f..0b1025b16d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -44,6 +44,19 @@ public PlanSystem() { webServerSystem = new WebServerSystem(); } + public static PlanSystem getInstance() { + boolean bukkitAvailable = Check.isBukkitAvailable(); + boolean bungeeAvailable = Check.isBungeeAvailable(); + if (bukkitAvailable && bungeeAvailable) { + // TODO test system. + } else if (bungeeAvailable) { + return BungeeSystem.getInstance(); + } else { + return BukkitSystem.getInstance(); + } + throw new IllegalAccessError("PlanSystem is not available on this platform."); + } + @Override public void enable() throws EnableException { checkSubSystemInitialization(); @@ -93,19 +106,6 @@ private void checkSubSystemInitialization() throws EnableException { } } - public static PlanSystem getInstance() { - boolean bukkitAvailable = Check.isBukkitAvailable(); - boolean bungeeAvailable = Check.isBungeeAvailable(); - if (bukkitAvailable && bungeeAvailable) { - // TODO test system. - } else if (bungeeAvailable) { - return BungeeSystem.getInstance(); - } else { - return BukkitSystem.getInstance(); - } - throw new IllegalAccessError("PlanSystem is not available on this platform."); - } - // Accessor methods. public ProcessingQueue getProcessingQueue() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java index 0e205fab81..cecdffae2e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java @@ -13,7 +13,7 @@ * @author Rsl1122 */ public class BungeeDBSystem extends DBSystem { - + @Override protected void initDatabase() throws DBInitException { db = new MySQLDB(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java index 486dfe4597..e5c22ab805 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java @@ -12,7 +12,7 @@ public static ListenerSystem getInstance() { NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); return listenerSystem; } - + @Override public void enable() { Benchmark.start("Register Listeners"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index eaa6b9f345..a90acb1567 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -4,8 +4,8 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; import com.djrapitops.plan.system.processing.processors.player.*; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.system.tasks.TaskSystem; +import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.systems.NotificationCenter; import com.djrapitops.plugin.api.utility.log.Log; @@ -43,6 +43,10 @@ public PlayerOnlineListener(Plan plugin) { cache = plugin.getDataCache(); } + public static void setCountKicks(boolean value) { + countKicks = value; + } + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerLogin(PlayerLoginEvent event) { try { @@ -147,8 +151,4 @@ public void onPlayerQuit(PlayerQuitEvent event) { Log.toLog(this.getClass(), e); } } - - public static void setCountKicks(boolean value) { - countKicks = value; - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java index 15ececd2a8..8a93a26ac6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java @@ -18,6 +18,13 @@ public Processor(T object) { this.object = object; } + public static void queue(Processor... processors) { + ProcessingQueue processingQueue = ProcessingQueue.getInstance(); + for (Processor processor : processors) { + processingQueue.queue(processor); + } + } + public abstract void process(); public T getObject() { @@ -27,11 +34,4 @@ public T getObject() { public void queue() { queue(this); } - - public static void queue(Processor... processors) { - ProcessingQueue processingQueue = ProcessingQueue.getInstance(); - for (Processor processor : processors) { - processingQueue.queue(processor); - } - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index 0b38a1eeec..5896c2b57a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -101,6 +101,14 @@ public enum Settings { this.configPath = path; } + public static ServerSpecificSettings serverSpecific() { + if (!Check.isBungeeAvailable()) { + throw new IllegalStateException("Not supposed to call this method on Bukkit"); + } + + return serverSpecificSettings; + } + /** * If the settings is a boolean, this method should be used. * @@ -157,12 +165,4 @@ public String getPath() { private Config getConfig() { return ConfigSystem.getInstance().getConfig(); } - - public static ServerSpecificSettings serverSpecific() { - if (!Check.isBungeeAvailable()) { - throw new IllegalStateException("Not supposed to call this method on Bukkit"); - } - - return serverSpecificSettings; - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index b784b76972..abc8f889c8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -22,6 +22,8 @@ */ public class BukkitTaskSystem extends TaskSystem { + private ITask bootAnalysisTask; + public BukkitTaskSystem(Plan plugin) { tpsCountTimer = Check.isPaperAvailable() ? new PaperTPSCountTimer(plugin) @@ -29,8 +31,6 @@ public BukkitTaskSystem(Plan plugin) { } - private ITask bootAnalysisTask; - @Override public void enable() { registerTasks(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java index efd8015531..d1d0b7b02d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java @@ -34,7 +34,7 @@ public void run() { long now = MiscUtils.getTime(); addNewTPSEntry(nanoTime, now); - + if (history.size() >= 60) { plugin.addToProcessQueue(new TPSInsertProcessor(new ArrayList<>(history))); history.clear(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java index 488dcc1b7c..74498d6ef6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java @@ -34,6 +34,10 @@ public static VersionCheckSystem getInstance() { return versionCheckSystem; } + public static boolean isNewVersionAvailable() { + return getInstance().newVersionAvailable; + } + @Override public void enable() { checkForNewVersion(); @@ -63,8 +67,4 @@ private void checkForNewVersion() { public void disable() { /* Does not need to be closed */ } - - public static boolean isNewVersionAvailable() { - return getInstance().newVersionAvailable; - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java index c2ffff451e..3a03c2c3ba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java @@ -18,11 +18,10 @@ * @author Rsl1122 */ public class Request { - private Authentication auth; private final String requestMethod; private final String target; - private final HttpExchange exchange; + private Authentication auth; public Request(HttpExchange exchange) { this.requestMethod = exchange.getRequestMethod(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java index 0432766c05..6e7d72e3c0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java @@ -27,6 +27,11 @@ public static WebServerSystem getInstance() { return PlanSystem.getInstance().getWebServerSystem(); } + public static boolean isWebServerEnabled() { + WebServer webServer = getInstance().webServer; + return webServer != null && webServer.isEnabled(); + } + @Override public void enable() throws EnableException { webServer.initServer(); @@ -44,11 +49,6 @@ public void disable() { webServer.stop(); } - public static boolean isWebServerEnabled() { - WebServer webServer = getInstance().webServer; - return webServer != null && webServer.isEnabled(); - } - public WebServer getWebServer() { return webServer; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java index 5c00e6438d..01ffa16e80 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java @@ -35,6 +35,10 @@ protected String getHeader() { return header; } + public void setHeader(String header) { + this.header = header; + } + public String getResponse() { return header + "\r\n" + "Content-Type: " + type + ";\r\n" @@ -51,10 +55,6 @@ public void setContent(String content) { this.content = content; } - public void setHeader(String header) { - this.header = header; - } - public int getCode() { return header == null ? 500 : Integer.parseInt(header.split(" ")[1]); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java index 7a548b6750..eebc71d94f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java @@ -38,6 +38,10 @@ private InspectPageResponse(InspectPageResponse response) { super.setContent(response.getContent()); } + public static InspectPageResponse copyOf(InspectPageResponse response) { + return new InspectPageResponse(response); + } + public void setInspectPagePluginsTab(String[] inspectPagePluginsTab) { Map replaceMap = new HashMap<>(); replaceMap.put("navPluginsTabs", inspectPagePluginsTab[0]); @@ -45,8 +49,4 @@ public void setInspectPagePluginsTab(String[] inspectPagePluginsTab) { setContent(StrSubstitutor.replace(getContent(), replaceMap)); } - - public static InspectPageResponse copyOf(InspectPageResponse response) { - return new InspectPageResponse(response); - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index fc22058982..fb792b562b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -35,12 +35,36 @@ */ public abstract class WebAPI { + private static TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { + //No need to implement. + } + + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { + //No need to implement. + } + } + }; private Map variables; + public WebAPI() { this.variables = new HashMap<>(); } + public static Map readVariables(String requestBody) { + String[] variables = requestBody.split(";&variable;"); + + return Arrays.stream(variables) + .map(variable -> variable.split("=", 2)) + .filter(splitVariables -> splitVariables.length == 2) + .collect(Collectors.toMap(splitVariables -> splitVariables[0], splitVariables -> splitVariables[1], (a, b) -> b)); + } public Response processRequest(PlanPlugin plugin, Map variables) { String sender = variables.get("sender"); @@ -149,22 +173,6 @@ private SSLSocketFactory getRelaxedSocketFactory() throws NoSuchAlgorithmExcepti return sc.getSocketFactory(); } - private static TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { - //No need to implement. - } - - public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { - //No need to implement. - } - } - }; - protected Response success() { return ResponseCache.loadResponse(PageId.TRUE.id(), SuccessResponse::new); } @@ -190,13 +198,4 @@ private String parseVariables() { } return parameters.toString(); } - - public static Map readVariables(String requestBody) { - String[] variables = requestBody.split(";&variable;"); - - return Arrays.stream(variables) - .map(variable -> variable.split("=", 2)) - .filter(splitVariables -> splitVariables.length == 2) - .collect(Collectors.toMap(splitVariables -> splitVariables[0], splitVariables -> splitVariables[1], (a, b) -> b)); - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java index e9974d4daf..f61f6eef79 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java @@ -15,8 +15,8 @@ @Deprecated public class WebAPIManager extends TreePageHandler { - private final Map registry; private static final Set accessKeys = new HashSet<>(); + private final Map registry; /** * Constructor used to hide the public constructor diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java index 4a642989d0..4c99ce4ddf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java @@ -30,9 +30,8 @@ */ public class GeolocationCache { - private static File geolocationDB = new File(PlanPlugin.getInstance().getDataFolder(), "GeoIP.dat"); - private static final Map geolocationCache = new HashMap<>(); + private static File geolocationDB = new File(PlanPlugin.getInstance().getDataFolder(), "GeoIP.dat"); /** * Constructor used to hide the public constructor diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java index f4de02f559..db4b76a2b8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java @@ -31,6 +31,21 @@ public SessionCache(Plan plugin) { this.plugin = plugin; } + /** + * Used to get the Map of active sessions. + *

+ * Used for testing. + * + * @return key:value UUID:Session + */ + public static Map getActiveSessions() { + return activeSessions; + } + + public static void clear() { + activeSessions.clear(); + } + public void cacheSession(UUID uuid, Session session) { activeSessions.put(uuid, session); plugin.addToProcessQueue(new Processor(plugin) { @@ -76,19 +91,4 @@ public Optional getCachedSession(UUID uuid) { } return Optional.empty(); } - - /** - * Used to get the Map of active sessions. - *

- * Used for testing. - * - * @return key:value UUID:Session - */ - public static Map getActiveSessions() { - return activeSessions; - } - - public static void clear() { - activeSessions.clear(); - } } 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 index 842556d5a1..3e0d15e6c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -62,13 +62,11 @@ public class BukkitInformationManager extends InformationManager { private final Plan plugin; private final DataCache dataCache; private final Analysis analysis; - + private final Map pluginsTabContents; private AnalysisData analysisData; private String analysisPluginsTab; private Long refreshDate; - private final Map pluginsTabContents; - public BukkitInformationManager(Plan plugin) { this.plugin = plugin; dataCache = new DataCache(plugin); 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 index 8155726935..e9e1dc7f73 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -48,11 +48,10 @@ public class BungeeInformationManager extends InformationManager { private final PlanBungee plugin; - private Map bukkitServers; - private final Map networkPageContent; private final Map> pluginsTabContent; private final BungeeServerInfoManager serverInfoManager; + private Map bukkitServers; public BungeeInformationManager(PlanBungee plugin) { usingAnotherWebServer = false; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java index fa8b6ad5eb..10773aa2c6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java @@ -29,9 +29,9 @@ public class BukkitServerInfoManager { private final Plan plugin; + private final ServerTable serverTable; private ServerInfo serverInfo; private ServerInfoFile serverInfoFile; - private final ServerTable serverTable; public BukkitServerInfoManager(Plan plugin) throws EnableException { this.plugin = plugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index c0ad885dd9..137a439628 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -30,11 +30,10 @@ public class BungeeServerInfoManager { private final PlanBungee plugin; - private ServerInfo serverInfo; private final Database db; - private final Map bukkitServers; private final Set onlineServers; + private ServerInfo serverInfo; private ServerTable serverTable; public BungeeServerInfoManager(PlanBungee plugin) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 40e1c1d51c..87ab55e38f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -33,9 +33,9 @@ */ public class Analysis { + private static ServerProfile serverProfile; private final Plan plugin; private int taskId = -1; - private static ServerProfile serverProfile; /** * Class Constructor. @@ -46,6 +46,15 @@ public Analysis(Plan plugin) { this.plugin = plugin; } + /** + * Only available during Analysis. + * + * @return ServerProfile being analyzed or null if analysis is not being run. + */ + public static ServerProfile getServerProfile() { + return serverProfile; + } + /** * Analyzes the data of all offline players on the server. * @@ -221,13 +230,4 @@ private Map analyzeAdditionalPluginData(Set public boolean isAnalysisBeingRun() { return taskId != -1; } - - /** - * Only available during Analysis. - * - * @return ServerProfile being analyzed or null if analysis is not being run. - */ - public static ServerProfile getServerProfile() { - return serverProfile; - } } From dc15c6195361c54861db08eee5a8f7586d6ca218 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 17 Jan 2018 11:10:28 +0200 Subject: [PATCH 022/166] Begun coding new Information transfer system --- .../main/java/com/djrapitops/plan/Plan.java | 4 +- .../com/djrapitops/plan/ShutdownHook.java | 4 +- .../connection/ConnectionFailException.java | 21 +++ .../connection/NoServersException.java | 28 ++++ .../connection/TransferDatabaseException.java | 19 +++ .../UnsupportedTransferDatabaseException.java | 20 +++ .../exceptions/connection/WebException.java | 28 ++++ .../connection/WebFailException.java | 28 ++++ .../WebForbiddenException.java} | 8 +- .../WebInternalErrorException.java} | 8 +- .../connection/WebNotFoundException.java | 16 ++ .../WebUnauthorizedServerException.java | 28 ++++ .../webapi/WebAPIConnectionFailException.java | 21 --- .../exceptions/webapi/WebAPIException.java | 28 ---- .../webapi/WebAPIFailException.java | 28 ---- .../webapi/WebAPINotFoundException.java | 16 -- .../plan/command/commands/DevCommand.java | 8 +- .../commands/manage/ManageClearCommand.java | 4 +- .../commands/manage/ManageRemoveCommand.java | 4 +- .../commands/manage/ManageSetupCommand.java | 8 +- .../djrapitops/plan/system/PlanSystem.java | 20 +++ .../plan/system/cache/CacheSystem.java | 60 +++++++ .../{systems => system}/cache/DataCache.java | 50 +----- .../cache/GeolocationCache.java | 37 +++-- .../cache/SessionCache.java | 56 +++++-- .../system/database/databases/Database.java | 3 + .../operation/TransferOperations.java | 18 +++ .../plan/system/info/InfoSystem.java | 44 +++++ .../system/info/connection/ConnectionOut.java | 150 ++++++++++++++++++ .../info/connection/ConnectionSystem.java | 63 ++++++++ .../info/request/CacheInspectPageRequest.java | 58 +++++++ .../plan/system/info/request/InfoRequest.java | 23 +++ .../system/listeners/bukkit/ChatListener.java | 2 +- .../bukkit/PlayerOnlineListener.java | 2 +- .../importing/importers/Importer.java | 2 +- .../info/InspectCacheRequestProcessor.java | 2 +- .../processors/player/IPUpdateProcessor.java | 2 +- .../processors/player/NameProcessor.java | 2 +- .../webserver/auth/BasicAuthentication.java | 8 +- .../plan/system/webserver/webapi/WebAPI.java | 18 +-- .../webapi/bukkit/AnalysisReadyWebAPI.java | 6 +- .../webapi/bukkit/AnalyzeWebAPI.java | 6 +- .../webapi/bukkit/ConfigurationWebAPI.java | 12 +- .../webapi/bukkit/InspectWebAPI.java | 6 +- .../webapi/bukkit/IsOnlineWebAPI.java | 6 +- .../RequestInspectPluginsTabBukkitWebAPI.java | 6 +- .../webapi/bungee/IsCachedWebAPI.java | 14 +- .../webapi/bungee/PostHtmlWebAPI.java | 8 +- .../bungee/PostInspectPluginsTabWebAPI.java | 6 +- .../bungee/PostNetworkPageContentWebAPI.java | 6 +- .../PostOriginalBukkitSettingsWebAPI.java | 4 +- .../bungee/RequestPluginsTabWebAPI.java | 8 +- .../webapi/bungee/RequestSetupWebAPI.java | 4 +- .../webapi/universal/PingWebAPI.java | 6 +- .../info/BukkitInformationManager.java | 52 +++--- .../info/BungeeInformationManager.java | 22 +-- .../plan/systems/info/InformationManager.java | 4 +- .../info/server/BungeeServerInfoManager.java | 6 +- .../djrapitops/plan/utilities/Base64Util.java | 26 +++ .../plan/utilities/analysis/Analysis.java | 4 +- .../html/tables/SessionsTableCreator.java | 4 +- .../plan/data/cache/DataCacheTest.java | 2 +- .../plan/data/cache/GeolocationCacheTest.java | 2 +- .../plan/data/cache/SessionCacheTest.java | 2 +- .../plan/system/database/DatabaseTest.java | 2 +- .../plan/systems/cache/SessionCacheTest.java | 44 ----- .../main/java/test/utilities/TestInit.java | 2 +- 67 files changed, 869 insertions(+), 350 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/ConnectionFailException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebFailException.java rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{webapi/WebAPIForbiddenException.java => connection/WebForbiddenException.java} (53%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/{webapi/WebAPIInternalErrorException.java => connection/WebInternalErrorException.java} (51%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebNotFoundException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebUnauthorizedServerException.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIConnectionFailException.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIException.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIFailException.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPINotFoundException.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/cache/DataCache.java (72%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/cache/GeolocationCache.java (78%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/cache/SessionCache.java (60%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/InfoSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java delete mode 100644 Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index e4bb731eb3..b7ad942ae0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -27,6 +27,8 @@ import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.BukkitSystem; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.file.FileSystem; @@ -37,8 +39,6 @@ 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.cache.DataCache; -import com.djrapitops.plan.systems.cache.GeolocationCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.systems.info.InformationManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index e6d7b227e9..3488a297fa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -8,10 +8,10 @@ import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.tables.SessionsTable; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/ConnectionFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/ConnectionFailException.java new file mode 100644 index 0000000000..575fb3080b --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/ConnectionFailException.java @@ -0,0 +1,21 @@ +/* + * 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.exceptions.connection; + +/** + * Thrown when Connection fails to connect to an address. + * + * @author Rsl1122 + */ +public class ConnectionFailException extends WebException { + + public ConnectionFailException(String message, Throwable cause) { + super(message, cause); + } + + public ConnectionFailException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java new file mode 100644 index 0000000000..44ecbdc878 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java @@ -0,0 +1,28 @@ +/* + * 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.exceptions.connection; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class NoServersException extends WebException { + + public NoServersException() { + } + + public NoServersException(String message) { + super(message); + } + + public NoServersException(String message, Throwable cause) { + super(message, cause); + } + + public NoServersException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java new file mode 100644 index 0000000000..b4f17cd9af --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java @@ -0,0 +1,19 @@ +/* + * 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.exceptions.connection; + +import com.djrapitops.plan.api.exceptions.database.DBException; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class TransferDatabaseException extends WebException { + + public TransferDatabaseException(DBException cause) { + super(cause); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java new file mode 100644 index 0000000000..2b29b5adca --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java @@ -0,0 +1,20 @@ +/* + * 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.exceptions.connection; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class UnsupportedTransferDatabaseException extends WebException { + + public UnsupportedTransferDatabaseException() { + } + + public UnsupportedTransferDatabaseException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebException.java new file mode 100644 index 0000000000..5b5866f892 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebException.java @@ -0,0 +1,28 @@ +/* + * 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.exceptions.connection; + +/** + * Thrown when Connection POST-request fails, general Exception. + * + * @author Rsl1122 + */ +public class WebException extends Exception { + + public WebException() { + } + + public WebException(String message) { + super(message); + } + + public WebException(String message, Throwable cause) { + super(message, cause); + } + + public WebException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebFailException.java new file mode 100644 index 0000000000..4d1145e3e9 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebFailException.java @@ -0,0 +1,28 @@ +/* + * 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.exceptions.connection; + +/** + * Group of WebExceptions that can be considered a failed connection state on some occasions. + * + * @author Rsl1122 + */ +public class WebFailException extends WebException { + + public WebFailException() { + } + + public WebFailException(String message) { + super(message); + } + + public WebFailException(String message, Throwable cause) { + super(message, cause); + } + + public WebFailException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIForbiddenException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebForbiddenException.java similarity index 53% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIForbiddenException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebForbiddenException.java index 4dc6c0b48a..b289f8deb3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIForbiddenException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebForbiddenException.java @@ -2,15 +2,15 @@ * 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.exceptions.webapi; +package com.djrapitops.plan.api.exceptions.connection; /** - * Thrown when WebAPI gets a 403 response. + * Thrown when Connection gets a 403 response. * * @author Rsl1122 */ -public class WebAPIForbiddenException extends WebAPIFailException { - public WebAPIForbiddenException(String url) { +public class WebForbiddenException extends WebFailException { + public WebForbiddenException(String url) { super("Forbidden: " + url); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIInternalErrorException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebInternalErrorException.java similarity index 51% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIInternalErrorException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebInternalErrorException.java index 144240a73c..f1aeb1a031 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIInternalErrorException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebInternalErrorException.java @@ -2,15 +2,15 @@ * 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.exceptions.webapi; +package com.djrapitops.plan.api.exceptions.connection; /** - * Thrown when WebAPI returns 404, usually when response is supposed to be false. + * Thrown when Connection returns 500. * * @author Rsl1122 */ -public class WebAPIInternalErrorException extends WebAPIFailException { - public WebAPIInternalErrorException() { +public class WebInternalErrorException extends WebFailException { + public WebInternalErrorException() { super("Internal Error occurred on receiving server"); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebNotFoundException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebNotFoundException.java new file mode 100644 index 0000000000..61b428fd26 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebNotFoundException.java @@ -0,0 +1,16 @@ +/* + * 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.exceptions.connection; + +/** + * Thrown when Connection returns 404, when page is not found. + * + * @author Rsl1122 + */ +public class WebNotFoundException extends WebFailException { + public WebNotFoundException() { + super("Not Found"); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebUnauthorizedServerException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebUnauthorizedServerException.java new file mode 100644 index 0000000000..05d706be7b --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebUnauthorizedServerException.java @@ -0,0 +1,28 @@ +/* + * 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.exceptions.connection; + +/** + * Thrown when Connection gets a 412 response due to ServerUUID not being in the database. + * + * @author Rsl1122 + */ +public class WebUnauthorizedServerException extends WebFailException { + + public WebUnauthorizedServerException() { + } + + public WebUnauthorizedServerException(String message) { + super(message); + } + + public WebUnauthorizedServerException(String message, Throwable cause) { + super(message, cause); + } + + public WebUnauthorizedServerException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIConnectionFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIConnectionFailException.java deleted file mode 100644 index a7a675d3c1..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIConnectionFailException.java +++ /dev/null @@ -1,21 +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.api.exceptions.webapi; - -/** - * Thrown when WebAPI fails to connect to an address. - * - * @author Rsl1122 - */ -public class WebAPIConnectionFailException extends WebAPIException { - - public WebAPIConnectionFailException(String message, Throwable cause) { - super(message, cause); - } - - public WebAPIConnectionFailException(Throwable cause) { - super(cause); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIException.java deleted file mode 100644 index 175b15d410..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIException.java +++ /dev/null @@ -1,28 +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.api.exceptions.webapi; - -/** - * Thrown when WebAPI POST-request fails, general Exception. - * - * @author Rsl1122 - */ -public class WebAPIException extends Exception { - - public WebAPIException() { - } - - public WebAPIException(String message) { - super(message); - } - - public WebAPIException(String message, Throwable cause) { - super(message, cause); - } - - public WebAPIException(Throwable cause) { - super(cause); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIFailException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIFailException.java deleted file mode 100644 index acc8fd4281..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPIFailException.java +++ /dev/null @@ -1,28 +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.api.exceptions.webapi; - -/** - * Group of WebAPIExceptions that can be considered a failed connection state on some occasions. - * - * @author Rsl1122 - */ -public class WebAPIFailException extends WebAPIException { - - public WebAPIFailException() { - } - - public WebAPIFailException(String message) { - super(message); - } - - public WebAPIFailException(String message, Throwable cause) { - super(message, cause); - } - - public WebAPIFailException(Throwable cause) { - super(cause); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPINotFoundException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPINotFoundException.java deleted file mode 100644 index 762f264f79..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/webapi/WebAPINotFoundException.java +++ /dev/null @@ -1,16 +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.api.exceptions.webapi; - -/** - * Thrown when WebAPI returns 404, usually when response is supposed to be false. - * - * @author Rsl1122 - */ -public class WebAPINotFoundException extends WebAPIFailException { - public WebAPINotFoundException() { - super("Not Found"); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index 9e094e45b9..79064eeb84 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.webserver.webapi.WebAPI; @@ -39,11 +39,11 @@ public boolean onCommand(ISender sender, String cmd, String[] args) { } String feature = args[0]; switch (feature) { - case "webapi": + case "connection": if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { break; } - if (!webapi(args[1] + "webapi", args.length >= 3)) { + if (!webapi(args[1] + "connection", args.length >= 3)) { sender.sendMessage("[Plan] No such API / Exception occurred."); } break; @@ -78,7 +78,7 @@ private boolean webapi(String method, boolean connectToBungee) { api.sendRequest(address); } return true; - } catch (WebAPIException e) { + } catch (WebException e) { e.printStackTrace(); } return false; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index 311673208b..a95e6543c1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -7,10 +7,10 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index d034451b7f..06c1709b80 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -5,10 +5,10 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.uuid.UUIDUtility; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 2dea249108..661fcf4a53 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIForbiddenException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.WebForbiddenException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; @@ -71,9 +71,9 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { // plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class).sendRequest(address); plugin.getWebServer().getWebAPI().getAPI(RequestSetupWebAPI.class).sendRequest(address); sender.sendMessage("§eConnection successful, Plan may restart in a few seconds, if it doesn't something has gone wrong."); - } catch (WebAPIForbiddenException e) { + } catch (WebForbiddenException e) { sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it."); - } catch (WebAPIException e) { + } catch (WebException e) { Log.toLog(this.getClass().getName(), e); sender.sendMessage("§cConnection to Bungee WebServer failed: More info on console"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 0b1025b16d..201e9395f4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -5,8 +5,10 @@ package com.djrapitops.plan.system; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.cache.CacheSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.listeners.ListenerSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.system.settings.config.ConfigSystem; @@ -29,12 +31,14 @@ public abstract class PlanSystem implements SubSystem { // Initialized in this class protected final ProcessingQueue processingQueue; protected final WebServerSystem webServerSystem; + protected final CacheSystem cacheSystem; // These need to be initialized in the sub class. protected VersionCheckSystem versionCheckSystem; protected FileSystem fileSystem; protected ConfigSystem configSystem; protected DBSystem databaseSystem; + protected InfoSystem infoSystem; protected ListenerSystem listenerSystem; protected TaskSystem taskSystem; @@ -42,6 +46,7 @@ public abstract class PlanSystem implements SubSystem { public PlanSystem() { processingQueue = new ProcessingQueue(); webServerSystem = new WebServerSystem(); + cacheSystem = new CacheSystem(this); } public static PlanSystem getInstance() { @@ -66,7 +71,10 @@ public void enable() throws EnableException { fileSystem, configSystem, databaseSystem, + webServerSystem, + infoSystem, processingQueue, + cacheSystem, listenerSystem, taskSystem }; @@ -78,9 +86,12 @@ public void enable() throws EnableException { @Override public void disable() { SubSystem[] systems = new SubSystem[]{ + cacheSystem, listenerSystem, processingQueue, databaseSystem, + infoSystem, + webServerSystem, taskSystem, configSystem, fileSystem, @@ -99,6 +110,7 @@ private void checkSubSystemInitialization() throws EnableException { NullCheck.check(fileSystem, new IllegalStateException("File system was not initialized.")); NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized.")); NullCheck.check(databaseSystem, new IllegalStateException("Database system was not initialized.")); + NullCheck.check(infoSystem, new IllegalStateException("Info system was not initialized.")); NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); NullCheck.check(taskSystem, new IllegalStateException("Task system was not initialized.")); } catch (Exception e) { @@ -143,4 +155,12 @@ public WebServerSystem getWebServerSystem() { public ServerInfo getServerInfo() { return null; // TODO } + + public CacheSystem getCacheSystem() { + return cacheSystem; + } + + public InfoSystem getInfoSystem() { + return infoSystem; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java new file mode 100644 index 0000000000..e8545317c4 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java @@ -0,0 +1,60 @@ +/* + * 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.cache; + +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.io.IOException; +import java.net.UnknownHostException; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class CacheSystem implements SubSystem { + + private final DataCache dataCache; + private final GeolocationCache geolocationCache; + + public CacheSystem(PlanSystem system) { + dataCache = new DataCache(system); + geolocationCache = new GeolocationCache(); + } + + public static CacheSystem getInstance() { + CacheSystem cacheSystem = PlanSystem.getInstance().getCacheSystem(); + NullCheck.check(cacheSystem, new IllegalStateException("Cache System was not initialized.")); + return cacheSystem; + } + + @Override + public void enable() throws EnableException { + 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() { + geolocationCache.clearCache(); + } + + public DataCache getDataCache() { + return dataCache; + } + + public GeolocationCache getGeolocationCache() { + return geolocationCache; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java similarity index 72% rename from Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java rename to Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java index 20e3cc4773..22f4d60084 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java @@ -1,7 +1,7 @@ -package com.djrapitops.plan.systems.cache; +package com.djrapitops.plan.system.cache; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; @@ -22,7 +22,6 @@ */ public class DataCache extends SessionCache { - private static final Map firstSessionInformation = new HashMap<>(); private final Database db; private final Map playerNames; private final Map uuids; @@ -31,11 +30,11 @@ public class DataCache extends SessionCache { /** * Class Constructor. * - * @param plugin Current instance of Plan + * @param system Instance of PlanSystem */ - public DataCache(Plan plugin) { - super(plugin); - db = plugin.getDB(); + public DataCache(PlanSystem system) { + super(system); + db = system.getDatabaseSystem().getActiveDatabase(); playerNames = new HashMap<>(); displayNames = new HashMap<>(); @@ -115,47 +114,10 @@ public String getDisplayName(UUID uuid) { return cached; } - /** - * Used for marking first Session Actions to be saved. - * - * @param uuid UUID of the new player. - */ - public void markFirstSession(UUID uuid) { - firstSessionInformation.put(uuid, 0); - } - - /** - * Condition if a session is player's first session on the server. - * - * @param uuid UUID of the player - * @return true / false - */ - public boolean isFirstSession(UUID uuid) { - return firstSessionInformation.containsKey(uuid); - } - - public void endFirstSessionActionTracking(UUID uuid) { - firstSessionInformation.remove(uuid); - } - - public void firstSessionMessageSent(UUID uuid) { - Integer msgCount = firstSessionInformation.getOrDefault(uuid, 0); - msgCount++; - firstSessionInformation.put(uuid, msgCount); - } - - public int getFirstSessionMsgCount(UUID uuid) { - return firstSessionInformation.getOrDefault(uuid, 0); - } - public Set getUuids() { return playerNames.keySet(); } - public Map getFirstSessionMsgCounts() { - return firstSessionInformation; - } - public UUID getUUIDof(String playerName) { return uuids.get(playerName); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java similarity index 78% rename from Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java rename to Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java index 4c99ce4ddf..20f43d04bb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/GeolocationCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java @@ -1,6 +1,7 @@ -package com.djrapitops.plan.systems.cache; +package com.djrapitops.plan.system.cache; -import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.utilities.NullCheck; import com.google.common.cache.Cache; import com.maxmind.geoip2.DatabaseReader; import com.maxmind.geoip2.exception.GeoIp2Exception; @@ -30,14 +31,18 @@ */ public class GeolocationCache { - private static final Map geolocationCache = new HashMap<>(); - private static File geolocationDB = new File(PlanPlugin.getInstance().getDataFolder(), "GeoIP.dat"); + private final Map geolocationCache; + private final File geolocationDB; - /** - * Constructor used to hide the public constructor - */ - private GeolocationCache() { - throw new IllegalStateException("Utility class"); + public GeolocationCache() { + geolocationCache = new HashMap<>(); + geolocationDB = new File(FileSystem.getDataFolder(), "GeoIP.dat"); + } + + private static GeolocationCache getInstance() { + GeolocationCache geolocationCache = CacheSystem.getInstance().getGeolocationCache(); + NullCheck.check(geolocationCache, new IllegalStateException("GeolocationCache was not initialized.")); + return geolocationCache; } /** @@ -59,7 +64,7 @@ public static String getCountry(String ipAddress) { return country; } else { country = getUnCachedCountry(ipAddress); - geolocationCache.put(ipAddress, country); + getInstance().geolocationCache.put(ipAddress, country); return country; } @@ -86,7 +91,7 @@ private static String getUnCachedCountry(String ipAddress) { try { checkDB(); - try (DatabaseReader reader = new DatabaseReader.Builder(geolocationDB).build()) { + try (DatabaseReader reader = new DatabaseReader.Builder(getInstance().geolocationDB).build()) { InetAddress inetAddress = InetAddress.getByName(ipAddress); CountryResponse response = reader.country(inetAddress); @@ -106,12 +111,12 @@ private static String getUnCachedCountry(String ipAddress) { * @throws IOException when an error at download or saving the DB happens */ public static void checkDB() throws IOException { - if (geolocationDB.exists()) { + if (getInstance().geolocationDB.exists()) { return; } URL downloadSite = new URL("http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz"); try (ReadableByteChannel rbc = Channels.newChannel(new GZIPInputStream(downloadSite.openStream())); - FileOutputStream fos = new FileOutputStream(geolocationDB.getAbsoluteFile())) { + FileOutputStream fos = new FileOutputStream(getInstance().geolocationDB.getAbsoluteFile())) { fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } } @@ -123,7 +128,7 @@ public static void checkDB() throws IOException { * @return The cached country, {@code null} if the country is not cached */ private static String getCachedCountry(String ipAddress) { - return geolocationCache.get(ipAddress); + return getInstance().geolocationCache.get(ipAddress); } /** @@ -133,13 +138,13 @@ private static String getCachedCountry(String ipAddress) { * @return true if the IP Address is cached */ public static boolean isCached(String ipAddress) { - return geolocationCache.containsKey(ipAddress); + return getInstance().geolocationCache.containsKey(ipAddress); } /** * Clears the cache */ - public static void clearCache() { + public void clearCache() { geolocationCache.clear(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java similarity index 60% rename from Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java rename to Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java index db4b76a2b8..e799a685db 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java @@ -1,8 +1,8 @@ -package com.djrapitops.plan.systems.cache; +package com.djrapitops.plan.system.cache; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.utilities.MiscUtils; @@ -21,14 +21,15 @@ */ public class SessionCache { + private static final Map firstSessionInformation = new HashMap<>(); private static final Map activeSessions = new HashMap<>(); - protected final Plan plugin; + protected final PlanSystem system; /** * Class Constructor. */ - public SessionCache(Plan plugin) { - this.plugin = plugin; + public SessionCache(PlanSystem system) { + this.system = system; } /** @@ -48,12 +49,12 @@ public static void clear() { public void cacheSession(UUID uuid, Session session) { activeSessions.put(uuid, session); - plugin.addToProcessQueue(new Processor(plugin) { + new Processor(system) { @Override public void process() { - plugin.getInfoManager().cachePlayer(uuid); + system.getInfoManager().cachePlayer(uuid); } - }); + }.queue(); } public void endSession(UUID uuid, long time) { @@ -68,7 +69,7 @@ public void endSession(UUID uuid, long time) { Log.toLog(this.getClass().getName(), e); } finally { activeSessions.remove(uuid); - plugin.getInfoManager().cachePlayer(uuid); + system.getInfoManager().cachePlayer(uuid); } } @@ -91,4 +92,41 @@ public Optional getCachedSession(UUID uuid) { } return Optional.empty(); } + + /** + * Used for marking first Session Actions to be saved. + * + * @param uuid UUID of the new player. + */ + public void markFirstSession(UUID uuid) { + firstSessionInformation.put(uuid, 0); + } + + /** + * Condition if a session is player's first session on the server. + * + * @param uuid UUID of the player + * @return true / false + */ + public boolean isFirstSession(UUID uuid) { + return firstSessionInformation.containsKey(uuid); + } + + public void endFirstSessionActionTracking(UUID uuid) { + firstSessionInformation.remove(uuid); + } + + public void firstSessionMessageSent(UUID uuid) { + Integer msgCount = firstSessionInformation.getOrDefault(uuid, 0); + msgCount++; + firstSessionInformation.put(uuid, msgCount); + } + + public int getFirstSessionMsgCount(UUID uuid) { + return firstSessionInformation.getOrDefault(uuid, 0); + } + + public Map getFirstSessionMsgCounts() { + return firstSessionInformation; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index 2390a4e114..59ace042b1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -1,5 +1,6 @@ package com.djrapitops.plan.system.database.databases; +import com.djrapitops.plan.api.exceptions.connection.UnsupportedTransferDatabaseException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.DBSystem; @@ -67,4 +68,6 @@ public boolean isOpen() { } public abstract void scheduleClean(long delay); + + public abstract TransferOperations transfer() throws UnsupportedTransferDatabaseException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java new file mode 100644 index 0000000000..44ca4c8fa4 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -0,0 +1,18 @@ +/* + * 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.database.databases.operation; + +import com.djrapitops.plan.api.exceptions.database.DBException; + +import java.util.UUID; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public interface TransferOperations { + void playerHtml(UUID player, String html) throws DBException; +} \ No newline at end of file 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 new file mode 100644 index 0000000000..0e94a805cf --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/InfoSystem.java @@ -0,0 +1,44 @@ +/* + * 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.info; + +import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; +import com.djrapitops.plan.utilities.NullCheck; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public abstract class InfoSystem implements SubSystem { + + protected final ConnectionSystem connectionSystem; + + public InfoSystem(ConnectionSystem connectionSystem) { + this.connectionSystem = connectionSystem; + } + + public static InfoSystem getInstance() { + InfoSystem infoSystem = PlanSystem.getInstance().getInfoSystem(); + NullCheck.check(infoSystem, new IllegalStateException("Info System was not initialized.")); + return infoSystem; + } + + @Override + public void enable() { + + } + + @Override + public void disable() { + + } + + public ConnectionSystem getConnectionSystem() { + return connectionSystem; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java new file mode 100644 index 0000000000..ed37159d88 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -0,0 +1,150 @@ +/* + * 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.info.connection; + +import com.djrapitops.plan.api.exceptions.connection.*; +import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.utilities.Verify; + +import javax.net.ssl.*; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.util.UUID; + +/** + * Represents an outbound action request to another Plan server. + * + * @author Rsl1122 + */ +public class ConnectionOut { + + private static final TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { + //No need to implement. + } + + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { + //No need to implement. + } + } + }; + + private final String address; + private final UUID serverUUID; + private final InfoRequest infoRequest; + + /** + * Constructor. + * + * @param address Full address to another Plan webserver. (http://something:port) + * @param serverUUID UUID of server this outbound connection. + * @param infoRequest Type of the action this connection wants to be performed. + */ + public ConnectionOut(String address, UUID serverUUID, InfoRequest infoRequest) { + Verify.nullCheck(address, serverUUID, infoRequest); + this.address = address; + this.serverUUID = serverUUID; + this.infoRequest = infoRequest; + } + + public void sendRequest() throws WebException { + try { + URL url = new URL(address + "/api/" + this.getClass().getSimpleName().toLowerCase()); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + if (address.startsWith("https")) { + HttpsURLConnection httpsConn = (HttpsURLConnection) connection; + + // Disables unsigned certificate & hostname check, because we're trusting the user given certificate. + + // This allows https connections internally to local ports. + httpsConn.setHostnameVerifier((hostname, session) -> true); + + // This allows connecting to connections with invalid certificate + // Drawback: MitM attack possible between connections to servers that are not local. + // Scope: WebAPI transmissions + // Risk: Attacker sets up a server between Bungee and Bukkit WebServers + // - Negotiates SSL Handshake with both servers + // - Receives the SSL encrypted data, but decrypts it in the MitM server. + // -> Access to valid ServerUUID for POST requests + // -> Access to sending Html to the (Bungee) WebServer + // Mitigating factors: + // - If Server owner has access to all routing done on the domain (IP/Address) + // - If Direct IPs are used to transfer between servers + // Alternative solution: WebAPI run only on HTTP, HTTP can be read during transmission, + // would require running two WebServers when HTTPS is used. + httpsConn.setSSLSocketFactory(getRelaxedSocketFactory()); + } + connection.setConnectTimeout(10000); + connection.setDoOutput(true); + connection.setInstanceFollowRedirects(false); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + + connection.setRequestProperty("charset", "UTF-8"); + + String parameters = parseVariables(); + infoRequest.placeDataToDatabase(); + + connection.setRequestProperty("Content-Length", Integer.toString(parameters.length())); + + byte[] toSend = parameters.getBytes(); + + connection.setUseCaches(false); + Log.debug("ConnectionOut: " + infoRequest.getClass().getSimpleName() + " to " + address); + try (DataOutputStream out = new DataOutputStream(connection.getOutputStream())) { + out.write(toSend); + } + + int responseCode = connection.getResponseCode(); + Log.debug("Response: " + responseCode); + switch (responseCode) { + case 200: + return; + case 400: + throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters); + case 403: + throw new WebForbiddenException(url.toString()); + case 404: + throw new WebNotFoundException(); + case 412: + throw new WebUnauthorizedServerException(); + case 500: + throw new WebInternalErrorException(); + default: + throw new WebException(url.toString() + "| Wrong response code " + responseCode); + } + } catch (SocketTimeoutException e) { + throw new ConnectionFailException("Connection timed out after 10 seconds.", e); + } catch (NoSuchAlgorithmException | KeyManagementException | IOException e) { + if (Settings.DEV_MODE.isTrue()) { + Log.toLog(this.getClass().getName(), e); + } + throw new ConnectionFailException("Connection failed. address: " + address, e); + } + } + + private String parseVariables() { + return "sender=" + serverUUID + ";&variable;" + + "type=" + infoRequest.getClass().getSimpleName(); + } + + private SSLSocketFactory getRelaxedSocketFactory() throws NoSuchAlgorithmException, KeyManagementException { + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + return sc.getSocketFactory(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java new file mode 100644 index 0000000000..783a530682 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -0,0 +1,63 @@ +/* + * 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.info.connection; + +import com.djrapitops.plan.api.exceptions.connection.NoServersException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.request.CacheInspectPageRequest; +import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.utilities.NullCheck; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * ConnectionSystem manages out- and inbound InfoRequest connections. + *

+ * It decides what server to use for each request. + * + * @author Rsl1122 + */ +public abstract class ConnectionSystem { + + protected final Map dataRequests; + protected final UUID serverUUID; + protected Map servers; + + public ConnectionSystem(UUID serverUUID) { + this.serverUUID = serverUUID; + + servers = new HashMap<>(); + dataRequests = loadDataRequests(); + } + + public static ConnectionSystem getInstance() { + ConnectionSystem connectionSystem = InfoSystem.getInstance().getConnectionSystem(); + NullCheck.check(connectionSystem, new IllegalStateException("Connection System was not initialized")); + return connectionSystem; + } + + private Map loadDataRequests() { + Map requests = new HashMap<>(); + putRequest(requests, CacheInspectPageRequest.createHandler()); + return requests; + } + + private void putRequest(Map requests, InfoRequest request) { + requests.put(request.getClass().getSimpleName(), request); + } + + protected abstract ServerInfo selectServerForRequest(InfoRequest infoRequest) throws NoServersException; + + public void sendInfoRequest(InfoRequest infoRequest) throws WebException { + ServerInfo serverInfo = selectServerForRequest(infoRequest); + String address = serverInfo.getWebAddress(); + + new ConnectionOut(address, serverUUID, infoRequest).sendRequest(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java new file mode 100644 index 0000000000..ae79b55b3b --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -0,0 +1,58 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.utilities.Base64Util; +import com.djrapitops.plugin.utilities.Verify; + +import java.util.Map; +import java.util.UUID; + +/** + * InfoRequest used to place HTML of a player to ResponseCache. + * + * @author Rsl1122 + */ +public class CacheInspectPageRequest implements InfoRequest { + + private final UUID player; + private final String html; + + private CacheInspectPageRequest() { + player = null; + html = null; + } + + public CacheInspectPageRequest(UUID player, String html) { + this.player = player; + this.html = html; + } + + public static CacheInspectPageRequest createHandler() { + return new CacheInspectPageRequest(); + } + + @Override + public void placeDataToDatabase() throws WebException { + Verify.nullCheck(player, html); + + String encodedHtml = Base64Util.encode(html); + try { + Database.getActive().transfer().playerHtml(player, encodedHtml); + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + } + + @Override + public Response handleRequest(Map variables) { + return null; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java new file mode 100644 index 0000000000..9f9e7b9a0e --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java @@ -0,0 +1,23 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.Map; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public interface InfoRequest { + + void placeDataToDatabase() throws WebException; + + Response handleRequest(Map variables); + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java index d0e4e2588a..7de1bf1b95 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.system.listeners.bukkit; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.processing.processors.player.NameProcessor; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index a90acb1567..2b5aacc84c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; import com.djrapitops.plan.system.processing.processors.player.*; import com.djrapitops.plan.system.tasks.TaskSystem; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.systems.NotificationCenter; import com.djrapitops.plugin.api.utility.log.Log; 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/processors/importing/importers/Importer.java index e9e4d84c63..3c343aea7e 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/processors/importing/importers/Importer.java @@ -10,11 +10,11 @@ import com.djrapitops.plan.data.container.Session; 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.systems.cache.GeolocationCache; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java index 5e57630f02..b0e28ef5e0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java @@ -8,8 +8,8 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java index a42c4d9fc2..e857facb8c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/IPUpdateProcessor.java @@ -6,8 +6,8 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.GeoInfo; +import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.systems.cache.GeolocationCache; import com.djrapitops.plugin.api.utility.log.Log; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java index 421f6106fb..5c44579909 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java @@ -6,10 +6,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plugin.api.utility.log.Log; import java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java index bede10e1f3..50d5dc5d83 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java @@ -9,10 +9,9 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.utilities.Base64Util; import com.djrapitops.plan.utilities.PassEncryptUtil; -import java.util.Base64; - /** * //TODO Class Javadoc Comment * @@ -30,9 +29,8 @@ public BasicAuthentication(String authenticationString) { @Override public WebUser getWebUser() throws WebUserAuthException { - Base64.Decoder decoder = Base64.getDecoder(); - byte[] decoded = decoder.decode(authenticationString); - String[] userInfo = new String(decoded).split(":"); + String decoded = Base64Util.decode(authenticationString); + String[] userInfo = decoded.split(":"); if (userInfo.length != 2) { throw new WebUserAuthException(FailReason.USER_AND_PASS_NOT_SPECIFIED); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index fb792b562b..22fdd0f88a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.*; +import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; @@ -84,7 +84,7 @@ public Response processRequest(PlanPlugin plugin, Map variables) public abstract Response onRequest(PlanPlugin plugin, Map variables); - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { Verify.nullCheck(address); try { @@ -139,23 +139,23 @@ public void sendRequest(String address) throws WebAPIException { case 200: return; case 400: - throw new WebAPIFailException("Bad Request: " + url.toString() + "|" + parameters); + throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters); case 403: - throw new WebAPIForbiddenException(url.toString()); + throw new WebForbiddenException(url.toString()); case 404: - throw new WebAPINotFoundException(); + throw new WebNotFoundException(); case 500: - throw new WebAPIInternalErrorException(); + throw new WebInternalErrorException(); default: - throw new WebAPIException(url.toString() + "| Wrong response code " + responseCode); + throw new WebException(url.toString() + "| Wrong response code " + responseCode); } } catch (SocketTimeoutException e) { - throw new WebAPIConnectionFailException("Connection timed out after 10 seconds.", e); + throw new ConnectionFailException("Connection timed out after 10 seconds.", e); } catch (NoSuchAlgorithmException | KeyManagementException | IOException e) { if (Settings.DEV_MODE.isTrue()) { Log.toLog(this.getClass().getName(), e); } - throw new WebAPIConnectionFailException("API connection failed. address: " + address, e); + throw new ConnectionFailException("API connection failed. address: " + address, e); } } 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 6dfd6c16d4..af3d13be77 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 @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; @@ -28,11 +28,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendRequest(String address, UUID serverUUID) throws WebAPIException { + public void sendRequest(String address, UUID serverUUID) throws WebException { addVariable("serverUUID", serverUUID.toString()); super.sendRequest(address); } 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 7a4699a43b..621b13f651 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 @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; @@ -28,11 +28,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendRequest(String address, UUID serverUUID) throws WebAPIException { + public void sendRequest(String address, UUID serverUUID) throws WebException { addVariable("serverUUID", serverUUID.toString()); super.sendRequest(address); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index 16f92b044c..efe6f06fa8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.settings.ServerSpecificSettings; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; @@ -41,11 +41,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendRequest(String address, UUID serverUUID, String accessKey) throws WebAPIException { + public void sendRequest(String address, UUID serverUUID, String accessKey) throws WebException { if (accessKey != null) { addVariable("accessKey", accessKey); } @@ -54,7 +54,7 @@ public void sendRequest(String address, UUID serverUUID, String accessKey) throw sendRequest(address, serverUUID); } - public void sendRequest(String address, UUID serverUUID) throws WebAPIException { + public void sendRequest(String address, UUID serverUUID) throws WebException { Map configValues = getConfigValues(serverUUID); for (Map.Entry entry : configValues.entrySet()) { String key = entry.getKey(); @@ -73,10 +73,10 @@ private void addConfigValue(Map configValues, Settings setting, } } - private Map getConfigValues(UUID serverUUID) throws WebAPIException { + private Map getConfigValues(UUID serverUUID) throws WebException { Map configValues = new HashMap<>(); if (!Check.isBungeeAvailable()) { - throw new WebAPIException("Attempted to send config values from Bukkit to Bungee."); + throw new WebException("Attempted to send config values from Bukkit to Bungee."); } addConfigValue(configValues, Settings.DB_TYPE, "mysql"); Settings[] sameStrings = new Settings[]{ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java index bd03e9f984..99c1c7f1da 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; @@ -30,11 +30,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendRequest(String address, UUID uuid) throws WebAPIException { + public void sendRequest(String address, UUID uuid) throws WebException { addVariable("uuid", uuid.toString()); super.sendRequest(address); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java index b60573e93d..47f1e50fe1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import org.bukkit.entity.Player; @@ -36,11 +36,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendRequest(String address, UUID uuid) throws WebAPIException { + public void sendRequest(String address, UUID uuid) throws WebException { addVariable("uuid", uuid.toString()); super.sendRequest(address); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java index 033b2bb425..86447cbe5d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BukkitInformationManager; @@ -44,11 +44,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendRequest(String address, UUID uuid) throws WebAPIException { + public void sendRequest(String address, UUID uuid) throws WebException { addVariable("uuid", uuid.toString()); super.sendRequest(address); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java index 619fdb8d41..fe64a38646 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.WebNotFoundException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.InformationManager; @@ -52,28 +52,28 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public boolean isInspectCached(String address, UUID uuid) throws WebAPIException { + public boolean isInspectCached(String address, UUID uuid) throws WebException { addVariable("uuid", uuid.toString()); addVariable("target", "inspectPage"); try { super.sendRequest(address); return true; - } catch (WebAPINotFoundException e) { + } catch (WebNotFoundException e) { return false; } } - public boolean isAnalysisCached(String address, UUID serverUUID) throws WebAPIException { + public boolean isAnalysisCached(String address, UUID serverUUID) throws WebException { addVariable("serverUUID", serverUUID.toString()); addVariable("target", "analysisPage"); try { super.sendRequest(address); return true; - } catch (WebAPINotFoundException e) { + } catch (WebNotFoundException e) { return false; } } 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 bbfdb5674a..5d1bccad23 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 @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; @@ -77,18 +77,18 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendInspectHtml(String address, UUID uuid, String html) throws WebAPIException { + public void sendInspectHtml(String address, UUID uuid, String html) throws WebException { addVariable("uuid", uuid.toString()); addVariable("target", "inspectPage"); addVariable("html", html); super.sendRequest(address); } - public void sendAnalysisHtml(String address, String html) throws WebAPIException { + public void sendAnalysisHtml(String address, String html) throws WebException { addVariable("html", html); addVariable("target", "analysisPage"); super.sendRequest(address); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java index 7189704475..3b3af604cc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BungeeInformationManager; @@ -49,11 +49,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendPluginsTab(String address, UUID uuid, String[] html) throws WebAPIException { + public void sendPluginsTab(String address, UUID uuid, String[] html) throws WebException { addVariable("uuid", uuid.toString()); addVariable("nav", html[0]); addVariable("html", html[1]); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java index fe727442f3..250aa896da 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BungeeInformationManager; @@ -38,11 +38,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendNetworkContent(String address, String html) throws WebAPIException { + public void sendNetworkContent(String address, String html) throws WebException { addVariable("html", html); super.sendRequest(address); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java index 0e46347270..502d30bfb7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +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.webapi.WebAPI; @@ -48,7 +48,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { addVariable("WebServerPort", Integer.toString(Settings.WEBSERVER_PORT.getNumber())); addVariable("ServerName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); addVariable("ThemeBase", Settings.THEME_BASE.toString()); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index 4ea46a7db7..7185e2a652 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; @@ -49,11 +49,11 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } - public void sendRequest(String address, UUID uuid) throws WebAPIException { + public void sendRequest(String address, UUID uuid) throws WebException { addVariable("uuid", uuid.toString()); super.sendRequest(address); } @@ -68,7 +68,7 @@ public void process() { String webAddress = server.getWebAddress(); try { plugin.getWebServer().getWebAPI().getAPI(RequestInspectPluginsTabBukkitWebAPI.class).sendRequest(webAddress, uuid); - } catch (WebAPIException ignore) { + } catch (WebException ignore) { /* ignored */ } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index 61d9fb1c51..ed286edeef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; @@ -50,7 +50,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { if (!Check.isBukkitAvailable()) { throw new IllegalStateException("Not supposed to be called on Bungee"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java index f613d8eb4a..9ad15501ab 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.BukkitInformationManager; @@ -45,7 +45,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebAPIException { + public void sendRequest(String address) throws WebException { if (Check.isBukkitAvailable()) { super.sendRequest(address); } else { @@ -54,7 +54,7 @@ public void sendRequest(String address) throws WebAPIException { } } - public void sendRequest(String address, String accessCode) throws WebAPIException { + public void sendRequest(String address, String accessCode) throws WebException { addVariable("accessKey", accessCode); addVariable("version", PlanPlugin.getInstance().getVersion()); sendRequest(address); 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 index 3e0d15e6c4..9136525c3e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -6,16 +6,17 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIConnectionFailException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIFailException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException; +import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.WebFailException; +import com.djrapitops.plan.api.exceptions.connection.WebNotFoundException; import com.djrapitops.plan.command.commands.AnalyzeCommand; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.WebServer; @@ -34,7 +35,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.*; import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.parsing.AnalysisPage; import com.djrapitops.plan.systems.info.parsing.InspectPage; import com.djrapitops.plan.utilities.MiscUtils; @@ -93,9 +93,9 @@ public void refreshAnalysis(UUID serverUUID) { } else if (usingAnotherWebServer) { try { getWebAPI().getAPI(AnalyzeWebAPI.class).sendRequest(webServerAddress, serverUUID); - } catch (WebAPIFailException e) { + } catch (WebFailException e) { Log.error("Failed to request Analysis refresh from Bungee."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); refreshAnalysis(serverUUID); } @@ -112,9 +112,9 @@ public void cachePlayer(UUID uuid) { if (usingAnotherWebServer) { try { getWebAPI().getAPI(PostHtmlWebAPI.class).sendInspectHtml(webServerAddress, uuid, getPlayerHtml(uuid)); - } catch (WebAPIFailException e) { + } catch (WebFailException e) { Log.error("Failed to request Inspect from Bungee."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); cachePlayer(uuid); } catch (ParseException e) { @@ -156,9 +156,9 @@ public void cacheInspectPluginsTab(UUID uuid, Class origin) { if (usingAnotherWebServer && !origin.equals(RequestInspectPluginsTabBukkitWebAPI.class)) { try { getWebAPI().getAPI(RequestPluginsTabWebAPI.class).sendRequest(webServerAddress, uuid); - } catch (WebAPIFailException e) { + } catch (WebFailException e) { Log.error("Failed send Player Plugins tab contents to BungeeCord."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); cacheInspectPluginsTab(uuid, origin); } @@ -188,9 +188,9 @@ public void cacheInspectPluginsTab(UUID uuid, String[] contents) { if (usingAnotherWebServer) { try { getWebAPI().getAPI(PostInspectPluginsTabWebAPI.class).sendPluginsTab(webServerAddress, uuid, contents); - } catch (WebAPIFailException e) { + } catch (WebFailException e) { Log.error("Failed send Player HTML to BungeeCord."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); cacheInspectPluginsTab(uuid, contents); } @@ -214,9 +214,9 @@ public boolean isCached(UUID uuid) { if (usingAnotherWebServer) { try { return getWebAPI().getAPI(IsCachedWebAPI.class).isInspectCached(webServerAddress, uuid); - } catch (WebAPIFailException e) { + } catch (WebFailException e) { Log.error("Failed check Bungee Player Cache status."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); return isCached(uuid); } @@ -232,9 +232,9 @@ public boolean isAnalysisCached(UUID serverUUID) { if (usingAnotherWebServer) { try { return getWebAPI().getAPI(IsCachedWebAPI.class).isAnalysisCached(webServerAddress, serverUUID); - } catch (WebAPIFailException e) { + } catch (WebFailException e) { Log.error("Failed check Bungee Analysis Cache status."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); return isAnalysisCached(serverUUID); } @@ -289,9 +289,9 @@ public void cacheAnalysisData(AnalysisData analysisData) { getWebAPI().getAPI(AnalysisReadyWebAPI.class).sendRequest(webServerAddress, serverUUID); updateNetworkPageContent(); return; - } catch (WebAPIFailException ignored) { + } catch (WebFailException ignored) { Log.error("Failed to notify Bungee of Analysis Completion."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); } } @@ -306,9 +306,9 @@ public void cacheAnalysisHtml(String html) { if (usingAnotherWebServer) { try { getWebAPI().getAPI(PostHtmlWebAPI.class).sendAnalysisHtml(webServerAddress, html); - } catch (WebAPIFailException e) { + } catch (WebFailException e) { Log.error("Failed to send Analysis HTML to Bungee Server."); - } catch (WebAPIException e) { + } catch (WebException e) { attemptConnection(); cacheAnalysisHtml(html); } @@ -344,11 +344,11 @@ public boolean attemptConnection() { plugin.getServerInfoManager().resetConnectionFails(); usingAnotherWebServer = true; return true; - } catch (WebAPIConnectionFailException e) { + } catch (ConnectionFailException e) { plugin.getServerInfoManager().markConnectionFail(); - } catch (WebAPINotFoundException e) { + } catch (WebNotFoundException e) { Log.info("Bungee reported that UUID of this server is not in the MySQL-database. Try using '/plan m setup " + webServerAddress + "' again"); - } catch (WebAPIException e) { + } catch (WebException e) { Log.toLog(this.getClass().getName(), e); } Log.info("Bungee Connection Failed."); @@ -384,9 +384,9 @@ public void updateNetworkPageContent() { if (usingAnotherWebServer) { try { getWebAPI().getAPI(PostNetworkPageContentWebAPI.class).sendNetworkContent(webServerAddress, HtmlStructure.createServerContainer(plugin)); - } catch (WebAPIFailException ignored) { + } catch (WebFailException ignored) { /* Do nothing */ - } catch (WebAPIException ignored) { + } catch (WebException ignored) { attemptConnection(); updateNetworkPageContent(); } 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 index e9e1dc7f73..0ec4b244bc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -7,9 +7,10 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIConnectionFailException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException; +import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.WebNotFoundException; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; @@ -24,7 +25,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.parsing.NetworkPage; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; import com.djrapitops.plan.systems.info.server.ServerInfo; @@ -91,9 +91,9 @@ public void refreshAnalysis(UUID serverUUID) { AnalyzeWebAPI api = plugin.getWebServer().getWebAPI().getAPI(AnalyzeWebAPI.class); try { api.sendRequest(serverInfo.getWebAddress(), serverUUID); - } catch (WebAPIConnectionFailException e) { + } catch (ConnectionFailException e) { attemptConnection(); - } catch (WebAPIException e) { + } catch (WebException e) { Log.toLog(this.getClass().getName(), e); } } @@ -147,7 +147,7 @@ public void cachePlayer(UUID uuid) { apiManager.getAPI(RequestPluginsTabWebAPI.class).sendRequestsToBukkitServers(plugin, uuid); } catch (IllegalStateException ignored) { /* Ignored */ - } catch (WebAPIException e) { + } catch (WebException e) { plugin.getServerInfoManager().attemptConnection(inspectServer); } } @@ -181,11 +181,11 @@ private ServerInfo getInspectRequestProcessorServer(UUID uuid) { try { getWebAPI().getAPI(IsOnlineWebAPI.class).sendRequest(server.getWebAddress(), uuid); return server; - } catch (WebAPIConnectionFailException e) { + } catch (ConnectionFailException e) { serverInfoManager.serverHasGoneOffline(server.getUuid()); - } catch (WebAPINotFoundException ignored) { + } catch (WebNotFoundException ignored) { /*continue*/ - } catch (WebAPIException e) { + } catch (WebException e) { Log.toLog(this.getClass().getName(), e); } } @@ -364,7 +364,7 @@ public void analysisReady(UUID serverUUID) { for (ServerInfo serverInfo : serverInfoManager.getOnlineBukkitServers()) { try { api.sendRequest(serverInfo.getWebAddress(), serverUUID); - } catch (WebAPIException ignored) { + } catch (WebException ignored) { /*Ignored*/ } } 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 index 11e39f7f38..fc89153908 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -5,10 +5,10 @@ package com.djrapitops.plan.systems.info; import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.webserver.pagecache.PageId; import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plugin.command.ISender; import java.io.IOException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java index 137a439628..c5b00aead9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.api.exceptions.webapi.WebAPIException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI; @@ -105,7 +105,7 @@ public boolean attemptConnection(ServerInfo server, String accessCode) { } connectedToServer(server); return true; - } catch (WebAPIException e) { + } catch (WebException e) { Log.debug(e.toString()); serverHasGoneOffline(server.getUuid()); return false; @@ -126,7 +126,7 @@ public void sendConfigSettings(UUID serverUUID) { webAddress = server.getWebAddress(); Log.debug("Sending config settings to " + webAddress + ""); plugin.getWebServer().getWebAPI().getAPI(ConfigurationWebAPI.class).sendRequest(webAddress, serverUUID); - } catch (WebAPIException e) { + } catch (WebException e) { Log.info("Connection to Bukkit (" + webAddress + ") did not succeed."); serverHasGoneOffline(serverUUID); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java b/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java new file mode 100644 index 0000000000..52ea958f7b --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java @@ -0,0 +1,26 @@ +/* + * 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.utilities; + +import java.util.Base64; + +/** + * //TODO Class Javadoc Comment + * + * @author Rsl1122 + */ +public class Base64Util { + + public static String encode(String decoded) { + byte[] encoded = Base64.getEncoder().encode(decoded.getBytes()); + return new String(encoded); + } + + public static String decode(String encoded) { + byte[] decoded = Base64.getDecoder().decode(encoded.getBytes()); + return new String(decoded); + } + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 87ab55e38f..34aac9ba59 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -9,14 +9,14 @@ import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.tasks.BukkitTaskSystem; import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plugin.StaticHolder; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index cbf528ce4f..1d54b69bbb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -9,9 +9,9 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.settings.WorldAliasSettings; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.comparators.SessionStartComparator; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java index 13877e46ea..5c86cf1e25 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java @@ -5,8 +5,8 @@ */ package com.djrapitops.plan.data.cache; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.systems.cache.DataCache; import org.bukkit.plugin.java.JavaPlugin; import org.junit.After; import org.junit.Before; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java index 0f1a3dc6dd..95b58a9e73 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.data.cache; -import com.djrapitops.plan.systems.cache.GeolocationCache; +import com.djrapitops.plan.system.cache.GeolocationCache; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; import org.junit.Test; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java index 5a2372f94b..6616e0d2b4 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java @@ -5,7 +5,7 @@ */ package com.djrapitops.plan.data.cache; -import com.djrapitops.plan.systems.cache.SessionCache; +import com.djrapitops.plan.system.cache.SessionCache; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; import org.junit.Test; diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index 9172b32a8e..a6cc6d1193 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -13,13 +13,13 @@ import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.MySQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.server.ServerInfo; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java deleted file mode 100644 index 9b8d890b36..0000000000 --- a/Plan/test/main/java/com/djrapitops/plan/systems/cache/SessionCacheTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.djrapitops.plan.systems.cache; - -import com.djrapitops.plan.data.container.Session; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.MockUtils; -import test.utilities.TestInit; - -import java.util.Optional; -import java.util.UUID; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) -public class SessionCacheTest { - - private final UUID uuid = MockUtils.getPlayerUUID(); - private SessionCache sessionCache; - private Session session; - - @Before - public void setUp() throws Exception { - TestInit t = TestInit.init(); - sessionCache = new SessionCache(null); - session = new Session(12345L, "World1", "SURVIVAL"); - sessionCache.cacheSession(uuid, session); - } - - @Test - @Ignore("Ignored, Requires more mocks") - public void testAtomity() { - SessionCache reloaded = new SessionCache(null); - Optional cachedSession = reloaded.getCachedSession(uuid); - assertTrue(cachedSession.isPresent()); - assertEquals(session, cachedSession.get()); - } -} \ No newline at end of file diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index 4f81875370..4ae15a3686 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -3,8 +3,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.settings.locale.Locale; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.IPlugin; From 7118c67c7e883a9402c815cf9a6bd60a3b3e957d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 17 Jan 2018 11:11:13 +0200 Subject: [PATCH 023/166] Add missing files to VCS --- .../plan/system/cache/SessionCacheTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Plan/test/main/java/com/djrapitops/plan/system/cache/SessionCacheTest.java diff --git a/Plan/test/main/java/com/djrapitops/plan/system/cache/SessionCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/system/cache/SessionCacheTest.java new file mode 100644 index 0000000000..8138c82974 --- /dev/null +++ b/Plan/test/main/java/com/djrapitops/plan/system/cache/SessionCacheTest.java @@ -0,0 +1,44 @@ +package com.djrapitops.plan.system.cache; + +import com.djrapitops.plan.data.container.Session; +import org.bukkit.plugin.java.JavaPlugin; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import test.utilities.MockUtils; +import test.utilities.TestInit; + +import java.util.Optional; +import java.util.UUID; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(JavaPlugin.class) +public class SessionCacheTest { + + private final UUID uuid = MockUtils.getPlayerUUID(); + private SessionCache sessionCache; + private Session session; + + @Before + public void setUp() throws Exception { + TestInit t = TestInit.init(); + sessionCache = new SessionCache(null); + session = new Session(12345L, "World1", "SURVIVAL"); + sessionCache.cacheSession(uuid, session); + } + + @Test + @Ignore("Ignored, Requires more mocks") + public void testAtomity() { + SessionCache reloaded = new SessionCache(null); + Optional cachedSession = reloaded.getCachedSession(uuid); + assertTrue(cachedSession.isPresent()); + assertEquals(session, cachedSession.get()); + } +} \ No newline at end of file From 31ff342dcc4667fa9fce1200ae05b7ea15a7f520 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 17 Jan 2018 13:14:39 +0200 Subject: [PATCH 024/166] Moved ServerInfo to new packaage --- .../main/java/com/djrapitops/plan/Plan.java | 2 +- .../java/com/djrapitops/plan/PlanBungee.java | 2 +- .../plan/command/commands/AnalyzeCommand.java | 2 +- .../djrapitops/plan/system/PlanSystem.java | 2 +- .../databases/sql/tables/ServerTable.java | 2 +- .../databases/sql/tables/TPSTable.java | 2 +- .../sql/tables/move/BatchOperationTable.java | 2 +- .../system/info/connection/ConnectionIn.java | 21 +++++++++++++++++++ .../info/connection/ConnectionSystem.java | 2 +- .../info/server/BukkitServerInfoManager.java | 3 +-- .../info/server/BungeeServerInfoManager.java | 3 +-- .../info/server/ServerInfo.java | 2 +- .../info/server/ServerInfoFile.java | 2 +- .../response/pages/DebugPageResponse.java | 4 ++-- .../bungee/RequestPluginsTabWebAPI.java | 2 +- .../webapi/bungee/RequestSetupWebAPI.java | 2 +- .../info/BungeeInformationManager.java | 4 ++-- .../InspectPluginsTabContentCreator.java | 2 +- .../plan/system/database/DatabaseTest.java | 2 +- .../plan/utilities/MiscUtilsTest.java | 2 +- .../main/java/test/utilities/TestInit.java | 2 +- 21 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/info/server/BukkitServerInfoManager.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/info/server/BungeeServerInfoManager.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/info/server/ServerInfo.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/info/server/ServerInfoFile.java (97%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index b7ad942ae0..84e5682262 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -42,7 +42,7 @@ 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.systems.info.server.BukkitServerInfoManager; +import com.djrapitops.plan.system.info.server.BukkitServerInfoManager; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 47d22eede5..b27cf87a71 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -21,7 +21,7 @@ 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.systems.info.server.BungeeServerInfoManager; +import com.djrapitops.plan.system.info.server.BungeeServerInfoManager; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 10d9f28aa5..14d611ef7a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 201e9395f4..097fde3273 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -15,7 +15,7 @@ import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Check; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java index a69462922d..13da89af47 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; import com.djrapitops.plan.system.database.databases.sql.statements.*; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java index 0f3534c714..761ac358f7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Select; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java index b065808cec..51b1fca974 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; import com.djrapitops.plan.system.database.databases.sql.tables.Table; import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java new file mode 100644 index 0000000000..f3fc58bb52 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java @@ -0,0 +1,21 @@ +package com.djrapitops.plan.system.info.connection; + +import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.Map; + +public class ConnectionIn { + + private final Map variables; + private final InfoRequest infoRequest; + + public ConnectionIn(Map variables, InfoRequest infoRequest) { + this.variables = variables; + this.infoRequest = infoRequest; + } + + public Response handleRequest() { + return infoRequest.handleRequest(variables); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 783a530682..3de439d9b0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.request.CacheInspectPageRequest; import com.djrapitops.plan.system.info.request.InfoRequest; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.NullCheck; import java.util.HashMap; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfoManager.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java rename to Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfoManager.java index 10773aa2c6..158d5f4c9c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BukkitServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfoManager.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.systems.info.server; +package com.djrapitops.plan.system.info.server; import com.djrapitops.plan.Plan; @@ -25,7 +25,6 @@ * * @author Rsl1122 */ -@Deprecated public class BukkitServerInfoManager { private final Plan plugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfoManager.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java rename to Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfoManager.java index c5b00aead9..8721cedcee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfoManager.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.systems.info.server; +package com.djrapitops.plan.system.info.server; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.ServerVariableHolder; @@ -26,7 +26,6 @@ * * @author Rsl1122 */ -@Deprecated public class BungeeServerInfoManager { private final PlanBungee plugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfo.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java rename to Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfo.java index 5f5ea247b3..cc103e77a4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfo.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.systems.info.server; +package com.djrapitops.plan.system.info.server; import java.util.Objects; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoFile.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoFile.java rename to Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java index 4af0227913..2a1ad5d5c9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoFile.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.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.systems.info.server; +package com.djrapitops.plan.system.info.server; import com.djrapitops.plan.Plan; import com.djrapitops.plan.utilities.file.FileUtil; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 0699a8b164..1033ef419c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -10,8 +10,8 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; -import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.BungeeServerInfoManager; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.Benchmark; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index 7185e2a652..4f10902060 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -11,7 +11,7 @@ import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index ed286edeef..a61327ec1e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -12,7 +12,7 @@ import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; 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 index 0ec4b244bc..92c08e1711 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -26,8 +26,8 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI; import com.djrapitops.plan.systems.info.parsing.NetworkPage; -import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.BungeeServerInfoManager; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plugin.api.utility.log.ErrorLogger; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java index 83e9c85861..f32cba8bef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; +import com.djrapitops.plan.system.info.server.BukkitServerInfoManager; import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator; import java.util.ArrayList; diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index a6cc6d1193..b7a6b3febc 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -20,7 +20,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index 7f565b9423..2573071901 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; -import com.djrapitops.plan.systems.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.bukkit.BukkitCMDSender; diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index 4ae15a3686..9bda23bdbc 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -5,7 +5,7 @@ import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; +import com.djrapitops.plan.system.info.server.BukkitServerInfoManager; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.StaticHolder; From 1b8ccff2f8879108bf69d4a3233119ec34a0ac90 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 17 Jan 2018 18:09:26 +0200 Subject: [PATCH 025/166] InfoRequestWithVariables, GenerateInspectPage, GenerateAnalysisPage --- .../connection/BadRequestException.java | 17 ++++++ ...Exception.java => ForbiddenException.java} | 4 +- ...ption.java => InternalErrorException.java} | 4 +- ...dException.java => NotFoundException.java} | 4 +- ....java => UnauthorizedServerException.java} | 10 ++-- .../UnsupportedTransferDatabaseException.java | 9 ++- .../commands/manage/ManageSetupCommand.java | 4 +- .../operation/TransferOperations.java | 8 +++ .../plan/system/info/InfoSystem.java | 46 +++++++++++++-- .../system/info/connection/ConnectionOut.java | 23 ++++++-- .../info/connection/ConnectionSystem.java | 5 +- .../info/request/CacheInspectPageRequest.java | 22 ++++++- .../request/GenerateAnalysisPageRequest.java | 32 ++++++++++ .../request/GenerateInspectPageRequest.java | 45 ++++++++++++++ .../plan/system/info/request/InfoRequest.java | 2 +- .../request/InfoRequestWithVariables.java | 28 +++++++++ .../system/webserver/ResponseHandler.java | 4 +- .../system/webserver/WebServerSystem.java | 2 +- .../webserver/pages/DefaultResponses.java | 4 +- .../webserver/pages/PlayerPageHandler.java | 4 +- .../webserver/pages/PlayersPageHandler.java | 4 +- .../webserver/pages/ServerPageHandler.java | 4 +- .../{pagecache => response/cache}/PageId.java | 6 +- .../cache}/PageLoader.java | 2 +- .../cache}/ResponseCache.java | 2 +- .../response/pages/InspectPageResponse.java | 25 ++++---- .../parts/InspectPagePluginsContent.java | 59 +++++++++++++++++++ .../plan/system/webserver/webapi/WebAPI.java | 10 ++-- .../webapi/bungee/IsCachedWebAPI.java | 6 +- .../webapi/bungee/PostHtmlWebAPI.java | 4 +- .../info/BukkitInformationManager.java | 8 +-- .../info/BungeeInformationManager.java | 10 ++-- .../plan/systems/info/InformationManager.java | 4 +- .../utilities/file/export/SpecificExport.java | 4 +- .../plan/data/cache/ResponseCacheTest.java | 4 +- 35 files changed, 344 insertions(+), 85 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/BadRequestException.java rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/{WebForbiddenException.java => ForbiddenException.java} (75%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/{WebInternalErrorException.java => InternalErrorException.java} (77%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/{WebNotFoundException.java => NotFoundException.java} (78%) rename Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/{WebUnauthorizedServerException.java => UnauthorizedServerException.java} (58%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequestWithVariables.java rename Plan/src/main/java/com/djrapitops/plan/system/webserver/{pagecache => response/cache}/PageId.java (86%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/{pagecache => response/cache}/PageLoader.java (80%) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/{pagecache => response/cache}/ResponseCache.java (98%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/BadRequestException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/BadRequestException.java new file mode 100644 index 0000000000..858734d0d3 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/BadRequestException.java @@ -0,0 +1,17 @@ +/* + * 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.exceptions.connection; + +/** + * Thrown when connection is returned 401 Bad Request. + * + * @author Rsl1122 + */ +public class BadRequestException extends WebException { + + public BadRequestException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebForbiddenException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/ForbiddenException.java similarity index 75% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebForbiddenException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/ForbiddenException.java index b289f8deb3..1e06b58448 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebForbiddenException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/ForbiddenException.java @@ -9,8 +9,8 @@ * * @author Rsl1122 */ -public class WebForbiddenException extends WebFailException { - public WebForbiddenException(String url) { +public class ForbiddenException extends WebFailException { + public ForbiddenException(String url) { super("Forbidden: " + url); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebInternalErrorException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/InternalErrorException.java similarity index 77% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebInternalErrorException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/InternalErrorException.java index f1aeb1a031..a0bbccf4a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebInternalErrorException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/InternalErrorException.java @@ -9,8 +9,8 @@ * * @author Rsl1122 */ -public class WebInternalErrorException extends WebFailException { - public WebInternalErrorException() { +public class InternalErrorException extends WebFailException { + public InternalErrorException() { super("Internal Error occurred on receiving server"); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebNotFoundException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NotFoundException.java similarity index 78% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebNotFoundException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NotFoundException.java index 61b428fd26..2f73fdd48f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebNotFoundException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NotFoundException.java @@ -9,8 +9,8 @@ * * @author Rsl1122 */ -public class WebNotFoundException extends WebFailException { - public WebNotFoundException() { +public class NotFoundException extends WebFailException { + public NotFoundException() { super("Not Found"); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebUnauthorizedServerException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnauthorizedServerException.java similarity index 58% rename from Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebUnauthorizedServerException.java rename to Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnauthorizedServerException.java index 05d706be7b..4bd725a46b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/WebUnauthorizedServerException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnauthorizedServerException.java @@ -9,20 +9,20 @@ * * @author Rsl1122 */ -public class WebUnauthorizedServerException extends WebFailException { +public class UnauthorizedServerException extends WebFailException { - public WebUnauthorizedServerException() { + public UnauthorizedServerException() { } - public WebUnauthorizedServerException(String message) { + public UnauthorizedServerException(String message) { super(message); } - public WebUnauthorizedServerException(String message, Throwable cause) { + public UnauthorizedServerException(String message, Throwable cause) { super(message, cause); } - public WebUnauthorizedServerException(Throwable cause) { + public UnauthorizedServerException(Throwable cause) { super(cause); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java index 2b29b5adca..ef66b6d896 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java @@ -4,6 +4,8 @@ */ package com.djrapitops.plan.api.exceptions.connection; +import com.djrapitops.plan.system.database.databases.Database; + /** * //TODO Class Javadoc Comment * @@ -11,10 +13,7 @@ */ public class UnsupportedTransferDatabaseException extends WebException { - public UnsupportedTransferDatabaseException() { - } - - public UnsupportedTransferDatabaseException(String message) { - super(message); + public UnsupportedTransferDatabaseException(Database db) { + super(db.getName() + " does not support Transfer operations!"); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 661fcf4a53..e643f326d3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.connection.ForbiddenException; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.api.exceptions.connection.WebForbiddenException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; @@ -71,7 +71,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { // plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class).sendRequest(address); plugin.getWebServer().getWebAPI().getAPI(RequestSetupWebAPI.class).sendRequest(address); sender.sendMessage("§eConnection successful, Plan may restart in a few seconds, if it doesn't something has gone wrong."); - } catch (WebForbiddenException e) { + } catch (ForbiddenException e) { sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it."); } catch (WebException e) { Log.toLog(this.getClass().getName(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index 44ca4c8fa4..3d7ed1d0ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; +import java.util.Map; import java.util.UUID; /** @@ -14,5 +15,12 @@ * @author Rsl1122 */ public interface TransferOperations { + + // Save + void playerHtml(UUID player, String html) throws DBException; + + // Get + + Map getPlayerHtml() throws DBException; } \ No newline at end of file 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 0e94a805cf..3d636744d8 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 @@ -4,13 +4,23 @@ */ package com.djrapitops.plan.system.info; +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem; +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 java.util.UUID; + /** - * //TODO Class Javadoc Comment + * Information management system. + * + * Subclasses should decide how InfoRequests are run locally if necessary. * * @author Rsl1122 */ @@ -18,7 +28,7 @@ public abstract class InfoSystem implements SubSystem { protected final ConnectionSystem connectionSystem; - public InfoSystem(ConnectionSystem connectionSystem) { + protected InfoSystem(ConnectionSystem connectionSystem) { this.connectionSystem = connectionSystem; } @@ -28,14 +38,40 @@ public static InfoSystem getInstance() { return infoSystem; } - @Override - public void enable() { + public void generatePlayerPage(UUID player) throws WebException { + sendRequest(new GenerateInspectPageRequest(player)); + } + public void generateAnalysisPageOfThisServer() throws WebException { + generateAnalysisPage(Plan.getServerUUID()); } + public void generateAnalysisPage(UUID serverUUID) throws WebException { + GenerateAnalysisPageRequest request = new GenerateAnalysisPageRequest(serverUUID); + if (Plan.getServerUUID().equals(serverUUID)) { + runLocally(request); + } else { + sendRequest(request); + } + } + + public void sendRequest(InfoRequest infoRequest) throws WebException { + if (!connectionSystem.isServerAvailable()) { + runLocally(infoRequest); + } + connectionSystem.sendInfoRequest(infoRequest); + } + + protected abstract void runLocally(InfoRequest infoRequest); + @Override - public void disable() { + public void enable() throws EnableException { + connectionSystem.enable(); + } + @Override + public void disable() { + connectionSystem.disable(); } public ConnectionSystem getConnectionSystem() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index ed37159d88..92547313aa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.info.request.InfoRequestWithVariables; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -18,6 +19,7 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; +import java.util.Map; import java.util.UUID; /** @@ -117,13 +119,13 @@ public void sendRequest() throws WebException { case 400: throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters); case 403: - throw new WebForbiddenException(url.toString()); + throw new ForbiddenException(url.toString()); case 404: - throw new WebNotFoundException(); + throw new NotFoundException(); case 412: - throw new WebUnauthorizedServerException(); + throw new UnauthorizedServerException(); case 500: - throw new WebInternalErrorException(); + throw new InternalErrorException(); default: throw new WebException(url.toString() + "| Wrong response code " + responseCode); } @@ -138,8 +140,17 @@ public void sendRequest() throws WebException { } private String parseVariables() { - return "sender=" + serverUUID + ";&variable;" + - "type=" + infoRequest.getClass().getSimpleName(); + StringBuilder parameters = new StringBuilder("sender=" + serverUUID + ";&variable;" + + "type=" + infoRequest.getClass().getSimpleName()); + + if (infoRequest instanceof InfoRequestWithVariables) { + Map variables = ((InfoRequestWithVariables) infoRequest).getVariables(); + for (Map.Entry entry : variables.entrySet()) { + parameters.append(";&variable;").append(entry.getKey()).append("=").append(entry.getValue()); + } + } + + return parameters.toString(); } private SSLSocketFactory getRelaxedSocketFactory() throws NoSuchAlgorithmException, KeyManagementException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 783a530682..34106ab82c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.request.CacheInspectPageRequest; import com.djrapitops.plan.system.info.request.InfoRequest; @@ -23,7 +24,7 @@ * * @author Rsl1122 */ -public abstract class ConnectionSystem { +public abstract class ConnectionSystem implements SubSystem { protected final Map dataRequests; protected final UUID serverUUID; @@ -60,4 +61,6 @@ public void sendInfoRequest(InfoRequest infoRequest) throws WebException { new ConnectionOut(address, serverUUID, infoRequest).sendRequest(); } + + public abstract boolean isServerAvailable(); } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index ae79b55b3b..fba44f50d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -8,7 +8,11 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.webserver.pages.DefaultResponses; 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.InspectPageResponse; import com.djrapitops.plan.utilities.Base64Util; import com.djrapitops.plugin.utilities.Verify; @@ -52,7 +56,21 @@ public void placeDataToDatabase() throws WebException { } @Override - public Response handleRequest(Map variables) { - return null; + public Response handleRequest(Map variables) throws WebException { + // Available variables: sender + + try { + Map pages = Database.getActive().transfer().getPlayerHtml(); + + for (Map.Entry entry : pages.entrySet()) { + UUID uuid = entry.getKey(); + String html = Base64Util.decode(entry.getValue()); + + ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(uuid, html)); + } + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + return DefaultResponses.SUCCESS.get(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java new file mode 100644 index 0000000000..a54c6d6b3a --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -0,0 +1,32 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.Map; +import java.util.UUID; + +/** + * InfoRequest to generate Analysis page HTML at the receiving end. + * + * @author Rsl1122 + */ +public class GenerateAnalysisPageRequest extends InfoRequestWithVariables { + + public GenerateAnalysisPageRequest(UUID serverUUID) { + variables.put("server", serverUUID.toString()); + } + + @Override + public void placeDataToDatabase() { + } + + @Override + public Response handleRequest(Map variables) { + + return null; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java new file mode 100644 index 0000000000..05d2eebf55 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -0,0 +1,45 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.utilities.NullCheck; + +import java.util.Map; +import java.util.UUID; + +/** + * InfoRequest for Generating Inspect page on receiving WebServer. + * + * @author Rsl1122 + */ +public class GenerateInspectPageRequest extends InfoRequestWithVariables { + + public GenerateInspectPageRequest(UUID uuid) { + variables.put("player", uuid.toString()); + } + + @Override + public void placeDataToDatabase() { + } + + @Override + public Response handleRequest(Map variables) throws WebException { + // Available variables: sender, player + + String player = variables.get("player"); + NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied.")); + UUID uuid = UUID.fromString(player); + + // TODO Generate HTML + + // TODO InfoSystem.getInstance().sendRequest(new CacheInspectPageRequest(uuid, html)); + + return DefaultResponses.SUCCESS.get(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java index 9f9e7b9a0e..0e032d4418 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java @@ -18,6 +18,6 @@ public interface InfoRequest { void placeDataToDatabase() throws WebException; - Response handleRequest(Map variables); + Response handleRequest(Map variables) throws WebException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequestWithVariables.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequestWithVariables.java new file mode 100644 index 0000000000..752ce90922 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequestWithVariables.java @@ -0,0 +1,28 @@ +/* + * 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.info.request; + +import java.util.HashMap; +import java.util.Map; + +/** + * Abstract InfoRequest that contains variables in request body. + *

+ * Used to send request differently. + * + * @author Rsl1122 + */ +public abstract class InfoRequestWithVariables implements InfoRequest { + + protected final Map variables; + + public InfoRequestWithVariables() { + this.variables = new HashMap<>(); + } + + public Map getVariables() { + return variables; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 6b92e9f13a..406b5d6f9a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -6,10 +6,10 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.system.webserver.auth.Authentication; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.pages.*; import com.djrapitops.plan.system.webserver.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.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java index 6e7d72e3c0..fd781cd844 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; import com.djrapitops.plugin.api.Check; /** diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java index 4d3a3e31d2..672447925f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.system.webserver.response.PromptAuthorizationResponse; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.api.SuccessResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; /** @@ -19,7 +20,8 @@ public enum DefaultResponses { + "

/player/PlayerName
" + "/server/ServerName

") ), - BASIC_AUTH(PromptAuthorizationResponse.getBasicAuthResponse()); + BASIC_AUTH(PromptAuthorizationResponse.getBasicAuthResponse()), + SUCCESS(new SuccessResponse()); private final Response response; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java index 2c41f40848..cb2e5b28fc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java @@ -12,9 +12,9 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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.errors.InternalErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java index 14ed1809f7..34ad7a2484 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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.PlayersPageResponse; import java.util.List; 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 e8218710ad..5c3b5ed2f7 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 @@ -9,9 +9,9 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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 java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java similarity index 86% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java index 700b458db7..a2ea23ad2c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageId.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.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.webserver.pagecache; +package com.djrapitops.plan.system.webserver.response.cache; import java.util.UUID; @@ -27,7 +27,9 @@ public enum PageId { CSS("css:"), // FAVICON_REDIRECT("Redirect:Favicon"), - AUTH_PROMPT("PromptAuth"); + AUTH_PROMPT("PromptAuth"), + // + PLAYER_PLUGINS_TAB("playerPluginsTab:"); private final String id; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageLoader.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageLoader.java similarity index 80% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageLoader.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageLoader.java index 4c60ce917b..2ececae8d6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/PageLoader.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageLoader.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.webserver.pagecache; +package com.djrapitops.plan.system.webserver.response.cache; import com.djrapitops.plan.system.webserver.response.Response; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java index 887fa3b3ae..d8fe8b9273 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pagecache/ResponseCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.webserver.pagecache; +package com.djrapitops.plan.system.webserver.response.cache; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java index eebc71d94f..ddaa591b18 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java @@ -1,9 +1,10 @@ package com.djrapitops.plan.system.webserver.response.pages; -import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.systems.info.InformationManager; +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.parts.InspectPagePluginsContent; import org.apache.commons.lang3.text.StrSubstitutor; import java.util.HashMap; @@ -17,19 +18,14 @@ public class InspectPageResponse extends Response { private final UUID uuid; + private InspectPagePluginsContent pluginsTab; - public InspectPageResponse(InformationManager infoManager, UUID uuid) throws ParseException { - this.uuid = uuid; - super.setHeader("HTTP/1.1 200 OK"); - super.setContent(infoManager.getPlayerHtml(uuid)); - setInspectPagePluginsTab(infoManager.getPluginsTabContent(uuid)); - } - - public InspectPageResponse(InformationManager infoManager, UUID uuid, String html) { + public InspectPageResponse(UUID uuid, String html) { this.uuid = uuid; super.setHeader("HTTP/1.1 200 OK"); super.setContent(Theme.replaceColors(html)); - setInspectPagePluginsTab(infoManager.getPluginsTabContent(uuid)); + pluginsTab = (InspectPagePluginsContent) + ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), InspectPagePluginsContent::new); } private InspectPageResponse(InspectPageResponse response) { @@ -42,11 +38,14 @@ public static InspectPageResponse copyOf(InspectPageResponse response) { return new InspectPageResponse(response); } - public void setInspectPagePluginsTab(String[] inspectPagePluginsTab) { + @Override + public String getContent() { Map replaceMap = new HashMap<>(); + String[] inspectPagePluginsTab = pluginsTab.getContents(); replaceMap.put("navPluginsTabs", inspectPagePluginsTab[0]); replaceMap.put("pluginsTabs", inspectPagePluginsTab[1]); - setContent(StrSubstitutor.replace(getContent(), replaceMap)); + return StrSubstitutor.replace(super.getContent(), replaceMap); } + } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java new file mode 100644 index 0000000000..691711f6a9 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java @@ -0,0 +1,59 @@ +/* + * 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.webserver.response.pages.parts; + +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.utilities.html.HtmlStructure; + +import java.util.*; + +/** + * Represents Plugins tabs on Inspect page. + *

+ * Extends Response so that it can be stored in ResponseCache. + * + * @author Rsl1122 + */ +public class InspectPagePluginsContent extends Response { + + // ServerUUID, {nav, html} + private final Map pluginsTab; + + public InspectPagePluginsContent() { + pluginsTab = new HashMap<>(); + } + + public InspectPagePluginsContent(UUID serverUUID, String nav, String html) { + pluginsTab = new HashMap<>(); + + addTab(serverUUID, nav, html); + } + + public void addTab(UUID serverUUID, String nav, String html) { + pluginsTab.put(serverUUID, new String[]{nav, html}); + } + + public void addTab(InspectPagePluginsContent content) { + pluginsTab.putAll(content.pluginsTab); + } + + public String[] getContents() { + if (pluginsTab.isEmpty()) { + return HtmlStructure.createInspectPageTabContentCalculating(); + } + + List order = new ArrayList<>(pluginsTab.values()); + // Sort serverNames alphabetically + order.sort(Comparator.comparing(name -> name[0])); + + StringBuilder nav = new StringBuilder(); + StringBuilder tabs = new StringBuilder(); + for (String[] tab : order) { + nav.append(tab[0]); + tabs.append(tab[1]); + } + return new String[]{nav.toString(), tabs.toString()}; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index 22fdd0f88a..8ad5657ace 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -7,11 +7,11 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.system.webserver.response.api.SuccessResponse; +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.NotFoundResponse; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -141,11 +141,11 @@ public void sendRequest(String address) throws WebException { case 400: throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters); case 403: - throw new WebForbiddenException(url.toString()); + throw new ForbiddenException(url.toString()); case 404: - throw new WebNotFoundException(); + throw new NotFoundException(); case 500: - throw new WebInternalErrorException(); + throw new InternalErrorException(); default: throw new WebException(url.toString() + "| Wrong response code " + responseCode); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java index fe64a38646..1bbb2afa03 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.system.webserver.webapi.bungee; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.connection.NotFoundException; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.api.exceptions.connection.WebNotFoundException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.systems.info.InformationManager; @@ -62,7 +62,7 @@ public boolean isInspectCached(String address, UUID uuid) throws WebException { try { super.sendRequest(address); return true; - } catch (WebNotFoundException e) { + } catch (NotFoundException e) { return false; } } @@ -73,7 +73,7 @@ public boolean isAnalysisCached(String address, UUID serverUUID) throws WebExcep try { super.sendRequest(address); return true; - } catch (WebNotFoundException e) { + } catch (NotFoundException e) { return false; } } 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 5d1bccad23..9d92bd9e8c 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 @@ -7,9 +7,9 @@ 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.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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; 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 index 9136525c3e..c893665242 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -7,9 +7,9 @@ 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.api.exceptions.connection.WebNotFoundException; import com.djrapitops.plan.command.commands.AnalyzeCommand; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.data.element.InspectContainer; @@ -21,9 +21,9 @@ 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.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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.errors.ErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; @@ -346,7 +346,7 @@ public boolean attemptConnection() { return true; } catch (ConnectionFailException e) { plugin.getServerInfoManager().markConnectionFail(); - } catch (WebNotFoundException e) { + } 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); 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 index 0ec4b244bc..1d64fd9775 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -8,13 +8,13 @@ import com.djrapitops.plan.PlanPlugin; 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.WebNotFoundException; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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.errors.InternalErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; @@ -183,7 +183,7 @@ private ServerInfo getInspectRequestProcessorServer(UUID uuid) { return server; } catch (ConnectionFailException e) { serverInfoManager.serverHasGoneOffline(server.getUuid()); - } catch (WebNotFoundException ignored) { + } catch (NotFoundException ignored) { /*continue*/ } catch (WebException e) { Log.toLog(this.getClass().getName(), e); @@ -291,7 +291,7 @@ public String[] getPluginsTabContent(UUID uuid) { order.sort(new Comparator() { @Override public int compare(String[] o1, String[] o2) { - return o1[0].compareTo(o2[1]); + return o1[0].compareTo(o2[0]); } }); 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 index fc89153908..0201cb2a16 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -7,8 +7,8 @@ import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; +import com.djrapitops.plan.system.webserver.response.cache.PageId; +import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; import com.djrapitops.plugin.command.ISender; import java.io.IOException; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index 3042ba55ca..6076f990f8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -6,9 +6,9 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pagecache.PageId; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; 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.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java index 73ce5d6ced..8a418248b2 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.data.cache; -import com.djrapitops.plan.system.webserver.pagecache.ResponseCache; -import com.djrapitops.plan.system.webserver.pagecache.PageLoader; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.cache.PageLoader; +import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; import org.junit.Test; import test.utilities.RandomData; From 980c11f287d295a2caaca30e4d38657eee2b469d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 17 Jan 2018 18:10:36 +0200 Subject: [PATCH 026/166] throws to ConnectionIn --- .../djrapitops/plan/system/info/connection/ConnectionIn.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java index f3fc58bb52..2b7b942bf8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java @@ -1,5 +1,6 @@ package com.djrapitops.plan.system.info.connection; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.request.InfoRequest; import com.djrapitops.plan.system.webserver.response.Response; @@ -15,7 +16,7 @@ public ConnectionIn(Map variables, InfoRequest infoRequest) { this.infoRequest = infoRequest; } - public Response handleRequest() { + public Response handleRequest() throws WebException { return infoRequest.handleRequest(variables); } } From 0320b2cea83e626d06c16d13cd034d46d68d33ee Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 17 Jan 2018 21:37:17 +0200 Subject: [PATCH 027/166] Removed TODOs from code that isn't maintained in this project. --- .../jquery-datatable/jquery.dataTables.js | 29 +- .../web/plugins/jquery-steps/jquery.steps.js | 2 - .../resources/web/plugins/jquery/jquery.js | 2 - .../plugins/materialize-css/js/materialize.js | 1261 +++++++++++++---- .../resources/web/plugins/momentjs/moment.js | 11 - 5 files changed, 968 insertions(+), 337 deletions(-) diff --git a/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js b/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js index 4f1d7bb4d7..2739c76808 100644 --- a/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js +++ b/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js @@ -55,7 +55,7 @@ // Browser factory( jQuery, window, document ); } -} +}; (function( $, window, document, undefined ) { "use strict"; @@ -1054,7 +1054,6 @@ var oClasses = oSettings.oClasses; - // @todo Remove in 1.11 if ( oInit.bJQueryUI ) { /* Use the JUI classes object for display. You could clone the oStdClasses object if @@ -1225,7 +1224,6 @@ /* * Sorting - * @todo For modularisation (1.11) this needs to do into a sort start up handler */ // If aaSorting is not defined, then we use the first indicator in asSorting @@ -2861,10 +2859,6 @@ * @param {int} [colIdx] Column index to invalidate. If undefined the whole * row will be invalidated * @memberof DataTable#oApi - * - * @todo For the modularisation of v1.11 this will need to become a callback, so - * the sort and filter methods can subscribe to it. That will required - * initialisation options for sorting, which is why it is not already baked in */ function _fnInvalidate( settings, rowIdx, src, colIdx ) { @@ -3582,7 +3576,6 @@ j++; } - /* Replace jQuery UI constants @todo depreciated */ if ( sAttr == "H" ) { sAttr = classes.sJUIHeader; @@ -3621,7 +3614,6 @@ /* End container div */ insert = insert.parent(); } - // @todo Move options into their own plugins? else if ( cOption == 'l' && features.bPaginate && features.bLengthChange ) { /* Length */ @@ -4258,7 +4250,6 @@ }; // Resolve any column types that are unknown due to addition or invalidation - // @todo As per sort - can this be moved into an event handler? _fnColumnTypes( oSettings ); /* In server-side processing all filtering is done by the server, so no point hanging around here */ @@ -5880,7 +5871,6 @@ * Change the order of the table * @param {object} oSettings dataTables settings object * @memberof DataTable#oApi - * @todo This really needs split up! */ function _fnSort ( oSettings ) { @@ -5898,7 +5888,6 @@ aSort; // Resolve any column types that are unknown due to addition or invalidation - // @todo Can this be moved into a 'data-ready' handler which is called when // data is going to be used in the table? _fnColumnTypes( oSettings ); @@ -6331,10 +6320,8 @@ // Store the saved state so it might be accessed at any time settings.oLoadedState = $.extend( true, {}, state ); - - // Restore key features - todo - for 1.11 this needs to be done by - // subscribed events - if ( state.start !== undefined ) { + + if ( state.start !== undefined ) { settings._iDisplayStart = state.start; settings.iInitDisplayStart = state.start; } @@ -6485,7 +6472,6 @@ * references * @returns {object} out Reference, just for convenience - out === the return. * @memberof DataTable#oApi - * @todo This doesn't take account of arrays inside the deep copied objects. */ function _fnExtend( out, extender, breakRefs ) { @@ -7164,7 +7150,6 @@ }; - // @todo - Is there need for an augment function? // _Api.augment = function ( inst, name ) // { // // Find src object in the structure from the name @@ -12866,13 +12851,6 @@ * NOT be manipulated outside of DataTables. Any configuration should be done * through the initialisation options. * @namespace - * @todo Really should attach the settings object to individual instances so we - * don't need to create new instances on each $().dataTable() call (if the - * table already exists). It would also save passing oSettings around and - * into every single function. However, this is a very significant - * architecture change for DataTables and will almost certainly break - * backwards compatibility with older installations. This is something that - * will be done in 2.0. */ DataTable.models.oSettings = { /** @@ -13195,7 +13173,6 @@ * Note that this parameter will be set by the initialisation routine. To * set a default use {@link DataTable.defaults}. * @type array - * @todo These inner arrays should really be objects */ "aaSorting": null, diff --git a/Plan/src/main/resources/web/plugins/jquery-steps/jquery.steps.js b/Plan/src/main/resources/web/plugins/jquery-steps/jquery.steps.js index 956b05a68f..3550b113cb 100644 --- a/Plan/src/main/resources/web/plugins/jquery-steps/jquery.steps.js +++ b/Plan/src/main/resources/web/plugins/jquery-steps/jquery.steps.js @@ -597,8 +597,6 @@ function insertStep(wizard, options, state, index, step) throwError(_indexOutOfRangeErrorMessage); } - // TODO: Validate step object - // Change data step = $.extend({}, stepModel, step); insertStepToCache(wizard, index, step); diff --git a/Plan/src/main/resources/web/plugins/jquery/jquery.js b/Plan/src/main/resources/web/plugins/jquery/jquery.js index 7fc60fca78..ef8683974d 100644 --- a/Plan/src/main/resources/web/plugins/jquery/jquery.js +++ b/Plan/src/main/resources/web/plugins/jquery/jquery.js @@ -807,7 +807,6 @@ function Sizzle( selector, context, results, seed ) { if ( (elem = context.getElementById( m )) ) { // Support: IE, Opera, Webkit - // TODO: identify versions // getElementById can match elements by name instead of ID if ( elem.id === m ) { results.push( elem ); @@ -821,7 +820,6 @@ function Sizzle( selector, context, results, seed ) { } else { // Support: IE, Opera, Webkit - // TODO: identify versions // getElementById can match elements by name instead of ID if ( newContext && (elem = newContext.getElementById( m )) && contains( context, elem ) && diff --git a/Plan/src/main/resources/web/plugins/materialize-css/js/materialize.js b/Plan/src/main/resources/web/plugins/materialize-css/js/materialize.js index d7d07da3be..ee2f57462c 100644 --- a/Plan/src/main/resources/web/plugins/materialize-css/js/materialize.js +++ b/Plan/src/main/resources/web/plugins/materialize-css/js/materialize.js @@ -14,7 +14,7 @@ if (typeof(jQuery) === 'undefined') { jQuery = $; } } -;/* +/* * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ * * Uses the built in easing capabilities added In jQuery 1.1 @@ -218,8 +218,8 @@ jQuery.extend( jQuery.easing, * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * - */; // Custom Easing - jQuery.extend( jQuery.easing, + */ // Custom Easing +jQuery.extend(jQuery.easing, { easeInOutMaterial: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; @@ -227,12 +227,683 @@ jQuery.extend( jQuery.easing, } }); -;/*! VelocityJS.org (1.2.3). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */ +/*! VelocityJS.org (1.2.3). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */ /*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */ /*! Note that this has been modified by Materialize to confirm that Velocity is not already being imported. */ jQuery.Velocity?console.log("Velocity is already loaded. You may be needlessly importing Velocity again; note that Materialize includes Velocity."):(!function(e){function t(e){var t=e.length,a=r.type(e);return"function"===a||r.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===a||0===t||"number"==typeof t&&t>0&&t-1 in e}if(!e.jQuery){var r=function(e,t){return new r.fn.init(e,t)};r.isWindow=function(e){return null!=e&&e==e.window},r.type=function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e},r.isArray=Array.isArray||function(e){return"array"===r.type(e)},r.isPlainObject=function(e){var t;if(!e||"object"!==r.type(e)||e.nodeType||r.isWindow(e))return!1;try{if(e.constructor&&!o.call(e,"constructor")&&!o.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(a){return!1}for(t in e);return void 0===t||o.call(e,t)},r.each=function(e,r,a){var n,o=0,i=e.length,s=t(e);if(a){if(s)for(;i>o&&(n=r.apply(e[o],a),n!==!1);o++);else for(o in e)if(n=r.apply(e[o],a),n===!1)break}else if(s)for(;i>o&&(n=r.call(e[o],o,e[o]),n!==!1);o++);else for(o in e)if(n=r.call(e[o],o,e[o]),n===!1)break;return e},r.data=function(e,t,n){if(void 0===n){var o=e[r.expando],i=o&&a[o];if(void 0===t)return i;if(i&&t in i)return i[t]}else if(void 0!==t){var o=e[r.expando]||(e[r.expando]=++r.uuid);return a[o]=a[o]||{},a[o][t]=n,n}},r.removeData=function(e,t){var n=e[r.expando],o=n&&a[n];o&&r.each(t,function(e,t){delete o[t]})},r.extend=function(){var e,t,a,n,o,i,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[l]||{},l++),"object"!=typeof s&&"function"!==r.type(s)&&(s={}),l===u&&(s=this,l--);u>l;l++)if(null!=(o=arguments[l]))for(n in o)e=s[n],a=o[n],s!==a&&(c&&a&&(r.isPlainObject(a)||(t=r.isArray(a)))?(t?(t=!1,i=e&&r.isArray(e)?e:[]):i=e&&r.isPlainObject(e)?e:{},s[n]=r.extend(c,i,a)):void 0!==a&&(s[n]=a));return s},r.queue=function(e,a,n){function o(e,r){var a=r||[];return null!=e&&(t(Object(e))?!function(e,t){for(var r=+t.length,a=0,n=e.length;r>a;)e[n++]=t[a++];if(r!==r)for(;void 0!==t[a];)e[n++]=t[a++];return e.length=n,e}(a,"string"==typeof e?[e]:e):[].push.call(a,e)),a}if(e){a=(a||"fx")+"queue";var i=r.data(e,a);return n?(!i||r.isArray(n)?i=r.data(e,a,o(n)):i.push(n),i):i||[]}},r.dequeue=function(e,t){r.each(e.nodeType?[e]:e,function(e,a){t=t||"fx";var n=r.queue(a,t),o=n.shift();"inprogress"===o&&(o=n.shift()),o&&("fx"===t&&n.unshift("inprogress"),o.call(a,function(){r.dequeue(a,t)}))})},r.fn=r.prototype={init:function(e){if(e.nodeType)return this[0]=e,this;throw new Error("Not a DOM node.")},offset:function(){var t=this[0].getBoundingClientRect?this[0].getBoundingClientRect():{top:0,left:0};return{top:t.top+(e.pageYOffset||document.scrollTop||0)-(document.clientTop||0),left:t.left+(e.pageXOffset||document.scrollLeft||0)-(document.clientLeft||0)}},position:function(){function e(){for(var e=this.offsetParent||document;e&&"html"===!e.nodeType.toLowerCase&&"static"===e.style.position;)e=e.offsetParent;return e||document}var t=this[0],e=e.apply(t),a=this.offset(),n=/^(?:body|html)$/i.test(e.nodeName)?{top:0,left:0}:r(e).offset();return a.top-=parseFloat(t.style.marginTop)||0,a.left-=parseFloat(t.style.marginLeft)||0,e.style&&(n.top+=parseFloat(e.style.borderTopWidth)||0,n.left+=parseFloat(e.style.borderLeftWidth)||0),{top:a.top-n.top,left:a.left-n.left}}};var a={};r.expando="velocity"+(new Date).getTime(),r.uuid=0;for(var n={},o=n.hasOwnProperty,i=n.toString,s="Boolean Number String Function Array Date RegExp Object Error".split(" "),l=0;ln;++n){var o=u(r,e,a);if(0===o)return r;var i=l(r,e,a)-t;r-=i/o}return r}function p(){for(var t=0;b>t;++t)w[t]=l(t*x,e,a)}function f(t,r,n){var o,i,s=0;do i=r+(n-r)/2,o=l(i,e,a)-t,o>0?n=i:r=i;while(Math.abs(o)>h&&++s=y?c(t,s):0==l?s:f(t,r,r+x)}function g(){V=!0,(e!=r||a!=n)&&p()}var m=4,y=.001,h=1e-7,v=10,b=11,x=1/(b-1),S="Float32Array"in t;if(4!==arguments.length)return!1;for(var P=0;4>P;++P)if("number"!=typeof arguments[P]||isNaN(arguments[P])||!isFinite(arguments[P]))return!1;e=Math.min(e,1),a=Math.min(a,1),e=Math.max(e,0),a=Math.max(a,0);var w=S?new Float32Array(b):new Array(b),V=!1,C=function(t){return V||g(),e===r&&a===n?t:0===t?0:1===t?1:l(d(t),r,n)};C.getControlPoints=function(){return[{x:e,y:r},{x:a,y:n}]};var T="generateBezier("+[e,r,a,n]+")";return C.toString=function(){return T},C}function u(e,t){var r=e;return m.isString(e)?b.Easings[e]||(r=!1):r=m.isArray(e)&&1===e.length?s.apply(null,e):m.isArray(e)&&2===e.length?x.apply(null,e.concat([t])):m.isArray(e)&&4===e.length?l.apply(null,e):!1,r===!1&&(r=b.Easings[b.defaults.easing]?b.defaults.easing:v),r}function c(e){if(e){var t=(new Date).getTime(),r=b.State.calls.length;r>1e4&&(b.State.calls=n(b.State.calls));for(var o=0;r>o;o++)if(b.State.calls[o]){var s=b.State.calls[o],l=s[0],u=s[2],d=s[3],g=!!d,y=null;d||(d=b.State.calls[o][3]=t-16);for(var h=Math.min((t-d)/u.duration,1),v=0,x=l.length;x>v;v++){var P=l[v],V=P.element;if(i(V)){var C=!1;if(u.display!==a&&null!==u.display&&"none"!==u.display){if("flex"===u.display){var T=["-webkit-box","-moz-box","-ms-flexbox","-webkit-flex"];f.each(T,function(e,t){S.setPropertyValue(V,"display",t)})}S.setPropertyValue(V,"display",u.display)}u.visibility!==a&&"hidden"!==u.visibility&&S.setPropertyValue(V,"visibility",u.visibility);for(var k in P)if("element"!==k){var A,F=P[k],j=m.isString(F.easing)?b.Easings[F.easing]:F.easing;if(1===h)A=F.endValue;else{var E=F.endValue-F.startValue;if(A=F.startValue+E*j(h,u,E),!g&&A===F.currentValue)continue}if(F.currentValue=A,"tween"===k)y=A;else{if(S.Hooks.registered[k]){var H=S.Hooks.getRoot(k),N=i(V).rootPropertyValueCache[H];N&&(F.rootPropertyValue=N)}var L=S.setPropertyValue(V,k,F.currentValue+(0===parseFloat(A)?"":F.unitType),F.rootPropertyValue,F.scrollData);S.Hooks.registered[k]&&(i(V).rootPropertyValueCache[H]=S.Normalizations.registered[H]?S.Normalizations.registered[H]("extract",null,L[1]):L[1]),"transform"===L[0]&&(C=!0)}}u.mobileHA&&i(V).transformCache.translate3d===a&&(i(V).transformCache.translate3d="(0px, 0px, 0px)",C=!0),C&&S.flushTransformCache(V)}}u.display!==a&&"none"!==u.display&&(b.State.calls[o][2].display=!1),u.visibility!==a&&"hidden"!==u.visibility&&(b.State.calls[o][2].visibility=!1),u.progress&&u.progress.call(s[1],s[1],h,Math.max(0,d+u.duration-t),d,y),1===h&&p(o)}}b.State.isTicking&&w(c)}function p(e,t){if(!b.State.calls[e])return!1;for(var r=b.State.calls[e][0],n=b.State.calls[e][1],o=b.State.calls[e][2],s=b.State.calls[e][4],l=!1,u=0,c=r.length;c>u;u++){var p=r[u].element;if(t||o.loop||("none"===o.display&&S.setPropertyValue(p,"display",o.display),"hidden"===o.visibility&&S.setPropertyValue(p,"visibility",o.visibility)),o.loop!==!0&&(f.queue(p)[1]===a||!/\.velocityQueueEntryFlag/i.test(f.queue(p)[1]))&&i(p)){i(p).isAnimating=!1,i(p).rootPropertyValueCache={};var d=!1;f.each(S.Lists.transforms3D,function(e,t){var r=/^scale/.test(t)?1:0,n=i(p).transformCache[t];i(p).transformCache[t]!==a&&new RegExp("^\\("+r+"[^.]").test(n)&&(d=!0,delete i(p).transformCache[t])}),o.mobileHA&&(d=!0,delete i(p).transformCache.translate3d),d&&S.flushTransformCache(p),S.Values.removeClass(p,"velocity-animating")}if(!t&&o.complete&&!o.loop&&u===c-1)try{o.complete.call(n,n)}catch(g){setTimeout(function(){throw g},1)}s&&o.loop!==!0&&s(n),i(p)&&o.loop===!0&&!t&&(f.each(i(p).tweensContainer,function(e,t){/^rotate/.test(e)&&360===parseFloat(t.endValue)&&(t.endValue=0,t.startValue=360),/^backgroundPosition/.test(e)&&100===parseFloat(t.endValue)&&"%"===t.unitType&&(t.endValue=0,t.startValue=100)}),b(p,"reverse",{loop:!0,delay:o.delay})),o.queue!==!1&&f.dequeue(p,o.queue)}b.State.calls[e]=!1;for(var m=0,y=b.State.calls.length;y>m;m++)if(b.State.calls[m]!==!1){l=!0;break}l===!1&&(b.State.isTicking=!1,delete b.State.calls,b.State.calls=[])}var f,d=function(){if(r.documentMode)return r.documentMode;for(var e=7;e>4;e--){var t=r.createElement("div");if(t.innerHTML="",t.getElementsByTagName("span").length)return t=null,e}return a}(),g=function(){var e=0;return t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||function(t){var r,a=(new Date).getTime();return r=Math.max(0,16-(a-e)),e=a+r,setTimeout(function(){t(a+r)},r)}}(),m={isString:function(e){return"string"==typeof e},isArray:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},isFunction:function(e){return"[object Function]"===Object.prototype.toString.call(e)},isNode:function(e){return e&&e.nodeType},isNodeList:function(e){return"object"==typeof e&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&e.length!==a&&(0===e.length||"object"==typeof e[0]&&e[0].nodeType>0)},isWrapped:function(e){return e&&(e.jquery||t.Zepto&&t.Zepto.zepto.isZ(e))},isSVG:function(e){return t.SVGElement&&e instanceof t.SVGElement},isEmptyObject:function(e){for(var t in e)return!1;return!0}},y=!1;if(e.fn&&e.fn.jquery?(f=e,y=!0):f=t.Velocity.Utilities,8>=d&&!y)throw new Error("Velocity: IE8 and below require jQuery to be loaded before Velocity.");if(7>=d)return void(jQuery.fn.velocity=jQuery.fn.animate);var h=400,v="swing",b={State:{isMobile:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),isAndroid:/Android/i.test(navigator.userAgent),isGingerbread:/Android 2\.3\.[3-7]/i.test(navigator.userAgent),isChrome:t.chrome,isFirefox:/Firefox/i.test(navigator.userAgent),prefixElement:r.createElement("div"),prefixMatches:{},scrollAnchor:null,scrollPropertyLeft:null,scrollPropertyTop:null,isTicking:!1,calls:[]},CSS:{},Utilities:f,Redirects:{},Easings:{},Promise:t.Promise,defaults:{queue:"",duration:h,easing:v,begin:a,complete:a,progress:a,display:a,visibility:a,loop:!1,delay:!1,mobileHA:!0,_cacheValues:!0},init:function(e){f.data(e,"velocity",{isSVG:m.isSVG(e),isAnimating:!1,computedStyle:null,tweensContainer:null,rootPropertyValueCache:{},transformCache:{}})},hook:null,mock:!1,version:{major:1,minor:2,patch:2},debug:!1};t.pageYOffset!==a?(b.State.scrollAnchor=t,b.State.scrollPropertyLeft="pageXOffset",b.State.scrollPropertyTop="pageYOffset"):(b.State.scrollAnchor=r.documentElement||r.body.parentNode||r.body,b.State.scrollPropertyLeft="scrollLeft",b.State.scrollPropertyTop="scrollTop");var x=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,r,a){var n={x:t.x+a.dx*r,v:t.v+a.dv*r,tension:t.tension,friction:t.friction};return{dx:n.v,dv:e(n)}}function r(r,a){var n={dx:r.v,dv:e(r)},o=t(r,.5*a,n),i=t(r,.5*a,o),s=t(r,a,i),l=1/6*(n.dx+2*(o.dx+i.dx)+s.dx),u=1/6*(n.dv+2*(o.dv+i.dv)+s.dv);return r.x=r.x+l*a,r.v=r.v+u*a,r}return function a(e,t,n){var o,i,s,l={x:-1,v:0,tension:null,friction:null},u=[0],c=0,p=1e-4,f=.016;for(e=parseFloat(e)||500,t=parseFloat(t)||20,n=n||null,l.tension=e,l.friction=t,o=null!==n,o?(c=a(e,t),i=c/n*f):i=f;s=r(s||l,i),u.push(1+s.x),c+=16,Math.abs(s.x)>p&&Math.abs(s.v)>p;);return o?function(e){return u[e*(u.length-1)|0]}:c}}();b.Easings={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},spring:function(e){return 1-Math.cos(4.5*e*Math.PI)*Math.exp(6*-e)}},f.each([["ease",[.25,.1,.25,1]],["ease-in",[.42,0,1,1]],["ease-out",[0,0,.58,1]],["ease-in-out",[.42,0,.58,1]],["easeInSine",[.47,0,.745,.715]],["easeOutSine",[.39,.575,.565,1]],["easeInOutSine",[.445,.05,.55,.95]],["easeInQuad",[.55,.085,.68,.53]],["easeOutQuad",[.25,.46,.45,.94]],["easeInOutQuad",[.455,.03,.515,.955]],["easeInCubic",[.55,.055,.675,.19]],["easeOutCubic",[.215,.61,.355,1]],["easeInOutCubic",[.645,.045,.355,1]],["easeInQuart",[.895,.03,.685,.22]],["easeOutQuart",[.165,.84,.44,1]],["easeInOutQuart",[.77,0,.175,1]],["easeInQuint",[.755,.05,.855,.06]],["easeOutQuint",[.23,1,.32,1]],["easeInOutQuint",[.86,0,.07,1]],["easeInExpo",[.95,.05,.795,.035]],["easeOutExpo",[.19,1,.22,1]],["easeInOutExpo",[1,0,0,1]],["easeInCirc",[.6,.04,.98,.335]],["easeOutCirc",[.075,.82,.165,1]],["easeInOutCirc",[.785,.135,.15,.86]]],function(e,t){b.Easings[t[0]]=l.apply(null,t[1])});var S=b.CSS={RegEx:{isHex:/^#([A-f\d]{3}){1,2}$/i,valueUnwrap:/^[A-z]+\((.*)\)$/i,wrappedValueAlreadyExtracted:/[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/,valueSplit:/([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/gi},Lists:{colors:["fill","stroke","stopColor","color","backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],transformsBase:["translateX","translateY","scale","scaleX","scaleY","skewX","skewY","rotateZ"],transforms3D:["transformPerspective","translateZ","scaleZ","rotateX","rotateY"]},Hooks:{templates:{textShadow:["Color X Y Blur","black 0px 0px 0px"],boxShadow:["Color X Y Blur Spread","black 0px 0px 0px 0px"],clip:["Top Right Bottom Left","0px 0px 0px 0px"],backgroundPosition:["X Y","0% 0%"],transformOrigin:["X Y Z","50% 50% 0px"],perspectiveOrigin:["X Y","50% 50%"]},registered:{},register:function(){for(var e=0;e=d)switch(e){case"name":return"filter";case"extract":var a=r.toString().match(/alpha\(opacity=(.*)\)/i);return r=a?a[1]/100:1;case"inject":return t.style.zoom=1,parseFloat(r)>=1?"":"alpha(opacity="+parseInt(100*parseFloat(r),10)+")"}else switch(e){case"name":return"opacity";case"extract":return r;case"inject":return r}}},register:function(){9>=d||b.State.isGingerbread||(S.Lists.transformsBase=S.Lists.transformsBase.concat(S.Lists.transforms3D));for(var e=0;en&&(n=1),o=!/(\d)$/i.test(n);break;case"skew":o=!/(deg|\d)$/i.test(n);break;case"rotate":o=!/(deg|\d)$/i.test(n)}return o||(i(r).transformCache[t]="("+n+")"),i(r).transformCache[t]}}}();for(var e=0;e=d||3!==o.split(" ").length||(o+=" 1"),o;case"inject":return 8>=d?4===n.split(" ").length&&(n=n.split(/\s+/).slice(0,3).join(" ")):3===n.split(" ").length&&(n+=" 1"),(8>=d?"rgb":"rgba")+"("+n.replace(/\s+/g,",").replace(/\.(\d)+(?=,)/g,"")+")"}}}()}},Names:{camelCase:function(e){return e.replace(/-(\w)/g,function(e,t){return t.toUpperCase()})},SVGAttribute:function(e){var t="width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2";return(d||b.State.isAndroid&&!b.State.isChrome)&&(t+="|transform"),new RegExp("^("+t+")$","i").test(e)},prefixCheck:function(e){if(b.State.prefixMatches[e])return[b.State.prefixMatches[e],!0];for(var t=["","Webkit","Moz","ms","O"],r=0,a=t.length;a>r;r++){var n;if(n=0===r?e:t[r]+e.replace(/^\w/,function(e){return e.toUpperCase()}),m.isString(b.State.prefixElement.style[n]))return b.State.prefixMatches[e]=n,[n,!0]}return[e,!1]}},Values:{hexToRgb:function(e){var t,r=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;return e=e.replace(r,function(e,t,r,a){return t+t+r+r+a+a}),t=a.exec(e),t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[0,0,0]},isCSSNullValue:function(e){return 0==e||/^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(e)},getUnitType:function(e){return/^(rotate|skew)/i.test(e)?"deg":/(^(scale|scaleX|scaleY|scaleZ|alpha|flexGrow|flexHeight|zIndex|fontWeight)$)|((opacity|red|green|blue|alpha)$)/i.test(e)?"":"px"},getDisplayType:function(e){var t=e&&e.tagName.toString().toLowerCase();return/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i.test(t)?"inline":/^(li)$/i.test(t)?"list-item":/^(tr)$/i.test(t)?"table-row":/^(table)$/i.test(t)?"table":/^(tbody)$/i.test(t)?"table-row-group":"block"},addClass:function(e,t){e.classList?e.classList.add(t):e.className+=(e.className.length?" ":"")+t},removeClass:function(e,t){e.classList?e.classList.remove(t):e.className=e.className.toString().replace(new RegExp("(^|\\s)"+t.split(" ").join("|")+"(\\s|$)","gi")," ")}},getPropertyValue:function(e,r,n,o){function s(e,r){function n(){u&&S.setPropertyValue(e,"display","none")}var l=0;if(8>=d)l=f.css(e,r);else{var u=!1;if(/^(width|height)$/.test(r)&&0===S.getPropertyValue(e,"display")&&(u=!0,S.setPropertyValue(e,"display",S.Values.getDisplayType(e))),!o){if("height"===r&&"border-box"!==S.getPropertyValue(e,"boxSizing").toString().toLowerCase()){var c=e.offsetHeight-(parseFloat(S.getPropertyValue(e,"borderTopWidth"))||0)-(parseFloat(S.getPropertyValue(e,"borderBottomWidth"))||0)-(parseFloat(S.getPropertyValue(e,"paddingTop"))||0)-(parseFloat(S.getPropertyValue(e,"paddingBottom"))||0);return n(),c}if("width"===r&&"border-box"!==S.getPropertyValue(e,"boxSizing").toString().toLowerCase()){var p=e.offsetWidth-(parseFloat(S.getPropertyValue(e,"borderLeftWidth"))||0)-(parseFloat(S.getPropertyValue(e,"borderRightWidth"))||0)-(parseFloat(S.getPropertyValue(e,"paddingLeft"))||0)-(parseFloat(S.getPropertyValue(e,"paddingRight"))||0);return n(),p}}var g;g=i(e)===a?t.getComputedStyle(e,null):i(e).computedStyle?i(e).computedStyle:i(e).computedStyle=t.getComputedStyle(e,null),"borderColor"===r&&(r="borderTopColor"),l=9===d&&"filter"===r?g.getPropertyValue(r):g[r],(""===l||null===l)&&(l=e.style[r]),n()}if("auto"===l&&/^(top|right|bottom|left)$/i.test(r)){var m=s(e,"position");("fixed"===m||"absolute"===m&&/top|left/i.test(r))&&(l=f(e).position()[r]+"px")}return l}var l;if(S.Hooks.registered[r]){var u=r,c=S.Hooks.getRoot(u);n===a&&(n=S.getPropertyValue(e,S.Names.prefixCheck(c)[0])),S.Normalizations.registered[c]&&(n=S.Normalizations.registered[c]("extract",e,n)),l=S.Hooks.extractValue(u,n)}else if(S.Normalizations.registered[r]){var p,g;p=S.Normalizations.registered[r]("name",e),"transform"!==p&&(g=s(e,S.Names.prefixCheck(p)[0]),S.Values.isCSSNullValue(g)&&S.Hooks.templates[r]&&(g=S.Hooks.templates[r][1])),l=S.Normalizations.registered[r]("extract",e,g)}if(!/^[\d-]/.test(l))if(i(e)&&i(e).isSVG&&S.Names.SVGAttribute(r))if(/^(height|width)$/i.test(r))try{l=e.getBBox()[r]}catch(m){l=0}else l=e.getAttribute(r);else l=s(e,S.Names.prefixCheck(r)[0]);return S.Values.isCSSNullValue(l)&&(l=0),b.debug>=2&&console.log("Get "+r+": "+l),l},setPropertyValue:function(e,r,a,n,o){var s=r;if("scroll"===r)o.container?o.container["scroll"+o.direction]=a:"Left"===o.direction?t.scrollTo(a,o.alternateValue):t.scrollTo(o.alternateValue,a);else if(S.Normalizations.registered[r]&&"transform"===S.Normalizations.registered[r]("name",e))S.Normalizations.registered[r]("inject",e,a),s="transform",a=i(e).transformCache[r];else{if(S.Hooks.registered[r]){var l=r,u=S.Hooks.getRoot(r);n=n||S.getPropertyValue(e,u),a=S.Hooks.injectValue(l,a,n),r=u}if(S.Normalizations.registered[r]&&(a=S.Normalizations.registered[r]("inject",e,a),r=S.Normalizations.registered[r]("name",e)),s=S.Names.prefixCheck(r)[0],8>=d)try{e.style[s]=a}catch(c){b.debug&&console.log("Browser does not support ["+a+"] for ["+s+"]")}else i(e)&&i(e).isSVG&&S.Names.SVGAttribute(r)?e.setAttribute(r,a):e.style[s]=a;b.debug>=2&&console.log("Set "+r+" ("+s+"): "+a)}return[s,a]},flushTransformCache:function(e){function t(t){return parseFloat(S.getPropertyValue(e,t))}var r="";if((d||b.State.isAndroid&&!b.State.isChrome)&&i(e).isSVG){var a={translate:[t("translateX"),t("translateY")],skewX:[t("skewX")],skewY:[t("skewY")],scale:1!==t("scale")?[t("scale"),t("scale")]:[t("scaleX"),t("scaleY")],rotate:[t("rotateZ"),0,0]};f.each(i(e).transformCache,function(e){/^translate/i.test(e)?e="translate":/^scale/i.test(e)?e="scale":/^rotate/i.test(e)&&(e="rotate"),a[e]&&(r+=e+"("+a[e].join(" ")+") ",delete a[e])})}else{var n,o;f.each(i(e).transformCache,function(t){return n=i(e).transformCache[t],"transformPerspective"===t?(o=n,!0):(9===d&&"rotateZ"===t&&(t="rotate"),void(r+=t+n+" "))}),o&&(r="perspective"+o+" "+r)}S.setPropertyValue(e,"transform",r)}};S.Hooks.register(),S.Normalizations.register(),b.hook=function(e,t,r){var n=a;return e=o(e),f.each(e,function(e,o){if(i(o)===a&&b.init(o),r===a)n===a&&(n=b.CSS.getPropertyValue(o,t));else{var s=b.CSS.setPropertyValue(o,t,r);"transform"===s[0]&&b.CSS.flushTransformCache(o),n=s}}),n};var P=function(){function e(){return s?k.promise||null:l}function n(){function e(e){function p(e,t){var r=a,n=a,i=a;return m.isArray(e)?(r=e[0],!m.isArray(e[1])&&/^[\d-]/.test(e[1])||m.isFunction(e[1])||S.RegEx.isHex.test(e[1])?i=e[1]:(m.isString(e[1])&&!S.RegEx.isHex.test(e[1])||m.isArray(e[1]))&&(n=t?e[1]:u(e[1],s.duration),e[2]!==a&&(i=e[2]))):r=e,t||(n=n||s.easing),m.isFunction(r)&&(r=r.call(o,V,w)),m.isFunction(i)&&(i=i.call(o,V,w)),[r||0,n,i]}function d(e,t){var r,a;return a=(t||"0").toString().toLowerCase().replace(/[%A-z]+$/,function(e){return r=e,""}),r||(r=S.Values.getUnitType(e)),[a,r]}function h(){var e={myParent:o.parentNode||r.body,position:S.getPropertyValue(o,"position"),fontSize:S.getPropertyValue(o,"fontSize")},a=e.position===L.lastPosition&&e.myParent===L.lastParent,n=e.fontSize===L.lastFontSize;L.lastParent=e.myParent,L.lastPosition=e.position,L.lastFontSize=e.fontSize;var s=100,l={};if(n&&a)l.emToPx=L.lastEmToPx,l.percentToPxWidth=L.lastPercentToPxWidth,l.percentToPxHeight=L.lastPercentToPxHeight;else{var u=i(o).isSVG?r.createElementNS("http://www.w3.org/2000/svg","rect"):r.createElement("div");b.init(u),e.myParent.appendChild(u),f.each(["overflow","overflowX","overflowY"],function(e,t){b.CSS.setPropertyValue(u,t,"hidden")}),b.CSS.setPropertyValue(u,"position",e.position),b.CSS.setPropertyValue(u,"fontSize",e.fontSize),b.CSS.setPropertyValue(u,"boxSizing","content-box"),f.each(["minWidth","maxWidth","width","minHeight","maxHeight","height"],function(e,t){b.CSS.setPropertyValue(u,t,s+"%")}),b.CSS.setPropertyValue(u,"paddingLeft",s+"em"),l.percentToPxWidth=L.lastPercentToPxWidth=(parseFloat(S.getPropertyValue(u,"width",null,!0))||1)/s,l.percentToPxHeight=L.lastPercentToPxHeight=(parseFloat(S.getPropertyValue(u,"height",null,!0))||1)/s,l.emToPx=L.lastEmToPx=(parseFloat(S.getPropertyValue(u,"paddingLeft"))||1)/s,e.myParent.removeChild(u)}return null===L.remToPx&&(L.remToPx=parseFloat(S.getPropertyValue(r.body,"fontSize"))||16),null===L.vwToPx&&(L.vwToPx=parseFloat(t.innerWidth)/100,L.vhToPx=parseFloat(t.innerHeight)/100),l.remToPx=L.remToPx,l.vwToPx=L.vwToPx,l.vhToPx=L.vhToPx,b.debug>=1&&console.log("Unit ratios: "+JSON.stringify(l),o),l}if(s.begin&&0===V)try{s.begin.call(g,g)}catch(x){setTimeout(function(){throw x},1)}if("scroll"===A){var P,C,T,F=/^x$/i.test(s.axis)?"Left":"Top",j=parseFloat(s.offset)||0;s.container?m.isWrapped(s.container)||m.isNode(s.container)?(s.container=s.container[0]||s.container,P=s.container["scroll"+F],T=P+f(o).position()[F.toLowerCase()]+j):s.container=null:(P=b.State.scrollAnchor[b.State["scrollProperty"+F]],C=b.State.scrollAnchor[b.State["scrollProperty"+("Left"===F?"Top":"Left")]],T=f(o).offset()[F.toLowerCase()]+j),l={scroll:{rootPropertyValue:!1,startValue:P,currentValue:P,endValue:T,unitType:"",easing:s.easing,scrollData:{container:s.container,direction:F,alternateValue:C}},element:o},b.debug&&console.log("tweensContainer (scroll): ",l.scroll,o)}else if("reverse"===A){if(!i(o).tweensContainer)return void f.dequeue(o,s.queue);"none"===i(o).opts.display&&(i(o).opts.display="auto"),"hidden"===i(o).opts.visibility&&(i(o).opts.visibility="visible"),i(o).opts.loop=!1,i(o).opts.begin=null,i(o).opts.complete=null,v.easing||delete s.easing,v.duration||delete s.duration,s=f.extend({},i(o).opts,s);var E=f.extend(!0,{},i(o).tweensContainer);for(var H in E)if("element"!==H){var N=E[H].startValue;E[H].startValue=E[H].currentValue=E[H].endValue,E[H].endValue=N,m.isEmptyObject(v)||(E[H].easing=s.easing),b.debug&&console.log("reverse tweensContainer ("+H+"): "+JSON.stringify(E[H]),o)}l=E}else if("start"===A){var E;i(o).tweensContainer&&i(o).isAnimating===!0&&(E=i(o).tweensContainer),f.each(y,function(e,t){if(RegExp("^"+S.Lists.colors.join("$|^")+"$").test(e)){var r=p(t,!0),n=r[0],o=r[1],i=r[2];if(S.RegEx.isHex.test(n)){for(var s=["Red","Green","Blue"],l=S.Values.hexToRgb(n),u=i?S.Values.hexToRgb(i):a,c=0;cO;O++){var q={delay:j.delay,progress:j.progress};O===z-1&&(q.display=j.display,q.visibility=j.visibility,q.complete=j.complete),P(g,"reverse",q)}return e()}};b=f.extend(P,b),b.animate=P;var w=t.requestAnimationFrame||g;return b.State.isMobile||r.hidden===a||r.addEventListener("visibilitychange",function(){r.hidden?(w=function(e){return setTimeout(function(){e(!0)},16)},c()):w=t.requestAnimationFrame||g}),e.Velocity=b,e!==t&&(e.fn.velocity=P,e.fn.velocity.defaults=b.defaults),f.each(["Down","Up"],function(e,t){b.Redirects["slide"+t]=function(e,r,n,o,i,s){var l=f.extend({},r),u=l.begin,c=l.complete,p={height:"",marginTop:"",marginBottom:"",paddingTop:"",paddingBottom:""},d={};l.display===a&&(l.display="Down"===t?"inline"===b.CSS.Values.getDisplayType(e)?"inline-block":"block":"none"),l.begin=function(){u&&u.call(i,i);for(var r in p){d[r]=e.style[r];var a=b.CSS.getPropertyValue(e,r);p[r]="Down"===t?[a,0]:[0,a]}d.overflow=e.style.overflow,e.style.overflow="hidden"},l.complete=function(){for(var t in d)e.style[t]=d[t];c&&c.call(i,i),s&&s.resolver(i)},b(e,p,l)}}),f.each(["In","Out"],function(e,t){b.Redirects["fade"+t]=function(e,r,n,o,i,s){var l=f.extend({},r),u={opacity:"In"===t?1:0},c=l.complete;l.complete=n!==o-1?l.begin=null:function(){c&&c.call(i,i),s&&s.resolver(i)},l.display===a&&(l.display="In"===t?"auto":"none"),b(this,u,l)}}),b}(window.jQuery||window.Zepto||window,window,document)})); -;!function(a,b,c,d){"use strict";function k(a,b,c){return setTimeout(q(a,c),b)}function l(a,b,c){return Array.isArray(a)?(m(a,c[b],c),!0):!1}function m(a,b,c){var e;if(a)if(a.forEach)a.forEach(b,c);else if(a.length!==d)for(e=0;e-1}function x(a){return a.trim().split(/\s+/g)}function y(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;dc[b]}):d.sort()),d}function B(a,b){for(var c,f,g=b[0].toUpperCase()+b.slice(1),h=0;h1&&!c.firstMultiple?c.firstMultiple=gb(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=b.center=hb(d);b.timeStamp=j(),b.deltaTime=b.timeStamp-f.timeStamp,b.angle=lb(h,i),b.distance=kb(h,i),eb(c,b),b.offsetDirection=jb(b.deltaX,b.deltaY),b.scale=g?nb(g.pointers,d):1,b.rotation=g?mb(g.pointers,d):0,fb(c,b);var k=a.element;v(b.srcEvent.target,k)&&(k=b.srcEvent.target),b.target=k}function eb(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(b.eventType===O||f.eventType===Q)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function fb(a,b){var f,g,h,j,c=a.lastInterval||b,e=b.timeStamp-c.timeStamp;if(b.eventType!=R&&(e>N||c.velocity===d)){var k=c.deltaX-b.deltaX,l=c.deltaY-b.deltaY,m=ib(e,k,l);g=m.x,h=m.y,f=i(m.x)>i(m.y)?m.x:m.y,j=jb(k,l),a.lastInterval=b}else f=c.velocity,g=c.velocityX,h=c.velocityY,j=c.direction;b.velocity=f,b.velocityX=g,b.velocityY=h,b.direction=j}function gb(a){for(var b=[],c=0;ce;)c+=a[e].clientX,d+=a[e].clientY,e++;return{x:h(c/b),y:h(d/b)}}function ib(a,b,c){return{x:b/a||0,y:c/a||0}}function jb(a,b){return a===b?S:i(a)>=i(b)?a>0?T:U:b>0?V:W}function kb(a,b,c){c||(c=$);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function lb(a,b,c){c||(c=$);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function mb(a,b){return lb(b[1],b[0],_)-lb(a[1],a[0],_)}function nb(a,b){return kb(b[0],b[1],_)/kb(a[0],a[1],_)}function rb(){this.evEl=pb,this.evWin=qb,this.allow=!0,this.pressed=!1,ab.apply(this,arguments)}function wb(){this.evEl=ub,this.evWin=vb,ab.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function Ab(){this.evTarget=yb,this.evWin=zb,this.started=!1,ab.apply(this,arguments)}function Bb(a,b){var c=z(a.touches),d=z(a.changedTouches);return b&(Q|R)&&(c=A(c.concat(d),"identifier",!0)),[c,d]}function Eb(){this.evTarget=Db,this.targetIds={},ab.apply(this,arguments)}function Fb(a,b){var c=z(a.touches),d=this.targetIds;if(b&(O|P)&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=z(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return v(a.target,i)}),b===O)for(e=0;eh&&(b.push(a),h=b.length-1):e&(Q|R)&&(c=!0),0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var xb={touchstart:O,touchmove:P,touchend:Q,touchcancel:R},yb="touchstart",zb="touchstart touchmove touchend touchcancel";p(Ab,ab,{handler:function(a){var b=xb[a.type];if(b===O&&(this.started=!0),this.started){var c=Bb.call(this,a,b);b&(Q|R)&&0===c[0].length-c[1].length&&(this.started=!1),this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:J,srcEvent:a})}}});var Cb={touchstart:O,touchmove:P,touchend:Q,touchcancel:R},Db="touchstart touchmove touchend touchcancel";p(Eb,ab,{handler:function(a){var b=Cb[a.type],c=Fb.call(this,a,b);c&&this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:J,srcEvent:a})}}),p(Gb,ab,{handler:function(a,b,c){var d=c.pointerType==J,e=c.pointerType==L;if(d)this.mouse.allow=!1;else if(e&&!this.mouse.allow)return;b&(Q|R)&&(this.mouse.allow=!0),this.callback(a,b,c)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Hb=B(f.style,"touchAction"),Ib=Hb!==d,Jb="compute",Kb="auto",Lb="manipulation",Mb="none",Nb="pan-x",Ob="pan-y";Pb.prototype={set:function(a){a==Jb&&(a=this.compute()),Ib&&(this.manager.element.style[Hb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return m(this.manager.recognizers,function(b){r(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),Qb(a.join(" "))},preventDefaults:function(a){if(!Ib){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return b.preventDefault(),void 0;var d=this.actions,e=w(d,Mb),f=w(d,Ob),g=w(d,Nb);return e||f&&c&X||g&&c&Y?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var Rb=1,Sb=2,Tb=4,Ub=8,Vb=Ub,Wb=16,Xb=32;Yb.prototype={defaults:{},set:function(a){return n(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(l(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=_b(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return l(a,"dropRecognizeWith",this)?this:(a=_b(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(l(a,"requireFailure",this))return this;var b=this.requireFail;return a=_b(a,this),-1===y(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(l(a,"dropRequireFailure",this))return this;a=_b(a,this);var b=y(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){function d(d){b.manager.emit(b.options.event+(d?Zb(c):""),a)}var b=this,c=this.state;Ub>c&&d(!0),d(),c>=Ub&&d(!0)},tryEmit:function(a){return this.canEmit()?this.emit(a):(this.state=Xb,void 0)},canEmit:function(){for(var a=0;af?T:U,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?S:0>g?V:W,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return ac.prototype.attrTest.call(this,a)&&(this.state&Sb||!(this.state&Sb)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=$b(a.direction);b&&this.manager.emit(this.options.event+b,a),this._super.emit.call(this,a)}}),p(cc,ac,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Mb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&Sb)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),p(dc,Yb,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[Kb]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,!d||!c||a.eventType&(Q|R)&&!e)this.reset();else if(a.eventType&O)this.reset(),this._timer=k(function(){this.state=Vb,this.tryEmit()},b.time,this);else if(a.eventType&Q)return Vb;return Xb},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===Vb&&(a&&a.eventType&Q?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=j(),this.manager.emit(this.options.event,this._input)))}}),p(ec,ac,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Mb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&Sb)}}),p(fc,ac,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:X|Y,pointers:1},getTouchAction:function(){return bc.prototype.getTouchAction.call(this)},attrTest:function(a){var c,b=this.options.direction;return b&(X|Y)?c=a.velocity:b&X?c=a.velocityX:b&Y&&(c=a.velocityY),this._super.attrTest.call(this,a)&&b&a.direction&&a.distance>this.options.threshold&&i(c)>this.options.velocity&&a.eventType&Q},emit:function(a){var b=$b(a.direction);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),p(gc,Yb,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[Lb]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance -1 + } + + function x(a) { + return a.trim().split(/\s+/g) + } + + function y(a, b, c) { + if (a.indexOf && !c) return a.indexOf(b); + for (var d = 0; d < a.length;) { + if (c && a[d][c] == b || !c && a[d] === b) return d; + d++ + } + return -1 + } + + function z(a) { + return Array.prototype.slice.call(a, 0) + } + + function A(a, b, c) { + for (var d = [], e = [], f = 0; f < a.length;) { + var g = b ? a[f][b] : a[f]; + y(e, g) < 0 && d.push(a[f]), e[f] = g, f++ + } + return c && (d = b ? d.sort(function (a, c) { + return a[b] > c[b] + }) : d.sort()), d + } + + function B(a, b) { + for (var c, f, g = b[0].toUpperCase() + b.slice(1), h = 0; h < e.length;) { + if (c = e[h], f = c ? c + g : b, f in a) return f; + h++ + } + return d + } + + function D() { + return C++ + } + + function E(a) { + var b = a.ownerDocument; + return b.defaultView || b.parentWindow + } + + function ab(a, b) { + var c = this; + this.manager = a, this.callback = b, this.element = a.element, this.target = a.options.inputTarget, this.domHandler = function (b) { + r(a.options.enable, [a]) && c.handler(b) + }, this.init() + } + + function bb(a) { + var b, c = a.options.inputClass; + return b = c ? c : H ? wb : I ? Eb : G ? Gb : rb, new b(a, cb) + } + + function cb(a, b, c) { + var d = c.pointers.length, e = c.changedPointers.length, f = b & O && 0 === d - e, + g = b & (Q | R) && 0 === d - e; + c.isFirst = !!f, c.isFinal = !!g, f && (a.session = {}), c.eventType = b, db(a, c), a.emit("hammer.input", c), a.recognize(c), a.session.prevInput = c + } + + function db(a, b) { + var c = a.session, d = b.pointers, e = d.length; + c.firstInput || (c.firstInput = gb(b)), e > 1 && !c.firstMultiple ? c.firstMultiple = gb(b) : 1 === e && (c.firstMultiple = !1); + var f = c.firstInput, g = c.firstMultiple, h = g ? g.center : f.center, i = b.center = hb(d); + b.timeStamp = j(), b.deltaTime = b.timeStamp - f.timeStamp, b.angle = lb(h, i), b.distance = kb(h, i), eb(c, b), b.offsetDirection = jb(b.deltaX, b.deltaY), b.scale = g ? nb(g.pointers, d) : 1, b.rotation = g ? mb(g.pointers, d) : 0, fb(c, b); + var k = a.element; + v(b.srcEvent.target, k) && (k = b.srcEvent.target), b.target = k + } + + function eb(a, b) { + var c = b.center, d = a.offsetDelta || {}, e = a.prevDelta || {}, f = a.prevInput || {}; + (b.eventType === O || f.eventType === Q) && (e = a.prevDelta = { + x: f.deltaX || 0, + y: f.deltaY || 0 + }, d = a.offsetDelta = {x: c.x, y: c.y}), b.deltaX = e.x + (c.x - d.x), b.deltaY = e.y + (c.y - d.y) + } + + function fb(a, b) { + var f, g, h, j, c = a.lastInterval || b, e = b.timeStamp - c.timeStamp; + if (b.eventType != R && (e > N || c.velocity === d)) { + var k = c.deltaX - b.deltaX, l = c.deltaY - b.deltaY, m = ib(e, k, l); + g = m.x, h = m.y, f = i(m.x) > i(m.y) ? m.x : m.y, j = jb(k, l), a.lastInterval = b + } else f = c.velocity, g = c.velocityX, h = c.velocityY, j = c.direction; + b.velocity = f, b.velocityX = g, b.velocityY = h, b.direction = j + } + + function gb(a) { + for (var b = [], c = 0; c < a.pointers.length;) b[c] = { + clientX: h(a.pointers[c].clientX), + clientY: h(a.pointers[c].clientY) + }, c++; + return {timeStamp: j(), pointers: b, center: hb(b), deltaX: a.deltaX, deltaY: a.deltaY} + } + + function hb(a) { + var b = a.length; + if (1 === b) return {x: h(a[0].clientX), y: h(a[0].clientY)}; + for (var c = 0, d = 0, e = 0; b > e;) c += a[e].clientX, d += a[e].clientY, e++; + return {x: h(c / b), y: h(d / b)} + } + + function ib(a, b, c) { + return {x: b / a || 0, y: c / a || 0} + } + + function jb(a, b) { + return a === b ? S : i(a) >= i(b) ? a > 0 ? T : U : b > 0 ? V : W + } + + function kb(a, b, c) { + c || (c = $); + var d = b[c[0]] - a[c[0]], e = b[c[1]] - a[c[1]]; + return Math.sqrt(d * d + e * e) + } + + function lb(a, b, c) { + c || (c = $); + var d = b[c[0]] - a[c[0]], e = b[c[1]] - a[c[1]]; + return 180 * Math.atan2(e, d) / Math.PI + } + + function mb(a, b) { + return lb(b[1], b[0], _) - lb(a[1], a[0], _) + } + + function nb(a, b) { + return kb(b[0], b[1], _) / kb(a[0], a[1], _) + } + + function rb() { + this.evEl = pb, this.evWin = qb, this.allow = !0, this.pressed = !1, ab.apply(this, arguments) + } + + function wb() { + this.evEl = ub, this.evWin = vb, ab.apply(this, arguments), this.store = this.manager.session.pointerEvents = [] + } + + function Ab() { + this.evTarget = yb, this.evWin = zb, this.started = !1, ab.apply(this, arguments) + } + + function Bb(a, b) { + var c = z(a.touches), d = z(a.changedTouches); + return b & (Q | R) && (c = A(c.concat(d), "identifier", !0)), [c, d] + } + + function Eb() { + this.evTarget = Db, this.targetIds = {}, ab.apply(this, arguments) + } + + function Fb(a, b) { + var c = z(a.touches), d = this.targetIds; + if (b & (O | P) && 1 === c.length) return d[c[0].identifier] = !0, [c, c]; + var e, f, g = z(a.changedTouches), h = [], i = this.target; + if (f = c.filter(function (a) { + return v(a.target, i) + }), b === O) for (e = 0; e < f.length;) d[f[e].identifier] = !0, e++; + for (e = 0; e < g.length;) d[g[e].identifier] && h.push(g[e]), b & (Q | R) && delete d[g[e].identifier], e++; + return h.length ? [A(f.concat(h), "identifier", !0), h] : void 0 + } + + function Gb() { + ab.apply(this, arguments); + var a = q(this.handler, this); + this.touch = new Eb(this.manager, a), this.mouse = new rb(this.manager, a) + } + + function Pb(a, b) { + this.manager = a, this.set(b) + } + + function Qb(a) { + if (w(a, Mb)) return Mb; + var b = w(a, Nb), c = w(a, Ob); + return b && c ? Nb + " " + Ob : b || c ? b ? Nb : Ob : w(a, Lb) ? Lb : Kb + } + + function Yb(a) { + this.id = D(), this.manager = null, this.options = o(a || {}, this.defaults), this.options.enable = s(this.options.enable, !0), this.state = Rb, this.simultaneous = {}, this.requireFail = [] + } + + function Zb(a) { + return a & Wb ? "cancel" : a & Ub ? "end" : a & Tb ? "move" : a & Sb ? "start" : "" + } + + function $b(a) { + return a == W ? "down" : a == V ? "up" : a == T ? "left" : a == U ? "right" : "" + } + + function _b(a, b) { + var c = b.manager; + return c ? c.get(a) : a + } + + function ac() { + Yb.apply(this, arguments) + } + + function bc() { + ac.apply(this, arguments), this.pX = null, this.pY = null + } + + function cc() { + ac.apply(this, arguments) + } + + function dc() { + Yb.apply(this, arguments), this._timer = null, this._input = null + } + + function ec() { + ac.apply(this, arguments) + } + + function fc() { + ac.apply(this, arguments) + } + + function gc() { + Yb.apply(this, arguments), this.pTime = !1, this.pCenter = !1, this._timer = null, this._input = null, this.count = 0 + } + + function hc(a, b) { + return b = b || {}, b.recognizers = s(b.recognizers, hc.defaults.preset), new kc(a, b) + } + + function kc(a, b) { + b = b || {}, this.options = o(b, hc.defaults), this.options.inputTarget = this.options.inputTarget || a, this.handlers = {}, this.session = {}, this.recognizers = [], this.element = a, this.input = bb(this), this.touchAction = new Pb(this, this.options.touchAction), lc(this, !0), m(b.recognizers, function (a) { + var b = this.add(new a[0](a[1])); + a[2] && b.recognizeWith(a[2]), a[3] && b.requireFailure(a[3]) + }, this) + } + + function lc(a, b) { + var c = a.element; + m(a.options.cssProps, function (a, d) { + c.style[B(c.style, d)] = b ? a : "" + }) + } + + function mc(a, c) { + var d = b.createEvent("Event"); + d.initEvent(a, !0, !0), d.gesture = c, c.target.dispatchEvent(d) + } + + var e = ["", "webkit", "moz", "MS", "ms", "o"], f = b.createElement("div"), g = "function", h = Math.round, + i = Math.abs, j = Date.now, C = 1, F = /mobile|tablet|ip(ad|hone|od)|android/i, G = "ontouchstart" in a, + H = B(a, "PointerEvent") !== d, I = G && F.test(navigator.userAgent), J = "touch", K = "pen", L = "mouse", + M = "kinect", N = 25, O = 1, P = 2, Q = 4, R = 8, S = 1, T = 2, U = 4, V = 8, W = 16, X = T | U, Y = V | W, + Z = X | Y, $ = ["x", "y"], _ = ["clientX", "clientY"]; + ab.prototype = { + handler: function () { + }, init: function () { + this.evEl && t(this.element, this.evEl, this.domHandler), this.evTarget && t(this.target, this.evTarget, this.domHandler), this.evWin && t(E(this.element), this.evWin, this.domHandler) + }, destroy: function () { + this.evEl && u(this.element, this.evEl, this.domHandler), this.evTarget && u(this.target, this.evTarget, this.domHandler), this.evWin && u(E(this.element), this.evWin, this.domHandler) + } + }; + var ob = {mousedown: O, mousemove: P, mouseup: Q}, pb = "mousedown", qb = "mousemove mouseup"; + p(rb, ab, { + handler: function (a) { + var b = ob[a.type]; + b & O && 0 === a.button && (this.pressed = !0), b & P && 1 !== a.which && (b = Q), this.pressed && this.allow && (b & Q && (this.pressed = !1), this.callback(this.manager, b, { + pointers: [a], + changedPointers: [a], + pointerType: L, + srcEvent: a + })) + } + }); + var sb = {pointerdown: O, pointermove: P, pointerup: Q, pointercancel: R, pointerout: R}, + tb = {2: J, 3: K, 4: L, 5: M}, ub = "pointerdown", vb = "pointermove pointerup pointercancel"; + a.MSPointerEvent && (ub = "MSPointerDown", vb = "MSPointerMove MSPointerUp MSPointerCancel"), p(wb, ab, { + handler: function (a) { + var b = this.store, c = !1, d = a.type.toLowerCase().replace("ms", ""), e = sb[d], + f = tb[a.pointerType] || a.pointerType, g = f == J, h = y(b, a.pointerId, "pointerId"); + e & O && (0 === a.button || g) ? 0 > h && (b.push(a), h = b.length - 1) : e & (Q | R) && (c = !0), 0 > h || (b[h] = a, this.callback(this.manager, e, { + pointers: b, + changedPointers: [a], + pointerType: f, + srcEvent: a + }), c && b.splice(h, 1)) + } + }); + var xb = {touchstart: O, touchmove: P, touchend: Q, touchcancel: R}, yb = "touchstart", + zb = "touchstart touchmove touchend touchcancel"; + p(Ab, ab, { + handler: function (a) { + var b = xb[a.type]; + if (b === O && (this.started = !0), this.started) { + var c = Bb.call(this, a, b); + b & (Q | R) && 0 === c[0].length - c[1].length && (this.started = !1), this.callback(this.manager, b, { + pointers: c[0], + changedPointers: c[1], + pointerType: J, + srcEvent: a + }) + } + } + }); + var Cb = {touchstart: O, touchmove: P, touchend: Q, touchcancel: R}, + Db = "touchstart touchmove touchend touchcancel"; + p(Eb, ab, { + handler: function (a) { + var b = Cb[a.type], c = Fb.call(this, a, b); + c && this.callback(this.manager, b, {pointers: c[0], changedPointers: c[1], pointerType: J, srcEvent: a}) + } + }), p(Gb, ab, { + handler: function (a, b, c) { + var d = c.pointerType == J, e = c.pointerType == L; + if (d) this.mouse.allow = !1; else if (e && !this.mouse.allow) return; + b & (Q | R) && (this.mouse.allow = !0), this.callback(a, b, c) + }, destroy: function () { + this.touch.destroy(), this.mouse.destroy() + } + }); + var Hb = B(f.style, "touchAction"), Ib = Hb !== d, Jb = "compute", Kb = "auto", Lb = "manipulation", Mb = "none", + Nb = "pan-x", Ob = "pan-y"; + Pb.prototype = { + set: function (a) { + a == Jb && (a = this.compute()), Ib && (this.manager.element.style[Hb] = a), this.actions = a.toLowerCase().trim() + }, update: function () { + this.set(this.manager.options.touchAction) + }, compute: function () { + var a = []; + return m(this.manager.recognizers, function (b) { + r(b.options.enable, [b]) && (a = a.concat(b.getTouchAction())) + }), Qb(a.join(" ")) + }, preventDefaults: function (a) { + if (!Ib) { + var b = a.srcEvent, c = a.offsetDirection; + if (this.manager.session.prevented) return b.preventDefault(), void 0; + var d = this.actions, e = w(d, Mb), f = w(d, Ob), g = w(d, Nb); + return e || f && c & X || g && c & Y ? this.preventSrc(b) : void 0 + } + }, preventSrc: function (a) { + this.manager.session.prevented = !0, a.preventDefault() + } + }; + var Rb = 1, Sb = 2, Tb = 4, Ub = 8, Vb = Ub, Wb = 16, Xb = 32; + Yb.prototype = { + defaults: {}, set: function (a) { + return n(this.options, a), this.manager && this.manager.touchAction.update(), this + }, recognizeWith: function (a) { + if (l(a, "recognizeWith", this)) return this; + var b = this.simultaneous; + return a = _b(a, this), b[a.id] || (b[a.id] = a, a.recognizeWith(this)), this + }, dropRecognizeWith: function (a) { + return l(a, "dropRecognizeWith", this) ? this : (a = _b(a, this), delete this.simultaneous[a.id], this) + }, requireFailure: function (a) { + if (l(a, "requireFailure", this)) return this; + var b = this.requireFail; + return a = _b(a, this), -1 === y(b, a) && (b.push(a), a.requireFailure(this)), this + }, dropRequireFailure: function (a) { + if (l(a, "dropRequireFailure", this)) return this; + a = _b(a, this); + var b = y(this.requireFail, a); + return b > -1 && this.requireFail.splice(b, 1), this + }, hasRequireFailures: function () { + return this.requireFail.length > 0 + }, canRecognizeWith: function (a) { + return !!this.simultaneous[a.id] + }, emit: function (a) { + function d(d) { + b.manager.emit(b.options.event + (d ? Zb(c) : ""), a) + } + + var b = this, c = this.state; + Ub > c && d(!0), d(), c >= Ub && d(!0) + }, tryEmit: function (a) { + return this.canEmit() ? this.emit(a) : (this.state = Xb, void 0) + }, canEmit: function () { + for (var a = 0; a < this.requireFail.length;) { + if (!(this.requireFail[a].state & (Xb | Rb))) return !1; + a++ + } + return !0 + }, recognize: function (a) { + var b = n({}, a); + return r(this.options.enable, [this, b]) ? (this.state & (Vb | Wb | Xb) && (this.state = Rb), this.state = this.process(b), this.state & (Sb | Tb | Ub | Wb) && this.tryEmit(b), void 0) : (this.reset(), this.state = Xb, void 0) + }, process: function () { + }, getTouchAction: function () { + }, reset: function () { + } + }, p(ac, Yb, { + defaults: {pointers: 1}, attrTest: function (a) { + var b = this.options.pointers; + return 0 === b || a.pointers.length === b + }, process: function (a) { + var b = this.state, c = a.eventType, d = b & (Sb | Tb), e = this.attrTest(a); + return d && (c & R || !e) ? b | Wb : d || e ? c & Q ? b | Ub : b & Sb ? b | Tb : Sb : Xb + } + }), p(bc, ac, { + defaults: {event: "pan", threshold: 10, pointers: 1, direction: Z}, getTouchAction: function () { + var a = this.options.direction, b = []; + return a & X && b.push(Ob), a & Y && b.push(Nb), b + }, directionTest: function (a) { + var b = this.options, c = !0, d = a.distance, e = a.direction, f = a.deltaX, g = a.deltaY; + return e & b.direction || (b.direction & X ? (e = 0 === f ? S : 0 > f ? T : U, c = f != this.pX, d = Math.abs(a.deltaX)) : (e = 0 === g ? S : 0 > g ? V : W, c = g != this.pY, d = Math.abs(a.deltaY))), a.direction = e, c && d > b.threshold && e & b.direction + }, attrTest: function (a) { + return ac.prototype.attrTest.call(this, a) && (this.state & Sb || !(this.state & Sb) && this.directionTest(a)) + }, emit: function (a) { + this.pX = a.deltaX, this.pY = a.deltaY; + var b = $b(a.direction); + b && this.manager.emit(this.options.event + b, a), this._super.emit.call(this, a) + } + }), p(cc, ac, { + defaults: {event: "pinch", threshold: 0, pointers: 2}, getTouchAction: function () { + return [Mb] + }, attrTest: function (a) { + return this._super.attrTest.call(this, a) && (Math.abs(a.scale - 1) > this.options.threshold || this.state & Sb) + }, emit: function (a) { + if (this._super.emit.call(this, a), 1 !== a.scale) { + var b = a.scale < 1 ? "in" : "out"; + this.manager.emit(this.options.event + b, a) + } + } + }), p(dc, Yb, { + defaults: {event: "press", pointers: 1, time: 500, threshold: 5}, getTouchAction: function () { + return [Kb] + }, process: function (a) { + var b = this.options, c = a.pointers.length === b.pointers, d = a.distance < b.threshold, + e = a.deltaTime > b.time; + if (this._input = a, !d || !c || a.eventType & (Q | R) && !e) this.reset(); else if (a.eventType & O) this.reset(), this._timer = k(function () { + this.state = Vb, this.tryEmit() + }, b.time, this); else if (a.eventType & Q) return Vb; + return Xb + }, reset: function () { + clearTimeout(this._timer) + }, emit: function (a) { + this.state === Vb && (a && a.eventType & Q ? this.manager.emit(this.options.event + "up", a) : (this._input.timeStamp = j(), this.manager.emit(this.options.event, this._input))) + } + }), p(ec, ac, { + defaults: {event: "rotate", threshold: 0, pointers: 2}, getTouchAction: function () { + return [Mb] + }, attrTest: function (a) { + return this._super.attrTest.call(this, a) && (Math.abs(a.rotation) > this.options.threshold || this.state & Sb) + } + }), p(fc, ac, { + defaults: {event: "swipe", threshold: 10, velocity: .65, direction: X | Y, pointers: 1}, + getTouchAction: function () { + return bc.prototype.getTouchAction.call(this) + }, + attrTest: function (a) { + var c, b = this.options.direction; + return b & (X | Y) ? c = a.velocity : b & X ? c = a.velocityX : b & Y && (c = a.velocityY), this._super.attrTest.call(this, a) && b & a.direction && a.distance > this.options.threshold && i(c) > this.options.velocity && a.eventType & Q + }, + emit: function (a) { + var b = $b(a.direction); + b && this.manager.emit(this.options.event + b, a), this.manager.emit(this.options.event, a) + } + }), p(gc, Yb, { + defaults: { + event: "tap", + pointers: 1, + taps: 1, + interval: 300, + time: 250, + threshold: 2, + posThreshold: 10 + }, getTouchAction: function () { + return [Lb] + }, process: function (a) { + var b = this.options, c = a.pointers.length === b.pointers, d = a.distance < b.threshold, + e = a.deltaTime < b.time; + if (this.reset(), a.eventType & O && 0 === this.count) return this.failTimeout(); + if (d && e && c) { + if (a.eventType != Q) return this.failTimeout(); + var f = this.pTime ? a.timeStamp - this.pTime < b.interval : !0, + g = !this.pCenter || kb(this.pCenter, a.center) < b.posThreshold; + this.pTime = a.timeStamp, this.pCenter = a.center, g && f ? this.count += 1 : this.count = 1, this._input = a; + var h = this.count % b.taps; + if (0 === h) return this.hasRequireFailures() ? (this._timer = k(function () { + this.state = Vb, this.tryEmit() + }, b.interval, this), Sb) : Vb + } + return Xb + }, failTimeout: function () { + return this._timer = k(function () { + this.state = Xb + }, this.options.interval, this), Xb + }, reset: function () { + clearTimeout(this._timer) + }, emit: function () { + this.state == Vb && (this._input.tapCount = this.count, this.manager.emit(this.options.event, this._input)) + } + }), hc.VERSION = "2.0.4", hc.defaults = { + domEvents: !1, + touchAction: Jb, + enable: !0, + inputTarget: null, + inputClass: null, + preset: [[ec, {enable: !1}], [cc, {enable: !1}, ["rotate"]], [fc, {direction: X}], [bc, {direction: X}, ["swipe"]], [gc], [gc, { + event: "doubletap", + taps: 2 + }, ["tap"]], [dc]], + cssProps: { + userSelect: "default", + touchSelect: "none", + touchCallout: "none", + contentZooming: "none", + userDrag: "none", + tapHighlightColor: "rgba(0,0,0,0)" + } + }; + var ic = 1, jc = 2; + kc.prototype = { + set: function (a) { + return n(this.options, a), a.touchAction && this.touchAction.update(), a.inputTarget && (this.input.destroy(), this.input.target = a.inputTarget, this.input.init()), this + }, stop: function (a) { + this.session.stopped = a ? jc : ic + }, recognize: function (a) { + var b = this.session; + if (!b.stopped) { + this.touchAction.preventDefaults(a); + var c, d = this.recognizers, e = b.curRecognizer; + (!e || e && e.state & Vb) && (e = b.curRecognizer = null); + for (var f = 0; f < d.length;) c = d[f], b.stopped === jc || e && c != e && !c.canRecognizeWith(e) ? c.reset() : c.recognize(a), !e && c.state & (Sb | Tb | Ub) && (e = b.curRecognizer = c), f++ + } + }, get: function (a) { + if (a instanceof Yb) return a; + for (var b = this.recognizers, c = 0; c < b.length; c++) if (b[c].options.event == a) return b[c]; + return null + }, add: function (a) { + if (l(a, "add", this)) return this; + var b = this.get(a.options.event); + return b && this.remove(b), this.recognizers.push(a), a.manager = this, this.touchAction.update(), a + }, remove: function (a) { + if (l(a, "remove", this)) return this; + var b = this.recognizers; + return a = this.get(a), b.splice(y(b, a), 1), this.touchAction.update(), this + }, on: function (a, b) { + var c = this.handlers; + return m(x(a), function (a) { + c[a] = c[a] || [], c[a].push(b) + }), this + }, off: function (a, b) { + var c = this.handlers; + return m(x(a), function (a) { + b ? c[a].splice(y(c[a], b), 1) : delete c[a] + }), this + }, emit: function (a, b) { + this.options.domEvents && mc(a, b); + var c = this.handlers[a] && this.handlers[a].slice(); + if (c && c.length) { + b.type = a, b.preventDefault = function () { + b.srcEvent.preventDefault() + }; + for (var d = 0; d < c.length;) c[d](b), d++ + } + }, destroy: function () { + this.element && lc(this, !1), this.handlers = {}, this.session = {}, this.input.destroy(), this.element = null + } + }, n(hc, { + INPUT_START: O, + INPUT_MOVE: P, + INPUT_END: Q, + INPUT_CANCEL: R, + STATE_POSSIBLE: Rb, + STATE_BEGAN: Sb, + STATE_CHANGED: Tb, + STATE_ENDED: Ub, + STATE_RECOGNIZED: Vb, + STATE_CANCELLED: Wb, + STATE_FAILED: Xb, + DIRECTION_NONE: S, + DIRECTION_LEFT: T, + DIRECTION_RIGHT: U, + DIRECTION_UP: V, + DIRECTION_DOWN: W, + DIRECTION_HORIZONTAL: X, + DIRECTION_VERTICAL: Y, + DIRECTION_ALL: Z, + Manager: kc, + Input: ab, + TouchAction: Pb, + TouchInput: Eb, + MouseInput: rb, + PointerEventInput: wb, + TouchMouseInput: Gb, + SingleTouchInput: Ab, + Recognizer: Yb, + AttrRecognizer: ac, + Tap: gc, + Pan: bc, + Swipe: fc, + Pinch: cc, + Rotate: ec, + Press: dc, + on: t, + off: u, + each: m, + merge: o, + extend: n, + inherit: p, + bindFn: q, + prefixed: B + }), typeof define == g && define.amd ? define(function () { + return hc + }) : "undefined" != typeof module && module.exports ? module.exports = hc : a[c] = hc +}(window, document, "Hammer"); +(function (factory) { if (typeof define === 'function' && define.amd) { define(['jquery', 'hammerjs'], factory); } else if (typeof exports === 'object') { @@ -265,7 +936,7 @@ m.isFunction(t)&&t(null,!0)}),f.queue(a,m.isString(v)?v:"",[])),"stop"===y?(i(a) }; })(Hammer.Manager.prototype.emit); })); -;// Required for Meteor package, the use of window prevents export by Meteor +// Required for Meteor package, the use of window prevents export by Meteor (function(window){ if(window.Package){ Materialize = {}; @@ -310,8 +981,8 @@ if ($) { } else { Vel = Velocity; } -;(function ($) { - $.fn.collapsible = function(options) { +(function ($) { + $.fn.collapsible = function (options) { var defaults = { accordion: undefined }; @@ -446,9 +1117,10 @@ if ($) { $(document).ready(function(){ $('.collapsible').collapsible(); }); -}( jQuery ));;(function ($) { +}(jQuery)); +(function ($) { - // Add posibility to scroll to selected option + // Add posibility to scroll to selected option // usefull for select for example $.fn.scrollTo = function(elem) { $(this).scrollTop($(this).scrollTop() - $(this).offset().top + $(elem).offset().top); @@ -711,7 +1383,7 @@ if ($) { $('.dropdown-button').dropdown(); }); }( jQuery )); -;(function($) { +(function ($) { var _stack = 0, _lastID = 0, _generateID = function() { @@ -903,9 +1575,8 @@ if ($) { } }); })(jQuery); -;(function ($) { - - $.fn.materialbox = function () { +(function ($) { + $.fn.materialbox = function () { return this.each(function() { @@ -1172,8 +1843,7 @@ $(document).ready(function(){ }); }( jQuery )); -;(function ($) { - +(function ($) { $.fn.parallax = function () { var window_width = $(window).width(); // Parallax Scripts @@ -1229,9 +1899,9 @@ $(document).ready(function(){ }); }; -}( jQuery ));;(function ($) { - - var methods = { +}(jQuery)); +(function ($) { + var methods = { init : function(options) { var defaults = { onShow: null @@ -1377,7 +2047,7 @@ $(document).ready(function(){ $('ul.tabs').tabs(); }); }( jQuery )); -;(function ($) { +(function ($) { $.fn.tooltip = function (options) { var timeout = null, margin = 5; @@ -1607,7 +2277,7 @@ $(document).ready(function(){ $('.tooltipped').tooltip(); }); }( jQuery )); -;/*! +/*! * Waves v0.6.4 * http://fian.my.id/Waves * @@ -1616,7 +2286,7 @@ $(document).ready(function(){ * https://github.com/fians/Waves/blob/master/LICENSE */ -;(function(window) { +(function (window) { 'use strict'; var Waves = Waves || {}; @@ -1945,7 +2615,7 @@ $(document).ready(function(){ }, false); })(window); -;Materialize.toast = function (message, displayLength, className, completeCallback) { +Materialize.toast = function (message, displayLength, className, completeCallback) { className = className || ""; var container = document.getElementById('toast-container'); @@ -2081,9 +2751,8 @@ $(document).ready(function(){ return toast; } }; -;(function ($) { - - var methods = { +(function ($) { + var methods = { init : function(options) { var defaults = { menuWidth: 300, @@ -2433,7 +3102,7 @@ $(document).ready(function(){ } }; // Plugin end }( jQuery )); -;/** +/** * Extend jquery with a scrollspy plugin. * This watches the window scroll and fires events when elements are scrolled into viewport. * @@ -2458,7 +3127,7 @@ $(document).ready(function(){ right : 0, bottom : 0, left : 0, - } + }; /** * Find elements that are within the boundary @@ -2591,9 +3260,9 @@ $(document).ready(function(){ } return result; }; - }; + } - /** + /** * Enables ScrollSpy using a selector * @param {jQuery|string} selector The elements collection, or a selector * @param {Object=} options Optional. @@ -2716,8 +3385,8 @@ $(document).ready(function(){ }; })(jQuery); -;(function ($) { - $(document).ready(function() { +(function ($) { + $(document).ready(function () { // Function to update labels of text fields Materialize.updateTextFields = function() { @@ -2822,7 +3491,7 @@ $(document).ready(function(){ $(this).removeClass('tabbed'); }); - return; + } }); @@ -3397,9 +4066,8 @@ $(document).ready(function(){ }; }( jQuery )); -;(function ($) { - - var methods = { +(function ($) { + var methods = { init : function(options) { var defaults = { @@ -3718,8 +4386,8 @@ $(document).ready(function(){ } }; // Plugin end }( jQuery )); -;(function ($) { - $(document).ready(function() { +(function ($) { + $(document).ready(function () { $(document).on('click.card', '.card', function (e) { if ($(this).find('> .card-reveal').length) { @@ -3743,8 +4411,9 @@ $(document).ready(function(){ }); }); -}( jQuery ));;(function ($) { - var chipsHandleEvents = false; +}(jQuery)); +(function ($) { + var chipsHandleEvents = false; var materialChipsDefaults = { data: [], placeholder: '', @@ -3907,7 +4576,7 @@ $(document).ready(function(){ if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) { self.selectChip(chipsIndex, chipsLength - 1, $chips); $target.blur(); - return; + } }); @@ -4009,8 +4678,9 @@ $(document).ready(function(){ chipsHandleEvents = true; } }; -}( jQuery ));;(function ($) { - $.fn.pushpin = function (options) { +}(jQuery)); +(function ($) { + $.fn.pushpin = function (options) { // Defaults var defaults = { top: 0, @@ -4079,8 +4749,9 @@ $(document).ready(function(){ }); }; -}( jQuery ));;(function ($) { - $(document).ready(function() { +}(jQuery)); +(function ($) { + $(document).ready(function () { // jQuery reverse $.fn.reverse = [].reverse; @@ -4170,8 +4841,8 @@ $(document).ready(function(){ }( jQuery )); -;(function ($) { - // Image transition function +(function ($) { + // Image transition function Materialize.fadeInImage = function(selectorOrEl) { var element; if (typeof(selectorOrEl) === 'string') { @@ -4339,9 +5010,9 @@ $(document).ready(function(){ // }); }); }( jQuery )); -;(function($) { +(function ($) { - // Input: Array of JSON objects {selector, offset, callback} + // Input: Array of JSON objects {selector, offset, callback} Materialize.scrollFire = function(options) { @@ -4387,7 +5058,7 @@ $(document).ready(function(){ }; })(jQuery); -;/*! +/*! * pickadate.js v3.5.0, 2014/04/13 * By Amsul, http://amsul.ca * Hosted on http://amsul.github.io/pickadate.js @@ -4398,20 +5069,20 @@ $(document).ready(function(){ // AMD. if ( typeof define == 'function' && define.amd ) - define( 'picker', ['jquery'], factory ) + define('picker', ['jquery'], factory); // Node.js/browserify. else if ( typeof exports == 'object' ) - module.exports = factory( require('jquery') ) + module.exports = factory(require('jquery')); // Browser globals. else this.Picker = factory( jQuery ) }(function( $ ) { -var $window = $( window ) -var $document = $( document ) -var $html = $( document.documentElement ) + var $window = $(window); + var $document = $(document); + var $html = $(document.documentElement); /** @@ -4420,7 +5091,7 @@ var $html = $( document.documentElement ) function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // If there’s no element, return the picker constructor. - if ( !ELEMENT ) return PickerConstructor + if (!ELEMENT) return PickerConstructor; var @@ -4465,33 +5136,33 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { start: function() { // If it’s already started, do nothing. - if ( STATE && STATE.start ) return P + if (STATE && STATE.start) return P; // Update the picker states. - STATE.methods = {} - STATE.start = true - STATE.open = false - STATE.type = ELEMENT.type + STATE.methods = {}; + STATE.start = true; + STATE.open = false; + STATE.type = ELEMENT.type; // Confirm focus state, convert into text input to remove UA stylings, // and set as readonly to prevent keyboard popup. - ELEMENT.autofocus = ELEMENT == getActiveElement() - ELEMENT.readOnly = !SETTINGS.editable - ELEMENT.id = ELEMENT.id || STATE.id + ELEMENT.autofocus = ELEMENT == getActiveElement(); + ELEMENT.readOnly = !SETTINGS.editable; + ELEMENT.id = ELEMENT.id || STATE.id; if ( ELEMENT.type != 'text' ) { ELEMENT.type = 'text' } // Create a new picker component with the settings. - P.component = new COMPONENT(P, SETTINGS) + P.component = new COMPONENT(P, SETTINGS); // Create the picker root with a holder and then prepare it. - P.$root = $( PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"') ) - prepareElementRoot() + P.$root = $(PickerConstructor._.node('div', createWrappedComponent(), CLASSES.picker, 'id="' + ELEMENT.id + '_root" tabindex="0"')); + prepareElementRoot(); // If there’s a format for the hidden input element, create the element. @@ -4501,12 +5172,12 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // Prepare the input element. - prepareElement() + prepareElement(); // Insert the root as specified in the settings. - if ( SETTINGS.container ) $( SETTINGS.container ).append( P.$root ) - else $ELEMENT.after( P.$root ) + if (SETTINGS.container) $(SETTINGS.container).append(P.$root); + else $ELEMENT.after(P.$root); // Bind the default component and settings events. @@ -4524,11 +5195,11 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { open: SETTINGS.onOpen, close: SETTINGS.onClose, set: SETTINGS.onSet - }) + }); // Once we’re all set, check the theme in use. - IS_DEFAULT_THEME = isUsingDefaultTheme( P.$root.children()[ 0 ] ) + IS_DEFAULT_THEME = isUsingDefaultTheme(P.$root.children()[0]); // If the element has autofocus, open the picker. @@ -4548,8 +5219,8 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { render: function( entireComponent ) { // Insert a new component holder in the root or box. - if ( entireComponent ) P.$root.html( createWrappedComponent() ) - else P.$root.find( '.' + CLASSES.box ).html( P.component.nodes( STATE.open ) ) + if (entireComponent) P.$root.html(createWrappedComponent()); + else P.$root.find('.' + CLASSES.box).html(P.component.nodes(STATE.open)); // Trigger the queued “render” events. return P.trigger( 'render' ) @@ -4562,10 +5233,10 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { stop: function() { // If it’s already stopped, do nothing. - if ( !STATE.start ) return P + if (!STATE.start) return P; // Then close the picker. - P.close() + P.close(); // Remove the hidden field. if ( P._hidden ) { @@ -4573,25 +5244,25 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { } // Remove the root. - P.$root.remove() + P.$root.remove(); // Remove the input class, remove the stored data, and unbind // the events (after a tick for IE - see `P.close`). - $ELEMENT.removeClass( CLASSES.input ).removeData( NAME ) + $ELEMENT.removeClass(CLASSES.input).removeData(NAME); setTimeout( function() { $ELEMENT.off( '.' + STATE.id ) - }, 0) + }, 0); // Restore the element state - ELEMENT.type = STATE.type - ELEMENT.readOnly = false + ELEMENT.type = STATE.type; + ELEMENT.readOnly = false; // Trigger the queued “stop” events. - P.trigger( 'stop' ) + P.trigger('stop'); // Reset the picker states. - STATE.methods = {} - STATE.start = false + STATE.methods = {}; + STATE.start = false; return P }, //stop @@ -4603,11 +5274,11 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { open: function( dontGiveFocus ) { // If it’s already open, do nothing. - if ( STATE.open ) return P + if (STATE.open) return P; // Add the “active” class. - $ELEMENT.addClass( CLASSES.active ) - aria( ELEMENT, 'expanded', true ) + $ELEMENT.addClass(CLASSES.active); + aria(ELEMENT, 'expanded', true); // * A Firefox bug, when `html` has `overflow:hidden`, results in // killing transitions :(. So add the “opened” state on the next tick. @@ -4615,16 +5286,16 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { setTimeout( function() { // Add the “opened” class to the picker root. - P.$root.addClass( CLASSES.opened ) + P.$root.addClass(CLASSES.opened); aria( P.$root[0], 'hidden', false ) - }, 0 ) + }, 0); // If we have to give focus, bind the element and doc events. if ( dontGiveFocus !== false ) { // Set it as open. - STATE.open = true + STATE.open = true; // Prevent the page from scrolling. if ( IS_DEFAULT_THEME ) { @@ -4635,12 +5306,12 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // Pass focus to the root element’s jQuery object. // * Workaround for iOS8 to bring the picker’s root into view. - P.$root.eq(0).focus() + P.$root.eq(0).focus(); // Bind the document events. $document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) { - var target = event.target + var target = event.target; // If the target of the event is not the element, close the picker picker. // * Don’t worry about clicks or focusins on the root because those don’t bubble up. @@ -4666,7 +5337,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { keycodeToMove = P.component.key[ keycode ], // Grab the target. - target = event.target + target = event.target; // On escape, close the picker and give focus. @@ -4679,7 +5350,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { else if ( target == P.$root[0] && ( keycodeToMove || keycode == 13 ) ) { // Prevent the default action to stop page movement. - event.preventDefault() + event.preventDefault(); // Trigger the key movement action. if ( keycodeToMove ) { @@ -4696,7 +5367,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // If the target is within the root and “enter” is pressed, // prevent the default action and trigger a click on the target instead. else if ( $.contains( P.$root[0], target ) && keycode == 13 ) { - event.preventDefault() + event.preventDefault(); target.click() } }) @@ -4717,15 +5388,15 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :| // The focus is triggered *after* the close has completed - causing it // to open again. So unbind and rebind the event at the next tick. - P.$root.off( 'focus.toOpen' ).eq(0).focus() + P.$root.off('focus.toOpen').eq(0).focus(); setTimeout( function() { P.$root.on( 'focus.toOpen', handleFocusToOpenEvent ) }, 0 ) } // Remove the “active” class. - $ELEMENT.removeClass( CLASSES.active ) - aria( ELEMENT, 'expanded', false ) + $ELEMENT.removeClass(CLASSES.active); + aria(ELEMENT, 'expanded', false); // * A Firefox bug, when `html` has `overflow:hidden`, results in // killing transitions :(. So remove the “opened” state on the next tick. @@ -4733,16 +5404,16 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { setTimeout( function() { // Remove the “opened” and “focused” class from the picker root. - P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused ) + P.$root.removeClass(CLASSES.opened + ' ' + CLASSES.focused); aria( P.$root[0], 'hidden', true ) - }, 0 ) + }, 0); // If it’s already closed, do nothing more. - if ( !STATE.open ) return P + if (!STATE.open) return P; // Set it as closed. - STATE.open = false + STATE.open = false; // Allow the page to scroll. if ( IS_DEFAULT_THEME ) { @@ -4752,7 +5423,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { } // Unbind the document events. - $document.off( '.' + STATE.id ) + $document.off('.' + STATE.id); // Trigger the queued “close” events. return P.trigger( 'close' ) @@ -4774,10 +5445,10 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { var thingItem, thingValue, thingIsObject = $.isPlainObject( thing ), - thingObject = thingIsObject ? thing : {} + thingObject = thingIsObject ? thing : {}; // Make sure we have usable options. - options = thingIsObject && $.isPlainObject( value ) ? value : options || {} + options = thingIsObject && $.isPlainObject(value) ? value : options || {}; if ( thing ) { @@ -4790,11 +5461,11 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { for ( thingItem in thingObject ) { // Grab the value of the thing. - thingValue = thingObject[ thingItem ] + thingValue = thingObject[thingItem]; // First, if the item exists and there’s a value, set it. if ( thingItem in P.component.item ) { - if ( thingValue === undefined ) thingValue = null + if (thingValue === undefined) thingValue = null; P.component.set( thingItem, thingValue, options ) } @@ -4821,7 +5492,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { get: function( thing, format ) { // Make sure there’s something to get. - thing = thing || 'value' + thing = thing || 'value'; // If a picker state exists, return that. if ( STATE[ thing ] != null ) { @@ -4844,7 +5515,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // Check if a component item exists, return that. if ( thing in P.component.item ) { if ( typeof format == 'string' ) { - var thingValue = P.component.get( thing ) + var thingValue = P.component.get(thing); return thingValue ? PickerConstructor._.trigger( P.component.formats.toString, @@ -4865,7 +5536,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { var thingName, thingMethod, thingIsObject = $.isPlainObject( thing ), - thingObject = thingIsObject ? thing : {} + thingObject = thingIsObject ? thing : {}; if ( thing ) { @@ -4878,7 +5549,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { for ( thingName in thingObject ) { // Grab the method of the thing. - thingMethod = thingObject[ thingName ] + thingMethod = thingObject[thingName]; // If it was an internal binding, prefix it. if ( internal ) { @@ -4886,7 +5557,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { } // Make sure the thing methods collection exists. - STATE.methods[ thingName ] = STATE.methods[ thingName ] || [] + STATE.methods[thingName] = STATE.methods[thingName] || []; // Add the method to the relative method collection. STATE.methods[ thingName ].push( thingMethod ) @@ -4905,7 +5576,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { var i, thingName, names = arguments; for ( i = 0, namesCount = names.length; i < namesCount; i += 1 ) { - thingName = names[i] + thingName = names[i]; if ( thingName in STATE.methods ) { delete STATE.methods[thingName] } @@ -4919,18 +5590,18 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { */ trigger: function( name, data ) { var _trigger = function( name ) { - var methodList = STATE.methods[ name ] + var methodList = STATE.methods[name]; if ( methodList ) { methodList.map( function( method ) { PickerConstructor._.trigger( method, P, [ data ] ) }) } - } - _trigger( '_' + name ) - _trigger( name ) + }; + _trigger('_' + name); + _trigger(name); return P } //trigger - } //PickerInstance.prototype + }; //PickerInstance.prototype /** @@ -4992,7 +5663,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { val( $ELEMENT.data('value') ? P.get('select', SETTINGS.format) : ELEMENT.value - ) + ); // Only bind keydown events if the element isn’t editable. @@ -5002,7 +5673,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // On focus/click, focus onto the root to open it up. on( 'focus.' + STATE.id + ' click.' + STATE.id, function( event ) { - event.preventDefault() + event.preventDefault(); P.$root.eq(0).focus() }). @@ -5036,7 +5707,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // When something within the root is focused, stop from bubbling // to the doc and remove the “focused” state from the root. focusin: function( event ) { - P.$root.removeClass( CLASSES.focused ) + P.$root.removeClass(CLASSES.focused); event.stopPropagation() }, @@ -5044,12 +5715,12 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // from bubbling to the doc. 'mousedown click': function( event ) { - var target = event.target + var target = event.target; // Make sure the target isn’t the root holder so it can bubble up. if ( target != P.$root.children()[ 0 ] ) { - event.stopPropagation() + event.stopPropagation(); // * For mousedown events, cancel the default action in order to // prevent cases where focus is shifted onto external elements @@ -5057,7 +5728,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // Also, for Firefox, don’t prevent action on the `option` element. if ( event.type == 'mousedown' && !$( target ).is( 'input, select, textarea, button, option' )) { - event.preventDefault() + event.preventDefault(); // Re-focus onto the root so that users can click away // from elements focused within the picker. @@ -5089,8 +5760,8 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { // * For IE, non-focusable elements can be active elements as well // (http://stackoverflow.com/a/2684561). - activeElement = getActiveElement() - activeElement = activeElement && ( activeElement.type || activeElement.href ) + activeElement = getActiveElement(); + activeElement = activeElement && (activeElement.type || activeElement.href); // If it’s disabled or nothing inside is actively focused, re-focus the element. if ( targetDisabled || activeElement && !$.contains( P.$root[0], activeElement ) ) { @@ -5116,7 +5787,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { P.close( true ) } - }) //P.$root + }); //P.$root aria( P.$root[0], 'hidden', true ) } @@ -5127,17 +5798,17 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { */ function prepareElementHidden() { - var name + var name; if ( SETTINGS.hiddenName === true ) { - name = ELEMENT.name + name = ELEMENT.name; ELEMENT.name = '' } else { name = [ typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit' - ] + ]; name = name[0] + ELEMENT.name + name[1] } @@ -5155,7 +5826,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { '' ) + '>' - )[0] + )[0]; $ELEMENT. @@ -5164,11 +5835,11 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { P._hidden.value = ELEMENT.value ? P.get('select', SETTINGS.formatSubmit) : '' - }) + }); // Insert the hidden input as specified in the settings. - if ( SETTINGS.container ) $( SETTINGS.container ).append( P._hidden ) + if (SETTINGS.container) $(SETTINGS.container).append(P._hidden); else $ELEMENT.after( P._hidden ) } @@ -5179,11 +5850,11 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { var keycode = event.keyCode, // Check if one of the delete keys was pressed. - isKeycodeDelete = /^(8|46)$/.test(keycode) + isKeycodeDelete = /^(8|46)$/.test(keycode); // For some reason IE clears the input value on “escape”. if ( keycode == 27 ) { - P.close() + P.close(); return false } @@ -5191,8 +5862,8 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) { // Prevent it from moving the page and bubbling to doc. - event.preventDefault() - event.stopPropagation() + event.preventDefault(); + event.stopPropagation(); // If `delete` was pressed, clear the values and close the picker. // Otherwise open the picker. @@ -5206,7 +5877,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { function handleFocusToOpenEvent( event ) { // Stop the event from propagating to the doc. - event.stopPropagation() + event.stopPropagation(); // If it’s a focus event, add the “focused” class to the root. if ( event.type == 'focus' ) { @@ -5228,7 +5899,7 @@ function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) { * The default classes and prefix to use for the HTML classes. */ PickerConstructor.klasses = function( prefix ) { - prefix = prefix || 'picker' + prefix = prefix || 'picker'; return { picker: prefix, @@ -5246,7 +5917,7 @@ PickerConstructor.klasses = function( prefix ) { box: prefix + '__box' } -} //PickerConstructor.klasses +}; //PickerConstructor.klasses @@ -5256,7 +5927,7 @@ PickerConstructor.klasses = function( prefix ) { function isUsingDefaultTheme( element ) { var theme, - prop = 'position' + prop = 'position'; // For IE. if ( element.currentStyle ) { @@ -5283,23 +5954,22 @@ function getScrollbarWidth() { return 0 } - var $outer = $( '

' ). - appendTo( 'body' ) + var $outer = $( '
' ).appendTo('body'); // Get the width without scrollbars. - var widthWithoutScroll = $outer[0].offsetWidth + var widthWithoutScroll = $outer[0].offsetWidth; // Force adding scrollbars. - $outer.css( 'overflow', 'scroll' ) + $outer.css('overflow', 'scroll'); // Add the inner div. - var $inner = $( '
' ).appendTo( $outer ) + var $inner = $('
').appendTo($outer); // Get the width with scrollbars. - var widthWithScroll = $inner[0].offsetWidth + var widthWithScroll = $inner[0].offsetWidth; // Remove the divs. - $outer.remove() + $outer.remove(); // Return the difference between the widths. return widthWithoutScroll - widthWithScroll @@ -5334,14 +6004,14 @@ PickerConstructor._ = { nodesList = '', // The counter starts from the `min` - counter = PickerConstructor._.trigger( groupObject.min, groupObject ) + counter = PickerConstructor._.trigger(groupObject.min, groupObject); // Loop from the `min` to `max`, incrementing by `i` for ( ; counter <= PickerConstructor._.trigger( groupObject.max, groupObject, [ counter ] ); counter += groupObject.i ) { // Trigger the `item` function within scope of the object - loopObjectScope = PickerConstructor._.trigger( groupObject.item, groupObject, [ counter ] ) + loopObjectScope = PickerConstructor._.trigger(groupObject.item, groupObject, [counter]); // Splice the subgroup and create nodes out of the sub nodes nodesList += PickerConstructor._.node( @@ -5363,16 +6033,16 @@ PickerConstructor._ = { node: function( wrapper, item, klass, attribute ) { // If the item is false-y, just return an empty string - if ( !item ) return '' + if (!item) return ''; // If the item is an array, do a join - item = $.isArray( item ) ? item.join( '' ) : item + item = $.isArray(item) ? item.join('') : item; // Check for the class - klass = klass ? ' class="' + klass + '"' : '' + klass = klass ? ' class="' + klass + '"' : ''; // Check for any attributes - attribute = attribute ? ' ' + attribute : '' + attribute = attribute ? ' ' + attribute : ''; // Return the wrapped item return '<' + wrapper + klass + attribute + '>' + item + '' @@ -5423,7 +6093,7 @@ PickerConstructor._ = { * Create ARIA attribute strings. */ ariaAttr: ariaAttr -} //PickerConstructor._ +}; //PickerConstructor._ @@ -5436,7 +6106,7 @@ PickerConstructor.extend = function( name, Component ) { $.fn[ name ] = function( options, action ) { // Grab the component data. - var componentData = this.data( name ) + var componentData = this.data(name); // If the picker is requested, return the data object. if ( options == 'picker' ) { @@ -5452,16 +6122,16 @@ PickerConstructor.extend = function( name, Component ) { // doesn’t exist, create a new picker using `this` element // and merging the defaults and options with a deep copy. return this.each( function() { - var $this = $( this ) + var $this = $(this); if ( !$this.data( name ) ) { new PickerConstructor( this, name, Component, options ) } }) - } + }; // Set the defaults. $.fn[ name ].defaults = Component.defaults -} //PickerConstructor.extend +}; //PickerConstructor.extend @@ -5485,10 +6155,10 @@ function ariaAttr(attribute, data) { if ( !$.isPlainObject(attribute) ) { attribute = { attribute: data } } - data = '' + data = ''; for ( var key in attribute ) { var attr = (key == 'role' ? '' : 'aria-') + key, - attrVal = attribute[key] + attrVal = attribute[key]; data += attrVal == null ? '' : attr + '="' + attribute[key] + '"' } return data @@ -5510,7 +6180,7 @@ return PickerConstructor })); -;/*! +/*! * Date picker for pickadate.js v3.5.0 * http://amsul.github.io/pickadate.js/date.htm */ @@ -5519,11 +6189,11 @@ return PickerConstructor // AMD. if ( typeof define == 'function' && define.amd ) - define( ['picker', 'jquery'], factory ) + define(['picker', 'jquery'], factory); // Node.js/browserify. else if ( typeof exports == 'object' ) - module.exports = factory( require('./picker.js'), require('jquery') ) + module.exports = factory(require('./picker.js'), require('jquery')); // Browser globals. else factory( Picker, jQuery ) @@ -5536,7 +6206,7 @@ return PickerConstructor */ var DAYS_IN_WEEK = 7, WEEKS_IN_CALENDAR = 6, - _ = Picker._ + _ = Picker._; @@ -5560,10 +6230,10 @@ function DatePicker( picker, settings ) { // For normal browsers. getComputedStyle( picker.$root[0] ).direction == 'rtl' - } + }; - calendar.settings = settings - calendar.$node = picker.$node + calendar.settings = settings; + calendar.$node = picker.$node; // The queue of methods that will be used to build item objects. calendar.queue = { @@ -5575,21 +6245,20 @@ function DatePicker( picker, settings ) { view: 'parse create validate viewset', disable: 'deactivate', enable: 'activate' - } + }; // The component's item object. - calendar.item = {} + calendar.item = {}; - calendar.item.clear = null - calendar.item.disable = ( settings.disable || [] ).slice( 0 ) + calendar.item.clear = null; + calendar.item.disable = (settings.disable || []).slice(0); calendar.item.enable = -(function( collectionDisabled ) { return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1 - })( calendar.item.disable ) + })(calendar.item.disable); calendar. set( 'min', settings.min ). - set( 'max', settings.max ). - set( 'now' ) + set( 'max', settings.max ).set('now'); // When there’s a value, set the `select`, which in turn // also sets the `highlight` and `view`. @@ -5613,37 +6282,37 @@ function DatePicker( picker, settings ) { 37: function() { return isRTL() ? 1 : -1 }, // Left go: function( timeChange ) { var highlightedObject = calendar.item.highlight, - targetDate = new Date( highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange ) + targetDate = new Date(highlightedObject.year, highlightedObject.month, highlightedObject.date + timeChange); calendar.set( 'highlight', targetDate, { interval: timeChange } - ) + ); this.render() } - } + }; // Bind some picker events. picker. on( 'render', function() { picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() { - var value = this.value + var value = this.value; if ( value ) { - picker.set( 'highlight', [ picker.get( 'view' ).year, value, picker.get( 'highlight' ).date ] ) + picker.set('highlight', [picker.get('view').year, value, picker.get('highlight').date]); picker.$root.find( '.' + settings.klass.selectMonth ).trigger( 'focus' ) } - }) + }); picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() { - var value = this.value + var value = this.value; if ( value ) { - picker.set( 'highlight', [ value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] ) + picker.set('highlight', [value, picker.get('view').month, picker.get('highlight').date]); picker.$root.find( '.' + settings.klass.selectYear ).trigger( 'focus' ) } }) }, 1 ). on( 'open', function() { - var includeToday = '' + var includeToday = ''; if ( calendar.disabled( calendar.get('now') ) ) { includeToday = ':not(.' + settings.klass.buttonToday + ')' } @@ -5662,12 +6331,12 @@ function DatePicker( picker, settings ) { DatePicker.prototype.set = function( type, value, options ) { var calendar = this, - calendarItem = calendar.item + calendarItem = calendar.item; // If the value is `null` just set it immediately. if ( value === null ) { - if ( type == 'clear' ) type = 'select' - calendarItem[ type ] = value + if (type == 'clear') type = 'select'; + calendarItem[type] = value; return calendar } @@ -5676,9 +6345,9 @@ DatePicker.prototype.set = function( type, value, options ) { // * In the case of `enable`, keep the queue but set `disable` instead. // And in the case of `flip`, keep the queue but set `enable` instead. calendarItem[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) { - value = calendar[ method ]( type, value, options ) + value = calendar[method](type, value, options); return value - }).pop() + }).pop(); // Check if we need to cascade through more updates. if ( type == 'select' ) { @@ -5697,7 +6366,7 @@ DatePicker.prototype.set = function( type, value, options ) { } return calendar -} //DatePicker.prototype.set +}; //DatePicker.prototype.set /** @@ -5705,7 +6374,7 @@ DatePicker.prototype.set = function( type, value, options ) { */ DatePicker.prototype.get = function( type ) { return this.item[ type ] -} //DatePicker.prototype.get +}; //DatePicker.prototype.get /** @@ -5714,10 +6383,10 @@ DatePicker.prototype.get = function( type ) { DatePicker.prototype.create = function( type, value, options ) { var isInfiniteValue, - calendar = this + calendar = this; // If there’s no value, use the type as the value. - value = value === undefined ? type : value + value = value === undefined ? type : value; // If it’s infinity, update the value. @@ -5733,7 +6402,7 @@ DatePicker.prototype.create = function( type, value, options ) { // If it’s an array, convert it into a date and make sure // that it’s a valid date – otherwise default to today. else if ( $.isArray( value ) ) { - value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] ) + value = new Date(value[0], value[1], value[2]); value = _.isDate( value ) ? value : calendar.create().obj } @@ -5756,7 +6425,7 @@ DatePicker.prototype.create = function( type, value, options ) { obj: isInfiniteValue || value, pick: isInfiniteValue || value.getTime() } -} //DatePicker.prototype.create +}; //DatePicker.prototype.create /** @@ -5771,7 +6440,7 @@ DatePicker.prototype.createRange = function( from, to ) { return calendar.create( date ) } return date - } + }; // Create objects if possible. if ( !_.isInteger( from ) ) { @@ -5793,16 +6462,16 @@ DatePicker.prototype.createRange = function( from, to ) { from: createDate( from ), to: createDate( to ) } -} //DatePicker.prototype.createRange +}; //DatePicker.prototype.createRange /** * Check if a date unit falls within a date range object. */ DatePicker.prototype.withinRange = function( range, dateUnit ) { - range = this.createRange(range.from, range.to) + range = this.createRange(range.from, range.to); return dateUnit.pick >= range.from.pick && dateUnit.pick <= range.to.pick -} +}; /** @@ -5810,27 +6479,27 @@ DatePicker.prototype.withinRange = function( range, dateUnit ) { */ DatePicker.prototype.overlapRanges = function( one, two ) { - var calendar = this + var calendar = this; // Convert the ranges into comparable dates. - one = calendar.createRange( one.from, one.to ) - two = calendar.createRange( two.from, two.to ) + one = calendar.createRange(one.from, one.to); + two = calendar.createRange(two.from, two.to); return calendar.withinRange( one, two.from ) || calendar.withinRange( one, two.to ) || calendar.withinRange( two, one.from ) || calendar.withinRange( two, one.to ) -} +}; /** * Get the date today. */ DatePicker.prototype.now = function( type, value, options ) { - value = new Date() + value = new Date(); if ( options && options.rel ) { value.setDate( value.getDate() + options.rel ) } return this.normalize( value, options ) -} +}; /** @@ -5844,34 +6513,35 @@ DatePicker.prototype.navigate = function( type, value, options ) { targetDate, isTargetArray = $.isArray( value ), isTargetObject = $.isPlainObject( value ), - viewsetObject = this.item.view/*, - safety = 100*/ + viewsetObject = this.item.view; + /*, + safety = 100*/ if ( isTargetArray || isTargetObject ) { if ( isTargetObject ) { - targetYear = value.year - targetMonth = value.month + targetYear = value.year; + targetMonth = value.month; targetDate = value.date } else { - targetYear = +value[0] - targetMonth = +value[1] + targetYear = +value[0]; + targetMonth = +value[1]; targetDate = +value[2] } // If we’re navigating months but the view is in a different // month, navigate to the view’s year and month. if ( options && options.nav && viewsetObject && viewsetObject.month !== targetMonth ) { - targetYear = viewsetObject.year + targetYear = viewsetObject.year; targetMonth = viewsetObject.month } // Figure out the expected target year and month. - targetDateObject = new Date( targetYear, targetMonth + ( options && options.nav ? options.nav : 0 ), 1 ) - targetYear = targetDateObject.getFullYear() - targetMonth = targetDateObject.getMonth() + targetDateObject = new Date(targetYear, targetMonth + (options && options.nav ? options.nav : 0), 1); + targetYear = targetDateObject.getFullYear(); + targetMonth = targetDateObject.getMonth(); // If the month we’re going to doesn’t have enough days, // keep decreasing the date until we reach the month’s last date. @@ -5887,16 +6557,16 @@ DatePicker.prototype.navigate = function( type, value, options ) { } return value -} //DatePicker.prototype.navigate +}; //DatePicker.prototype.navigate /** * Normalize a date by setting the hours to midnight. */ DatePicker.prototype.normalize = function( value/*, options*/ ) { - value.setHours( 0, 0, 0, 0 ) + value.setHours(0, 0, 0, 0); return value -} +}; /** @@ -5904,7 +6574,7 @@ DatePicker.prototype.normalize = function( value/*, options*/ ) { */ DatePicker.prototype.measure = function( type, value/*, options*/ ) { - var calendar = this + var calendar = this; // If it’s anything false-y, remove the limits. if ( !value ) { @@ -5922,7 +6592,7 @@ DatePicker.prototype.measure = function( type, value/*, options*/ ) { } return value -} ///DatePicker.prototype.measure +}; ///DatePicker.prototype.measure /** @@ -5930,7 +6600,7 @@ DatePicker.prototype.measure = function( type, value/*, options*/ ) { */ DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) { return this.create([ dateObject.year, dateObject.month, 1 ]) -} +}; /** @@ -5964,16 +6634,17 @@ DatePicker.prototype.validate = function( type, dateObject, options ) { // If there’s a date, check where it is relative to the target. if ( $.isArray( value ) ) { - var dateTime = calendar.create( value ).pick - if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true + var dateTime = calendar.create(value).pick; + if (dateTime < dateObject.pick) hasEnabledBeforeTarget = true; else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true } // Return only integers for enabled weekdays. return _.isInteger( value ) - }).length/*, + }).length; + /*, - safety = 100*/ + safety = 100*/ @@ -6012,15 +6683,15 @@ DatePicker.prototype.validate = function( type, dateObject, options ) { // If we’ve looped into the next/prev month with a large interval, return to the original date and flatten the interval. if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) { - dateObject = originalDateObject + dateObject = originalDateObject; interval = interval > 0 ? 1 : -1 } // If we’ve reached the min/max limit, reverse the direction, flatten the interval and set it to the limit. if ( dateObject.pick <= minLimitObject.pick ) { - reachedMin = true - interval = 1 + reachedMin = true; + interval = 1; dateObject = calendar.create([ minLimitObject.year, minLimitObject.month, @@ -6028,8 +6699,8 @@ DatePicker.prototype.validate = function( type, dateObject, options ) { ]) } else if ( dateObject.pick >= maxLimitObject.pick ) { - reachedMax = true - interval = -1 + reachedMax = true; + interval = -1; dateObject = calendar.create([ maxLimitObject.year, maxLimitObject.month, @@ -6053,7 +6724,7 @@ DatePicker.prototype.validate = function( type, dateObject, options ) { // Return the date object settled on. return dateObject -} //DatePicker.prototype.validate +}; //DatePicker.prototype.validate /** @@ -6081,13 +6752,13 @@ DatePicker.prototype.disabled = function( dateToVerify ) { if ( $.isPlainObject( dateToDisable ) ) { return calendar.withinRange( dateToDisable, dateToVerify ) } - }) + }); // If this date matches a disabled date, confirm it’s not inverted. isDisabledMatch = isDisabledMatch.length && !isDisabledMatch.filter(function( dateToDisable ) { return $.isArray( dateToDisable ) && dateToDisable[3] == 'inverted' || $.isPlainObject( dateToDisable ) && dateToDisable.inverted - }).length + }).length; // Check the calendar “enabled” flag and respectively flip the // disabled state. Then also check if it’s beyond the min/max limits. @@ -6095,7 +6766,7 @@ DatePicker.prototype.disabled = function( dateToVerify ) { dateToVerify.pick < calendar.item.min.pick || dateToVerify.pick > calendar.item.max.pick -} //DatePicker.prototype.disabled +}; //DatePicker.prototype.disabled /** @@ -6104,7 +6775,7 @@ DatePicker.prototype.disabled = function( dateToVerify ) { DatePicker.prototype.parse = function( type, value, options ) { var calendar = this, - parsingObject = {} + parsingObject = {}; // If it’s already parsed, we’re good. if ( !value || typeof value != 'string' ) { @@ -6113,7 +6784,7 @@ DatePicker.prototype.parse = function( type, value, options ) { // We need a `.format` to parse the value with. if ( !( options && options.format ) ) { - options = options || {} + options = options || {}; options.format = calendar.settings.format } @@ -6126,7 +6797,7 @@ DatePicker.prototype.parse = function( type, value, options ) { // The format length is from the formatting label function or the // label length without the escaping exclamation (!) mark. - formatLength = formattingLabel ? _.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length + formatLength = formattingLabel ? _.trigger(formattingLabel, calendar, [value, parsingObject]) : label.replace(/^!/, '').length; // If there's a format label, split the value up to the format length. // Then add it to the parsing object with appropriate label. @@ -6136,7 +6807,7 @@ DatePicker.prototype.parse = function( type, value, options ) { // Update the value as the substring from format length to end. value = value.substr( formatLength ) - }) + }); // Compensate for month 0index. return [ @@ -6144,7 +6815,7 @@ DatePicker.prototype.parse = function( type, value, options ) { +( parsingObject.mm || parsingObject.m ) - 1, parsingObject.dd || parsingObject.d ] -} //DatePicker.prototype.parse +}; //DatePicker.prototype.parse /** @@ -6156,7 +6827,7 @@ DatePicker.prototype.formats = (function() { function getWordLengthFromCollection( string, collection, dateObject ) { // Grab the first word from the string. - var word = string.match( /\w+/ )[ 0 ] + var word = string.match(/\w+/)[0]; // If there's no month index, add it to the date object if ( !dateObject.mm && !dateObject.m ) { @@ -6212,7 +6883,7 @@ DatePicker.prototype.formats = (function() { }, mmm: function( string, dateObject ) { - var collection = this.settings.monthsShort + var collection = this.settings.monthsShort; // If there's a string, get length of the relevant month from the short // months collection. Otherwise return the selected month from that collection. @@ -6220,7 +6891,7 @@ DatePicker.prototype.formats = (function() { }, mmmm: function( string, dateObject ) { - var collection = this.settings.monthsFull + var collection = this.settings.monthsFull; // If there's a string, get length of the relevant month from the full // months collection. Otherwise return the selected month from that collection. @@ -6244,13 +6915,13 @@ DatePicker.prototype.formats = (function() { // Format an object into a string using the formatting options. toString: function ( formatString, itemObject ) { - var calendar = this + var calendar = this; return calendar.formats.toArray( formatString ).map( function( label ) { return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' ) }).join( '' ) } } -})() //DatePicker.prototype.formats +})(); //DatePicker.prototype.formats @@ -6260,7 +6931,7 @@ DatePicker.prototype.formats = (function() { */ DatePicker.prototype.isDateExact = function( one, two ) { - var calendar = this + var calendar = this; // When we’re working with weekdays, do a direct comparison. if ( @@ -6284,7 +6955,7 @@ DatePicker.prototype.isDateExact = function( one, two ) { } return false -} +}; /** @@ -6293,15 +6964,15 @@ DatePicker.prototype.isDateExact = function( one, two ) { DatePicker.prototype.isDateOverlap = function( one, two ) { var calendar = this, - firstDay = calendar.settings.firstDay ? 1 : 0 + firstDay = calendar.settings.firstDay ? 1 : 0; // When we’re working with a weekday index, compare the days. if ( _.isInteger( one ) && ( _.isDate( two ) || $.isArray( two ) ) ) { - one = one % 7 + firstDay + one = one % 7 + firstDay; return one === calendar.create( two ).day + 1 } if ( _.isInteger( two ) && ( _.isDate( one ) || $.isArray( one ) ) ) { - two = two % 7 + firstDay + two = two % 7 + firstDay; return two === calendar.create( one ).day + 1 } @@ -6311,16 +6982,16 @@ DatePicker.prototype.isDateOverlap = function( one, two ) { } return false -} +}; /** * Flip the “enabled” state. */ DatePicker.prototype.flipEnable = function(val) { - var itemObject = this.item + var itemObject = this.item; itemObject.enable = val || (itemObject.enable == -1 ? 1 : -1) -} +}; /** @@ -6329,7 +7000,7 @@ DatePicker.prototype.flipEnable = function(val) { DatePicker.prototype.deactivate = function( type, datesToDisable ) { var calendar = this, - disabledItems = calendar.item.disable.slice(0) + disabledItems = calendar.item.disable.slice(0); // If we’re flipping, that’s all we need to do. @@ -6338,12 +7009,12 @@ DatePicker.prototype.deactivate = function( type, datesToDisable ) { } else if ( datesToDisable === false ) { - calendar.flipEnable(1) + calendar.flipEnable(1); disabledItems = [] } else if ( datesToDisable === true ) { - calendar.flipEnable(-1) + calendar.flipEnable(-1); disabledItems = [] } @@ -6352,13 +7023,13 @@ DatePicker.prototype.deactivate = function( type, datesToDisable ) { datesToDisable.map(function( unitToDisable ) { - var matchFound + var matchFound; // When we have disabled items, check for matches. // If something is matched, immediately break out. for ( var index = 0; index < disabledItems.length; index += 1 ) { if ( calendar.isDateExact( unitToDisable, disabledItems[index] ) ) { - matchFound = true + matchFound = true; break } } @@ -6379,7 +7050,7 @@ DatePicker.prototype.deactivate = function( type, datesToDisable ) { // Return the updated collection. return disabledItems -} //DatePicker.prototype.deactivate +}; //DatePicker.prototype.deactivate /** @@ -6389,7 +7060,7 @@ DatePicker.prototype.activate = function( type, datesToEnable ) { var calendar = this, disabledItems = calendar.item.disable, - disabledItemsCount = disabledItems.length + disabledItemsCount = disabledItems.length; // If we’re flipping, that’s all we need to do. if ( datesToEnable == 'flip' ) { @@ -6397,12 +7068,12 @@ DatePicker.prototype.activate = function( type, datesToEnable ) { } else if ( datesToEnable === true ) { - calendar.flipEnable(1) + calendar.flipEnable(1); disabledItems = [] } else if ( datesToEnable === false ) { - calendar.flipEnable(-1) + calendar.flipEnable(-1); disabledItems = [] } @@ -6414,28 +7085,28 @@ DatePicker.prototype.activate = function( type, datesToEnable ) { var matchFound, disabledUnit, index, - isExactRange + isExactRange; // Go through the disabled items and try to find a match. for ( index = 0; index < disabledItemsCount; index += 1 ) { - disabledUnit = disabledItems[index] + disabledUnit = disabledItems[index]; // When an exact match is found, remove it from the collection. if ( calendar.isDateExact( disabledUnit, unitToEnable ) ) { - matchFound = disabledItems[index] = null - isExactRange = true + matchFound = disabledItems[index] = null; + isExactRange = true; break } // When an overlapped match is found, add the “inverted” state to it. else if ( calendar.isDateOverlap( disabledUnit, unitToEnable ) ) { if ( $.isPlainObject( unitToEnable ) ) { - unitToEnable.inverted = true + unitToEnable.inverted = true; matchFound = unitToEnable } else if ( $.isArray( unitToEnable ) ) { - matchFound = unitToEnable + matchFound = unitToEnable; if ( !matchFound[3] ) matchFound.push( 'inverted' ) } else if ( _.isDate( unitToEnable ) ) { @@ -6448,7 +7119,7 @@ DatePicker.prototype.activate = function( type, datesToEnable ) { // If a match was found, remove a previous duplicate entry. if ( matchFound ) for ( index = 0; index < disabledItemsCount; index += 1 ) { if ( calendar.isDateExact( disabledItems[index], unitToEnable ) ) { - disabledItems[index] = null + disabledItems[index] = null; break } } @@ -6457,7 +7128,7 @@ DatePicker.prototype.activate = function( type, datesToEnable ) { // make sure there are no “inverted” dates because of it. if ( isExactRange ) for ( index = 0; index < disabledItemsCount; index += 1 ) { if ( calendar.isDateOverlap( disabledItems[index], unitToEnable ) ) { - disabledItems[index] = null + disabledItems[index] = null; break } } @@ -6471,7 +7142,7 @@ DatePicker.prototype.activate = function( type, datesToEnable ) { // Return the updated collection. return disabledItems.filter(function( val ) { return val != null }) -} //DatePicker.prototype.activate +}; //DatePicker.prototype.activate /** @@ -6498,7 +7169,7 @@ DatePicker.prototype.nodes = function( isOpen ) { // If the first day should be Monday, move Sunday to the end. if ( settings.firstDay ) { - collection.push( collection.shift() ) + collection.push(collection.shift()); fullCollection.push( fullCollection.shift() ) } @@ -6555,7 +7226,7 @@ DatePicker.prototype.nodes = function( isOpen ) { //Materialize modified createMonthLabel = function(override) { - var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull + var monthsCollection = settings.showMonthsShort ? settings.monthsShort : settings.monthsFull; // Materialize modified if (override == "short_months") { @@ -6617,7 +7288,7 @@ DatePicker.prototype.nodes = function( isOpen ) { // If years selector is set to a literal "true", set it to 5. Otherwise // divide in half to get half before and half after focused year. - numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 ) + numberYears = settings.selectYears === true ? 5 : ~~(settings.selectYears / 2); // If there are years to select, add a dropdown menu. if ( numberYears ) { @@ -6626,12 +7297,12 @@ DatePicker.prototype.nodes = function( isOpen ) { minYear = minLimitObject.year, maxYear = maxLimitObject.year, lowestYear = focusedYear - numberYears, - highestYear = focusedYear + numberYears + highestYear = focusedYear + numberYears; // If the min year is greater than the lowest year, increase the highest year // by the difference and set the lowest year to the min year. if ( minYear > lowestYear ) { - highestYear += minYear - lowestYear + highestYear += minYear - lowestYear; lowestYear = minYear } @@ -6641,9 +7312,9 @@ DatePicker.prototype.nodes = function( isOpen ) { if ( maxYear < highestYear ) { var availableYears = lowestYear - minYear, - neededYears = highestYear - maxYear + neededYears = highestYear - maxYear; - lowestYear -= availableYears > neededYears ? neededYears : availableYears + lowestYear -= availableYears > neededYears ? neededYears : availableYears; highestYear = maxYear } @@ -6674,19 +7345,19 @@ DatePicker.prototype.nodes = function( isOpen ) { // Materialize modified if (override == "raw") - return _.node( 'div', focusedYear ) + return _.node('div', focusedYear); // Otherwise just return the year focused return _.node( 'div', focusedYear, settings.klass.year ) - } //createYearLabel + }; //createYearLabel // Materialize modified createDayLabel = function() { if (selectedObject != null) - return _.node( 'div', selectedObject.date) + return _.node('div', selectedObject.date); else return _.node( 'div', nowObject.date) - } + }; createWeekdayLabel = function() { var display_day; @@ -6694,9 +7365,9 @@ DatePicker.prototype.nodes = function( isOpen ) { display_day = selectedObject.day; else display_day = nowObject.day; - var weekday = settings.weekdaysFull[ display_day ] + var weekday = settings.weekdaysFull[display_day]; return weekday - } + }; // Create and return the entire calendar. @@ -6747,7 +7418,7 @@ return _.node( item: function( rowCounter ) { // If Monday is the first day and the month starts on Sunday, shift the date back a week. - var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0 + var shiftDateBy = settings.firstDay && calendar.create([viewsetObject.year, viewsetObject.month, 1]).day === 0 ? -7 : 0; return [ _.group({ @@ -6760,12 +7431,12 @@ return _.node( item: function( targetDate ) { // Convert the time date from a relative date to a target date. - targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ]) + targetDate = calendar.create([viewsetObject.year, viewsetObject.month, targetDate + (settings.firstDay ? 1 : 0)]); var isSelected = selectedObject && selectedObject.pick == targetDate.pick, isHighlighted = highlightedObject && highlightedObject.pick == targetDate.pick, isDisabled = disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick, - formattedDate = _.trigger( calendar.formats.toString, calendar, [ settings.format, targetDate ] ) + formattedDate = _.trigger(calendar.formats.toString, calendar, [settings.format, targetDate]); return [ _.node( @@ -6774,7 +7445,7 @@ return _.node( (function( klasses ) { // Add the `infocus` or `outfocus` classes based on month in view. - klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus ) + klasses.push(viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus); // Add the `today` class if needed. if ( nowObject.pick == targetDate.pick ) { @@ -6843,7 +7514,7 @@ return _.node( _.ariaAttr({ controls: calendar.$node[0].id }) ), settings.klass.footer ) //endreturn -} //DatePicker.prototype.nodes +}; //DatePicker.prototype.nodes @@ -6925,7 +7596,7 @@ DatePicker.defaults = (function( prefix ) { buttonClose: prefix + 'button--close' } } -})( Picker.klasses().picker + '__' ) +})(Picker.klasses().picker + '__'); @@ -6940,9 +7611,8 @@ Picker.extend( 'pickadate', DatePicker ) })); -;(function ($) { - - $.fn.characterCounter = function(){ +(function ($) { + $.fn.characterCounter = function () { return this.each(function(){ var $input = $(this); var $counterElement = $input.parent().find('span[class="character-counter"]'); @@ -7012,14 +7682,13 @@ Picker.extend( 'pickadate', DatePicker ) }); }( jQuery )); -;(function ($) { - - var methods = { +(function ($) { + var methods = { init : function(options) { var defaults = { time_constant: 200, // ms - dist: -100, // zoom scale TODO: make this more intuitive as an option + dist: -100, // zoom scale shift: 0, // spacing for center image padding: 0, // Padding between non center items full_width: false, // Change to full width styles diff --git a/Plan/src/main/resources/web/plugins/momentjs/moment.js b/Plan/src/main/resources/web/plugins/momentjs/moment.js index 714b4c441a..a375a9527b 100644 --- a/Plan/src/main/resources/web/plugins/momentjs/moment.js +++ b/Plan/src/main/resources/web/plugins/momentjs/moment.js @@ -873,7 +873,6 @@ this._shortMonthsParse = []; } - // TODO: add sorting // Sorting makes sure if one month (or abbr) is a prefix of another // see sorting in computeMonthsParse for (i = 0; i < 12; i++) { @@ -913,7 +912,6 @@ value = toInt(value); } else { value = mom.localeData().monthsParse(value); - // TODO: Another silent failure? if (typeof value !== 'number') { return mom; } @@ -1756,7 +1754,6 @@ function loadLocale(name) { var oldLocale = null; - // TODO: Find a better way to register and load all the locales in Node if (!locales[name] && (typeof module !== 'undefined') && module && module.exports) { try { @@ -2120,10 +2117,6 @@ dow = 1; doy = 4; - // TODO: We need to take the current isoWeekYear, but that depends on - // how we interpret now (local, utc, fixed offset). So create - // a now version of current config (take local/utc/offset flags, and - // create now). weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year); week = defaults(w.W, 1); weekday = defaults(w.E, 1); @@ -2170,7 +2163,6 @@ // date from string and format string function configFromStringAndFormat(config) { - // TODO: Move this to another part of the creation flow to prevent circular deps if (config._f === utils_hooks__hooks.ISO_8601) { configFromISO(config); return; @@ -2462,7 +2454,6 @@ return res; } - // TODO: Use [].sort instead? function min () { var args = [].slice.call(arguments, 0); @@ -2842,7 +2833,6 @@ } } - // TODO: remove 'name' arg after deprecation is removed function createAdder(direction, name) { return function (val, period) { var dur, tmp; @@ -3924,7 +3914,6 @@ } } - // TODO: Use this.as('ms')? function duration_as__valueOf () { return ( this._milliseconds + From 1c488d50f8a193ca292af1da4af4d18edf8f1767 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 17 Jan 2018 22:39:08 +0200 Subject: [PATCH 028/166] Reduced TODO items allover the code --- .../java/com/djrapitops/plan/api/PlanAPI.java | 2 +- .../connection/NoServersException.java | 5 +-- .../connection/NotFoundException.java | 4 +-- .../connection/TransferDatabaseException.java | 2 +- .../UnauthorizedServerException.java | 3 -- .../UnsupportedTransferDatabaseException.java | 2 +- .../plan/command/commands/AnalyzeCommand.java | 4 +-- .../commands/BungeeSetupToggleCommand.java | 4 ++- .../com/djrapitops/plan/data/HasDate.java | 16 ---------- .../plan/data/container/Action.java | 3 +- .../plan/data/container/GeoInfo.java | 8 +---- .../plan/data/container/PlayerKill.java | 8 +---- .../plan/data/container/Session.java | 8 +---- .../djrapitops/plan/data/container/TPS.java | 3 +- .../plan/system/cache/CacheSystem.java | 2 +- .../plan/system/database/BukkitDBSystem.java | 2 +- .../plan/system/database/BungeeDBSystem.java | 2 +- .../plan/system/database/DBSystem.java | 2 +- .../databases/operation/SaveOperations.java | 4 ++- .../operation/TransferOperations.java | 4 ++- .../databases/sql/operation/SQLSaveOps.java | 11 ++++++- .../sql/processing/ExecStatement.java | 2 +- .../sql/processing/QueryAllStatement.java | 2 +- .../sql/processing/QueryStatement.java | 2 +- .../plan/system/file/FileSystem.java | 2 +- .../plan/system/info/InfoSystem.java | 26 +++++++++++++-- .../system/info/connection/ConnectionOut.java | 10 +++--- .../CacheNetworkPageContentRequest.java | 27 ++++++++++++++++ .../info/NetworkPageUpdateProcessor.java | 12 +++---- .../settings/config/BukkitConfigSystem.java | 4 ++- .../settings/config/BungeeConfigSystem.java | 4 ++- .../system/settings/config/ConfigSystem.java | 7 +++- .../plan/system/tasks/TaskSystem.java | 4 ++- .../system/update/VersionCheckSystem.java | 2 +- .../system/webserver/auth/Authentication.java | 2 +- .../webserver/auth/BasicAuthentication.java | 5 ++- .../system/webserver/auth/FailReason.java | 3 +- .../webserver/pages/DebugPageHandler.java | 2 +- .../webserver/pages/DefaultResponses.java | 2 +- .../system/webserver/pages/PageHandler.java | 5 +-- .../webserver/pages/PlayerPageHandler.java | 21 ++++-------- .../webserver/pages/PlayersPageHandler.java | 2 +- .../webserver/pages/RootPageHandler.java | 7 ++-- .../webserver/pages/TreePageHandler.java | 5 +-- .../webserver/response/ResponseType.java | 2 +- .../plan/system/webserver/webapi/WebAPI.java | 1 + .../info/BungeeInformationManager.java | 5 ++- .../systems/info/parsing/InspectPage.java | 4 +-- .../djrapitops/plan/utilities/Base64Util.java | 2 +- .../djrapitops/plan/utilities/NullCheck.java | 2 +- .../comparators/HasDateComparator.java | 32 ------------------- .../html/graphs/ActivityStackGraph.java | 4 ++- .../html/graphs/pie/ActivityPie.java | 2 +- .../InspectPluginsTabContentCreator.java | 2 +- .../structure/ServerAccordionCreator.java | 2 +- .../structure/SessionTabStructureCreator.java | 2 +- ...eCreator.java => GeoInfoTableCreator.java} | 7 ++-- .../html/tables/SessionsTableCreator.java | 2 +- .../plan/utilities/metrics/BStats.java | 2 -- .../plan/data/PlayerProfileTest.java | 5 --- .../com/djrapitops/plan/data/SessionTest.java | 2 ++ .../djrapitops/plan/data/UserInfoTest.java | 1 + .../plan/data/cache/SessionCacheTest.java | 2 ++ .../plan/system/webserver/WebServerTest.java | 5 --- 64 files changed, 167 insertions(+), 176 deletions(-) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/data/HasDate.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java rename Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/{IpTableCreator.java => GeoInfoTableCreator.java} (91%) diff --git a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java index 568cd5463e..851ed49bee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java @@ -11,7 +11,7 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Interface for PlanAPI methods. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java index 44ecbdc878..3f57119b46 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NoServersException.java @@ -5,15 +5,12 @@ package com.djrapitops.plan.api.exceptions.connection; /** - * //TODO Class Javadoc Comment + * Thrown when ConnectionSystem can not find any servers to send request to. * * @author Rsl1122 */ public class NoServersException extends WebException { - public NoServersException() { - } - public NoServersException(String message) { super(message); } diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NotFoundException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NotFoundException.java index 2f73fdd48f..2c817ef8f2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NotFoundException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/NotFoundException.java @@ -10,7 +10,7 @@ * @author Rsl1122 */ public class NotFoundException extends WebFailException { - public NotFoundException() { - super("Not Found"); + public NotFoundException(String message) { + super(message); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java index b4f17cd9af..68fae09d67 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/TransferDatabaseException.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; /** - * //TODO Class Javadoc Comment + * Thrown when DBException occurs during InfoRequest#placeIntoDatabase. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnauthorizedServerException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnauthorizedServerException.java index 4bd725a46b..2e6db01b97 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnauthorizedServerException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnauthorizedServerException.java @@ -11,9 +11,6 @@ */ public class UnauthorizedServerException extends WebFailException { - public UnauthorizedServerException() { - } - public UnauthorizedServerException(String message) { super(message); } diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java index ef66b6d896..5ce6cdb089 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/UnsupportedTransferDatabaseException.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.system.database.databases.Database; /** - * //TODO Class Javadoc Comment + * Exception thrown when calling Database#transfer and Database implementation doesn't support it. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 14d611ef7a..4c895ba3b8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -4,9 +4,9 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; @@ -83,8 +83,6 @@ public String[] addHelp() { @Override public boolean onCommand(ISender sender, String commandLabel, String[] args) { - // TODO Write a command for listing servers. - UUID serverUUID = Plan.getServerUUID(); if (args.length >= 1 && plugin.getInfoManager().isUsingAnotherWebServer()) { try { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java index 90e532e9a8..a267e56d59 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java @@ -11,7 +11,9 @@ import com.djrapitops.plugin.command.SubCommand; /** - * //TODO Class Javadoc Comment + * Command for Toggling whether or not BungeeCord accepts set up requests. + * + * This was added as a security measure against unwanted MySQL snooping. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/data/HasDate.java b/Plan/src/main/java/com/djrapitops/plan/data/HasDate.java deleted file mode 100644 index 1c19a76f65..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/data/HasDate.java +++ /dev/null @@ -1,16 +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.data; - -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ -public interface HasDate { - - long getDate(); - -} diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java index 2f4b16f705..ba81aba452 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Action.java @@ -5,7 +5,6 @@ package com.djrapitops.plan.data.container; import com.djrapitops.plan.data.Actions; -import com.djrapitops.plan.data.HasDate; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.html.Html; @@ -16,7 +15,7 @@ * * @author Rsl1122 */ -public class Action implements HasDate { +public class Action { private final long date; private final Actions doneAction; private final String additionalInfo; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java b/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java index 773c0e1fb0..f34bf5f21c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/GeoInfo.java @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.data.container; -import com.djrapitops.plan.data.HasDate; import com.google.common.base.Objects; /** @@ -12,7 +11,7 @@ * * @author Rsl1122 */ -public class GeoInfo implements HasDate { +public class GeoInfo { private final String ip; private final String geolocation; @@ -36,11 +35,6 @@ public long getLastUsed() { return lastUsed; } - @Override - public long getDate() { - return getLastUsed(); - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java index 1318c5b212..56b9c7836b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java @@ -2,7 +2,6 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.Actions; -import com.djrapitops.plan.data.HasDate; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Objects; @@ -14,7 +13,7 @@ * * @author Rsl1122 */ -public class PlayerKill implements HasDate { +public class PlayerKill { private final UUID victim; private final long time; @@ -51,11 +50,6 @@ public long getTime() { return time; } - @Override - public long getDate() { - return getTime(); - } - /** * Get the Weapon used as string. * diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java index 7a802d477e..8b265b7058 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.data.container; -import com.djrapitops.plan.data.HasDate; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.utilities.MiscUtils; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -28,7 +27,7 @@ * * @author Rsl1122 */ -public class Session implements HasDate { +public class Session { private final long sessionStart; private Integer sessionID; @@ -217,9 +216,4 @@ public String toString() { .append("deaths", deaths) .toString(); } - - @Override - public long getDate() { - return getSessionStart(); - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java b/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java index 753e94712a..c211375814 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java @@ -5,7 +5,6 @@ */ package com.djrapitops.plan.data.container; -import com.djrapitops.plan.data.HasDate; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Objects; @@ -16,7 +15,7 @@ * @author Rsl1122 * @since 3.5.0 */ -public class TPS implements HasDate { +public class TPS { private final long date; private final double ticksPerSecond; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java index e8545317c4..7d578ed843 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java @@ -14,7 +14,7 @@ import java.net.UnknownHostException; /** - * //TODO Class Javadoc Comment + * System that holds data caches of the plugin. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java index d092cafcea..773a7d5d5c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.settings.Settings; /** - * //TODO Class Javadoc Comment + * Bukkit Database system that initializes SQLite and MySQL database objects. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java index cecdffae2e..36da79755f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BungeeDBSystem.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.system.database.databases.sql.MySQLDB; /** - * //TODO Class Javadoc Comment + * Bungee Database system that initializes MySQL object. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index 511b6df65a..655bbf289b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -21,7 +21,7 @@ import java.util.Set; /** - * //TODO Class Javadoc Comment + * System that holds the active databases. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java index e450704567..d3c4372162 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java @@ -12,7 +12,9 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Operation methods for saving data. + * + * Note: Method names subject to change (TODO remove insert update and such) * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index 3d7ed1d0ed..06be95d0d7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -10,7 +10,9 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Operations for transferring data via Database to another server. + * + * Receiving server has to be using the same database. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java index 6f0e9add4b..57f3148d07 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java @@ -16,7 +16,7 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * SaveOperations implementation for SQL databases. * * @author Rsl1122 */ @@ -196,4 +196,13 @@ public void insertTPSforThisServer(TPS tps) throws DBException { throw ErrorUtil.getExceptionFor(e); } } + + @Override + public void session(UUID uuid, Session session) throws DBException { + try { + sessionsTable.saveSession(uuid, session); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java index 5f843523df..51ff3a6ac8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/ExecStatement.java @@ -11,7 +11,7 @@ import java.sql.SQLException; /** - * //TODO Class Javadoc Comment + * SQL executing statement that closes appropriate elements. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryAllStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryAllStatement.java index 563b6191ee..c552b1a74c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryAllStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryAllStatement.java @@ -9,7 +9,7 @@ import java.sql.SQLException; /** - * //TODO Class Javadoc Comment + * SQL query that doesn't require preparing that closes proper elements. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java index 0e7c4ad089..675864c9d9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/processing/QueryStatement.java @@ -12,7 +12,7 @@ import java.sql.SQLException; /** - * //TODO Class Javadoc Comment + * SQL query that closes proper elements. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/file/FileSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/file/FileSystem.java index 45bfd90755..d2662ade5e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/file/FileSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/file/FileSystem.java @@ -15,7 +15,7 @@ import java.util.List; /** - * //TODO Class Javadoc Comment + * Abstracts File methods of Plugin classes so that they can be tested without Mocks. * * @author Rsl1122 */ 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 3d636744d8..07ad5d55cf 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 @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem; @@ -14,12 +14,19 @@ 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; +interface ExceptionLoggingAction { + + void performAction() throws WebException; + +} + /** * Information management system. - * + *

* Subclasses should decide how InfoRequests are run locally if necessary. * * @author Rsl1122 @@ -38,7 +45,7 @@ public static InfoSystem getInstance() { return infoSystem; } - public void generatePlayerPage(UUID player) throws WebException { + public void generateAndCachePlayerPage(UUID player) throws WebException { sendRequest(new GenerateInspectPageRequest(player)); } @@ -77,4 +84,17 @@ public void disable() { public ConnectionSystem getConnectionSystem() { return connectionSystem; } + + public abstract void updateNetworkPage(); + + public void handlePossibleException(ExceptionLoggingAction action) { + try { + action.performAction(); + } catch (ConnectionFailException | UnsupportedTransferDatabaseException | UnauthorizedServerException + | NotFoundException | NoServersException e) { + Log.warn(e.getMessage()); + } catch (WebException e) { + Log.toLog(this.getClass().getName(), e); + } + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index 92547313aa..d9bec9430c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -117,13 +117,13 @@ public void sendRequest() throws WebException { case 200: return; case 400: - throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters); + throw new WebFailException("Bad Request: " + url.toString() + " | " + parameters); case 403: - throw new ForbiddenException(url.toString()); + throw new ForbiddenException(url.toString() + " returned 403, this is not supposed to happen."); case 404: - throw new NotFoundException(); + throw new NotFoundException(url.toString() + " returned a 404, ensure that your server is connected to an up to date Plan server."); case 412: - throw new UnauthorizedServerException(); + throw new UnauthorizedServerException(url.toString() + " reported that it does not recognize this server. Make sure '/plan m setup' was successful."); case 500: throw new InternalErrorException(); default: @@ -135,7 +135,7 @@ public void sendRequest() throws WebException { if (Settings.DEV_MODE.isTrue()) { Log.toLog(this.getClass().getName(), e); } - throw new ConnectionFailException("Connection failed. address: " + address, e); + throw new ConnectionFailException("Connection failed to address: " + address, e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java new file mode 100644 index 0000000000..28a4629d6f --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java @@ -0,0 +1,27 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.Map; + +/** + * InfoRequest for caching Network page parts to ResponseCache of receiving server. + * + * @author Rsl1122 + */ +public class CacheNetworkPageContentRequest implements InfoRequest { + + @Override + public void placeDataToDatabase() { + // TODO + } + + @Override + public Response handleRequest(Map variables) { + return null; // TODO + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java index a0c879c538..6f10690c70 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java @@ -4,22 +4,22 @@ */ package com.djrapitops.plan.system.processing.processors.info; +import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.processing.processors.Processor; -import com.djrapitops.plan.systems.info.InformationManager; /** - * //TODO Class Javadoc Comment + * Processor for updating the network page. * * @author Rsl1122 */ -public class NetworkPageUpdateProcessor extends Processor { +public class NetworkPageUpdateProcessor extends Processor { - public NetworkPageUpdateProcessor(InformationManager object) { - super(object); + public NetworkPageUpdateProcessor() { + super(null); } @Override public void process() { - object.updateNetworkPageContent(); + InfoSystem.getInstance().updateNetworkPage(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java index 509141b312..c9d9f68499 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BukkitConfigSystem.java @@ -9,7 +9,9 @@ import java.io.IOException; /** - * //TODO Class Javadoc Comment + * ConfigSystem for Bukkit. + *

+ * Bukkit and Bungee have different default config file inside the jar. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java index 2b0d31671e..f7efdf6ac2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/BungeeConfigSystem.java @@ -9,7 +9,9 @@ import java.io.IOException; /** - * //TODO Class Javadoc Comment + * ConfigSystem for Bungee. + *

+ * Bukkit and Bungee have different default config file inside the jar. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index b58d7e3565..a35dad71be 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -17,7 +17,7 @@ import java.io.IOException; /** - * //TODO Class Javadoc Comment + * System for Config and other user customizable options. * * @author Rsl1122 */ @@ -59,6 +59,11 @@ public void enable() throws EnableException { theme.enable(); } + /** + * Copies default values from file in jar to Config. + * + * @throws IOException + */ protected abstract void copyDefaults() throws IOException; @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java index 8cc02c0863..6e237124b9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java @@ -13,7 +13,9 @@ import com.djrapitops.plugin.task.RunnableFactory; /** - * //TODO Class Javadoc Comment + * TaskSystem that registers tasks that were previously registered inside Plugin classes. + * + * Subclasses register actual tasks. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java index 74498d6ef6..143168280b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java @@ -15,7 +15,7 @@ import java.io.IOException; /** - * //TODO Class Javadoc Comment + * System for checking if new Version is available when the System initializes. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java index 6e509c03ee..e07a6ca632 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/Authentication.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.data.WebUser; /** - * //TODO Class Javadoc Comment + * Interface for different WebUser authentication methods used by Requests. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java index 50d5dc5d83..73e0d92970 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java @@ -13,7 +13,10 @@ import com.djrapitops.plan.utilities.PassEncryptUtil; /** - * //TODO Class Javadoc Comment + * Authentication handling for Basic Auth. + * + * Basic access authentication (Wikipedia): + * https://en.wikipedia.org/wiki/Basic_access_authentication * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java index 2aa60d224f..44f522db8d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/FailReason.java @@ -5,9 +5,10 @@ package com.djrapitops.plan.system.webserver.auth; /** - * //TODO Class Javadoc Comment + * Reason for WebUserAuthException. * * @author Rsl1122 + * @see com.djrapitops.plan.api.exceptions.WebUserAuthException */ public enum FailReason { USER_AND_PASS_NOT_SPECIFIED("User and Password not specified"), diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java index f37386b72f..6a4176c480 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DebugPageHandler.java @@ -14,7 +14,7 @@ import java.util.List; /** - * //TODO Class Javadoc Comment + * PageHandler for /debug page. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java index 672447925f..f4f031a3f0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; /** - * //TODO Class Javadoc Comment + * Enum containing default responses that don't need to be cached because they're always the same. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java index 3a8d80ee35..0bcdea3f42 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PageHandler.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.webserver.pages; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.response.Response; @@ -12,7 +13,7 @@ import java.util.List; /** - * //TODO Class Javadoc Comment + * PageHandlers are used for easier Response management and authorization checking. * * @author Rsl1122 */ @@ -25,7 +26,7 @@ public abstract class PageHandler { * @param target Rest of the target coordinates after this page has been solved. * @return Response appropriate to the PageHandler. */ - public abstract Response getResponse(Request request, List target); + public abstract Response getResponse(Request request, List target) throws WebException; public boolean isAuthorized(Authentication auth, List target) throws WebUserAuthException { return true; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java index cb2e5b28fc..fcfe472e6b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java @@ -4,18 +4,17 @@ */ package com.djrapitops.plan.system.webserver.pages; -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; 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.errors.InternalErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import com.djrapitops.plan.utilities.uuid.UUIDUtility; @@ -25,14 +24,14 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * PageHandler for /player/PlayerName pages. * * @author Rsl1122 */ public class PlayerPageHandler extends PageHandler { @Override - public Response getResponse(Request request, List target) { + public Response getResponse(Request request, List target) throws WebException { if (target.isEmpty()) { return DefaultResponses.NOT_FOUND.get(); } @@ -46,17 +45,9 @@ public Response getResponse(Request request, List target) { try { if (Database.getActive().check().isPlayerRegistered(uuid)) { - PlanPlugin.getInstance().getInfoManager().cachePlayer(uuid); Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); - // TODO Create a new method that places NotFoundResponse to ResponseCache instead. - if (response == null || response.getContent().contains("No Bukkit Servers were online to process this request")) { - ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> { - try { - return new InspectPageResponse(PlanPlugin.getInstance().getInfoManager(), uuid); - } catch (ParseException e) { - return new InternalErrorResponse(e, this.getClass().getName()); - } - }); + if (response == null || !(response instanceof InspectPageResponse)) { + InfoSystem.getInstance().generateAndCachePlayerPage(uuid); response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); } return response; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java index 34ad7a2484..a36a19027e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayersPageHandler.java @@ -15,7 +15,7 @@ import java.util.List; /** - * //TODO Class Javadoc Comment + * PageHandler for /players page. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java index cdae932fe5..9034bc20eb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.webserver.pages; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.ResponseHandler; @@ -18,7 +19,9 @@ import java.util.Optional; /** - * //TODO Class Javadoc Comment + * PageHandler for / page (Address root). + * + * Not Available if Authentication is not enabled. * * @author Rsl1122 */ @@ -31,7 +34,7 @@ public RootPageHandler(ResponseHandler responseHandler) { } @Override - public Response getResponse(Request request, List target) { + public Response getResponse(Request request, List target) throws WebException { Optional auth = request.getAuth(); if (!auth.isPresent()) { return DefaultResponses.BASIC_AUTH.get(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java index 9bd17f77d3..6d22c79b2c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.webserver.pages; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.response.Response; @@ -14,7 +15,7 @@ import java.util.Map; /** - * //TODO Class Javadoc Comment + * Abstract PageHandler that allows Tree-like target deduction. * * @author Rsl1122 */ @@ -45,7 +46,7 @@ public boolean isAuthorized(Authentication auth, List target) throws Web } @Override - public Response getResponse(Request request, List target) { + public Response getResponse(Request request, List target) throws WebException { PageHandler pageHandler = getPageHandler(target); return pageHandler != null ? pageHandler.getResponse(request, target) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java index a9d61c57a1..c12f2b6157 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/ResponseType.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.response; /** - * //TODO Class Javadoc Comment + * Enum for HTTP content-type response header Strings. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index 8ad5657ace..47be80f0ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -33,6 +33,7 @@ /** * @author Rsl1122 */ +@Deprecated public abstract class WebAPI { private static TrustManager[] trustAllCerts = new TrustManager[]{ 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 index c366f26447..fa560f0464 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -11,6 +11,8 @@ import com.djrapitops.plan.api.exceptions.connection.NotFoundException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.info.server.BungeeServerInfoManager; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.PageId; @@ -26,8 +28,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI; import com.djrapitops.plan.systems.info.parsing.NetworkPage; -import com.djrapitops.plan.system.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plugin.api.utility.log.ErrorLogger; @@ -387,7 +387,6 @@ public void sendConfigSettings() { @Override public TreeMap> getErrors() throws IOException { - // TODO Request Bukkit servers for errors return ErrorLogger.getLoggedErrors(plugin); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java index 0d5b446511..36608b4eee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java @@ -29,7 +29,7 @@ import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie; import com.djrapitops.plan.utilities.html.structure.ServerAccordionCreator; import com.djrapitops.plan.utilities.html.tables.ActionsTableCreator; -import com.djrapitops.plan.utilities.html.tables.IpTableCreator; +import com.djrapitops.plan.utilities.html.tables.GeoInfoTableCreator; import com.djrapitops.plan.utilities.html.tables.NicknameTableCreator; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.TimeAmount; @@ -117,7 +117,7 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown"); addValue("tableBodyNicknames", NicknameTableCreator.createTable(profile.getNicknames(), serverNames)); - addValue("tableBodyIPs", IpTableCreator.createTable(profile.getGeoInformation())); + addValue("tableBodyIPs", GeoInfoTableCreator.createTable(profile.getGeoInformation())); Map> sessions = profile.getSessions(); Map> sessionsByServerName = sessions.entrySet().stream() diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java b/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java index 52ea958f7b..8ecdfa3856 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java @@ -7,7 +7,7 @@ import java.util.Base64; /** - * //TODO Class Javadoc Comment + * Utility for performing Base64 operations. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java b/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java index fc7de19efe..fc35dece73 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/NullCheck.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.utilities; /** - * //TODO Class Javadoc Comment + * Utility class for performing actions if something is null. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java deleted file mode 100644 index 4f271db59f..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/HasDateComparator.java +++ /dev/null @@ -1,32 +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.utilities.comparators; - -import com.djrapitops.plan.data.HasDate; - -import java.util.Comparator; - -/** - * Comparator for HasDate interface Objects. - * - * @author Rsl1122 - */ -public class HasDateComparator implements Comparator { - - private final boolean reversed; - - public HasDateComparator() { - this(false); - } - - public HasDateComparator(boolean reversed) { - this.reversed = reversed; - } - - @Override - public int compare(HasDate o1, HasDate o2) { - return (reversed ? -1 : 1) * Long.compare(o1.getDate(), o2.getDate()); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java index 77a8fd1445..c60c38d44b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java @@ -15,7 +15,9 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * Graph creation utility for Activity Stack graph. + * + * This graph represents evolution of the playerbase. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java index 6ed0d2bf38..944a4c8a24 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java @@ -10,7 +10,7 @@ import java.util.*; /** - * //TODO Class Javadoc Comment + * Utility class for creating Activity Pie data. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java index f32cba8bef..b7b1ed8adc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java @@ -15,7 +15,7 @@ import java.util.Map; /** - * //TODO Class Javadoc Comment + * HTML utility class for parsing HTML for Inspect page plugins tabs. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java index df1ec82cfd..7c87b27eb0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java @@ -20,7 +20,7 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * HTML utility class for creating a Session Accordion. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index a9406871e3..df8e118f09 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -26,7 +26,7 @@ import java.util.UUID; /** - * //TODO Class Javadoc Comment + * HTML utility class used for creating main element on Sessions tabs. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/IpTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTableCreator.java similarity index 91% rename from Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/IpTableCreator.java rename to Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTableCreator.java index a39757ea64..02ba41c314 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/IpTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTableCreator.java @@ -16,10 +16,9 @@ * * @author Rsl1122 */ -public class IpTableCreator { +public class GeoInfoTableCreator { - - public IpTableCreator() { + public GeoInfoTableCreator() { throw new IllegalStateException("Utility class"); } @@ -30,7 +29,7 @@ public static String createTable(List geoInfo) { html.append(Html.TABLELINE_3.parse("No Connections", "-", "-")); } else { for (GeoInfo info : geoInfo) { - long date = info.getDate(); + long date = info.getLastUsed(); html.append(Html.TABLELINE_3.parse( FormatUtils.formatIP(info.getIp()), info.getGeolocation(), diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index 1d54b69bbb..0895b23557 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; /** - * //TODO Class Javadoc Comment + * Utility for creating HTML {@code }-element with Sessions inside it. * * @author Rsl1122 */ 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 e9e799cc78..1f5591dfea 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 @@ -27,8 +27,6 @@ public void registerMetrics() { } private void registerConfigSettingGraphs() { - // TODO Write a Module bar graph - String serverType = plugin.getServer().getName(); if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) { serverType = "Spigot"; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java b/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java index 3152f32805..afb4124035 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java @@ -18,11 +18,6 @@ import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.assertTrue; -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ @RunWith(PowerMockRunner.class) @PrepareForTest(JavaPlugin.class) public class PlayerProfileTest { diff --git a/Plan/test/main/java/com/djrapitops/plan/data/SessionTest.java b/Plan/test/main/java/com/djrapitops/plan/data/SessionTest.java index 554a5f9883..02396a7c18 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/SessionTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/SessionTest.java @@ -7,10 +7,12 @@ import com.djrapitops.plan.data.container.Session; import org.junit.Before; +import org.junit.Ignore; /** * @author Rsl1122 */ +@Ignore public class SessionTest { private Session session; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/UserInfoTest.java b/Plan/test/main/java/com/djrapitops/plan/data/UserInfoTest.java index ab526a3f41..cb6dc380d3 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/UserInfoTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/UserInfoTest.java @@ -29,6 +29,7 @@ public void setUp() throws Exception { } @Test + @Ignore public void test() { // TODO Rewrite } diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java index 6616e0d2b4..14690a4067 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.system.cache.SessionCache; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -29,6 +30,7 @@ public void setUp() throws Exception { } @Test + @Ignore public void test() { // TODO Rewrite } diff --git a/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java b/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java index 7887e2c15a..5c4cb062e5 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java @@ -14,11 +14,6 @@ import java.io.IOException; import java.util.HashMap; -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ @RunWith(PowerMockRunner.class) @PrepareForTest({JavaPlugin.class}) public class WebServerTest { From 027db58a0a380ec6e15bca96947d5cab7fbe4808 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 18 Jan 2018 11:59:39 +0200 Subject: [PATCH 029/166] Added deprecated API class to main.java.com.djrapitops.plan --- .../main/java/com/djrapitops/plan/Plan.java | 29 +++++++++++++++++ .../java}/com/djrapitops/plan/api/API.java | 31 ++++++++++++++----- 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java rename Plan/src/main/java/{ => main/java}/com/djrapitops/plan/api/API.java (92%) diff --git a/Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java new file mode 100644 index 0000000000..3562f21bfd --- /dev/null +++ b/Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java @@ -0,0 +1,29 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package main.java.com.djrapitops.plan; + +import main.java.com.djrapitops.plan.api.API; + +/** + * Older package version of Plan. + * + * @author Rsl1122 + * @deprecated Use com.djrapitops.plan.Plan instead. + */ +@Deprecated +public class Plan { + + /** + * Old method for getting old API. + * + * @return new instance of the old API object to not break old API. + * @deprecated Use PlanAPI.getInstance() instead as new API. + */ + @Deprecated + public static API getPlanAPI() { + return new API(com.djrapitops.plan.Plan.getInstance()); + } + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/API.java b/Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java similarity index 92% rename from Plan/src/main/java/com/djrapitops/plan/api/API.java rename to Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java index 82bb40bcf8..bd00d1fe42 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/API.java +++ b/Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.api; +package main.java.com.djrapitops.plan.api; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.ParseException; @@ -8,6 +8,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.utilities.uuid.UUIDUtility; +import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; import org.bukkit.OfflinePlayer; @@ -24,15 +25,14 @@ * Methods can be called from Asynchronous task and are thread safe unless * otherwise stated. *

- * Use Plan.getPlanAPI() to get the API. - *

* More information about API methods can be found on GitHub. * * @author Rsl1122 * @see PluginData - * @see AnalysisType * @since 4.0.0 + * @deprecated Old version of Plan API, use PlanAPI.getInstance() instead. */ +@Deprecated public class API { private final Plan plugin; @@ -51,6 +51,7 @@ public API(Plan plugin) { * * @return true if plugin is enabled correctly. */ + @Deprecated public boolean isEnabled() { return plugin.isEnabled(); } @@ -66,6 +67,7 @@ public boolean isEnabled() { * Analysis and Inspect to manage the data of a plugin correctly. * @see PluginData */ + @Deprecated public void addPluginDataSource(PluginData dataSource) { if (isEnabled()) { plugin.getHookHandler().addPluginDataSource(dataSource); @@ -84,6 +86,7 @@ public void addPluginDataSource(PluginData dataSource) { * @param name Name of the player * @return {@code ../player/PlayerName} */ + @Deprecated public String getPlayerInspectPageLink(String name) { if (name == null) { return "#"; @@ -112,6 +115,7 @@ public boolean isPlayersDataInspectCached(UUID uuid) { * @param uuid UUID of the player. * @return true/false */ + @Deprecated public boolean isPlayerHtmlCached(UUID uuid) { return plugin.getInfoManager().isCached(uuid); } @@ -136,6 +140,7 @@ public void cacheUserDataToInspectCache(UUID uuid) { * @param uuid UUID of the player. * @deprecated use {@code cachePlayerHtml} */ + @Deprecated public void cachePlayerHtml(UUID uuid) { plugin.getInfoManager().cachePlayer(uuid); } @@ -148,6 +153,7 @@ public void cachePlayerHtml(UUID uuid) { * @param uuid UUID of the player. * @return player.html with all placeholders replaced. */ + @Deprecated public String getPlayerHtmlAsString(UUID uuid) throws ParseException { return plugin.getInfoManager().getPlayerHtml(uuid); } @@ -157,6 +163,7 @@ public String getPlayerHtmlAsString(UUID uuid) throws ParseException { * * @return true/false */ + @Deprecated public boolean isAnalysisCached() { return plugin.getInfoManager().isAnalysisCached(Plan.getServerUUID()); } @@ -164,6 +171,7 @@ public boolean isAnalysisCached() { /** * Run the analysis. */ + @Deprecated public void updateAnalysisCache() { plugin.getInfoManager().refreshAnalysis(plugin.getServerUuid()); } @@ -176,6 +184,7 @@ public void updateAnalysisCache() { * @return server.html with all placeholders replaced. * @throws NullPointerException if AnalysisData has not been cached. */ + @Deprecated public String getAnalysisHtmlAsString() { return plugin.getInfoManager().getAnalysisHtml(); } @@ -188,6 +197,7 @@ public String getAnalysisHtmlAsString() { * @return AnalysisData object. * @see AnalysisData */ + @Deprecated public AnalysisData getAnalysisDataFromCache() { return ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisData(); } @@ -201,11 +211,16 @@ public AnalysisData getAnalysisDataFromCache() { * @throws IllegalArgumentException If uuid is null. * @throws IllegalStateException If the player has not played on the server before. */ + @Deprecated public String getPlayerName(UUID uuid) { Verify.nullCheck(uuid); - String playerName = plugin.getDB().getUsersTable().getPlayerName(uuid); - if (playerName != null) { - return playerName; + try { + String playerName = Database.getActive().fetch().getPlayerName(uuid); + if (playerName != null) { + return playerName; + } + } catch (DBException e) { + Log.toLog(API.class, e); } OfflinePlayer offlinePlayer = getOfflinePlayer(uuid); if (offlinePlayer != null) { @@ -234,6 +249,7 @@ public UUID PlayerNameToUUID(String playerName) { * @return UUID of the Player * @throws IllegalArgumentException if player's name is not registered at Mojang */ + @Deprecated public UUID playerNameToUUID(String playerName) { UUID uuid = UUIDUtility.getUUIDOf(playerName); if (uuid == null) { @@ -251,6 +267,7 @@ public UUID playerNameToUUID(String playerName) { * @throws SQLException If database error occurs. * @since 3.4.2 */ + @Deprecated public Collection getSavedUUIDs() { try { return Database.getActive().fetch().getSavedUUIDs(); From f5f488f16ae7b61bb1a663888ee85a907c940454 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 18 Jan 2018 12:17:56 +0200 Subject: [PATCH 030/166] Implemented CacheNetworkPageContentRequest --- .../operation/TransferOperations.java | 4 ++ .../CacheNetworkPageContentRequest.java | 54 +++++++++++++++++-- .../webserver/response/cache/PageId.java | 3 +- .../pages/parts/NetworkPageContent.java | 50 +++++++++++++++++ 4 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index 06be95d0d7..3970add48c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -25,4 +25,8 @@ public interface TransferOperations { // Get Map getPlayerHtml() throws DBException; + + void networkPageContent(UUID serverUUID, String html) throws DBException; + + Map getNetworkPageContent() throws DBException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java index 28a4629d6f..c203705d9b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java @@ -4,9 +4,19 @@ */ package com.djrapitops.plan.system.info.request; +import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.webserver.pages.DefaultResponses; 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.parts.NetworkPageContent; import java.util.Map; +import java.util.UUID; /** * InfoRequest for caching Network page parts to ResponseCache of receiving server. @@ -15,13 +25,49 @@ */ public class CacheNetworkPageContentRequest implements InfoRequest { + private final UUID serverUUID; + private final String html; + + public CacheNetworkPageContentRequest(UUID serverUUID, String html) { + this.serverUUID = serverUUID; + this.html = html; + } + @Override - public void placeDataToDatabase() { - // TODO + public void placeDataToDatabase() throws WebException { + try { + Database.getActive().transfer().networkPageContent(serverUUID, html); + } catch (DBException e) { + throw new TransferDatabaseException(e); + } } @Override - public Response handleRequest(Map variables) { - return null; // TODO + public Response handleRequest(Map variables) throws WebException { + // Available variables: sender + + Map networkPageHtml; + Map serverNames; + try { + Database database = Database.getActive(); + networkPageHtml = database.transfer().getNetworkPageContent(); + serverNames = database.fetch().getServerNames(); + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + + for (Map.Entry entry : networkPageHtml.entrySet()) { + UUID serverUUID = entry.getKey(); + String serverName = serverNames.getOrDefault(serverUUID, "Unknown"); + String html = entry.getValue(); + + NetworkPageContent response = (NetworkPageContent) + ResponseCache.loadResponse(PageId.NETWORK_CONTENT.of(serverUUID), NetworkPageContent::new); + response.addElement(serverName, html); + } + + InfoSystem.getInstance().updateNetworkPage(); + + return DefaultResponses.SUCCESS.get(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java index a2ea23ad2c..f44ce33b15 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java @@ -29,7 +29,8 @@ public enum PageId { FAVICON_REDIRECT("Redirect:Favicon"), AUTH_PROMPT("PromptAuth"), // - PLAYER_PLUGINS_TAB("playerPluginsTab:"); + PLAYER_PLUGINS_TAB("playerPluginsTab:"), + NETWORK_CONTENT("networkContent:"); private final String id; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java new file mode 100644 index 0000000000..bd303067ac --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java @@ -0,0 +1,50 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package com.djrapitops.plan.system.webserver.response.pages.parts; + +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.*; + +/** + * Represents Servers tab content of Network page. + *

+ * Extends Response so that it can be stored in ResponseCache. + * + * @author Rsl1122 + */ +public class NetworkPageContent extends Response { + + private final Map content; + + public NetworkPageContent() { + content = new HashMap<>(); + } + + public NetworkPageContent(String serverName, String html) { + this(); + content.put(serverName, html); + } + + public void addElement(String serverName, String html) { + content.put(serverName, html); + } + + public String getContents() { + if (content.isEmpty()) { + return ""; // TODO "No Servers" + } + + List serverNames = new ArrayList<>(content.keySet()); + Collections.sort(serverNames); + + StringBuilder b = new StringBuilder(); + for (String serverName : serverNames) { + b.append(content.get(serverName)); + } + + return b.toString(); + } +} \ No newline at end of file From 45ba9d02c02d63bb0aeb419350d6990c7b70c6f8 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 18 Jan 2018 14:13:44 +0200 Subject: [PATCH 031/166] Removed some deprecated PlanPlugin methods --- .../java/com/djrapitops/plan/PlanPlugin.java | 12 ------ .../com/djrapitops/plan/ShutdownHook.java | 41 ++++++++----------- .../commands/manage/ManageHotswapCommand.java | 25 ++++------- .../commands/manage/ManageSetupCommand.java | 6 +-- .../plan/settings/ServerSpecificSettings.java | 16 ++++---- .../djrapitops/plan/system/BukkitSystem.java | 3 ++ .../plan/system/cache/SessionCache.java | 21 +++++++++- .../plan/system/database/BukkitDBSystem.java | 2 +- .../plan/system/database/DBSystem.java | 4 +- .../database/databases/sql/MySQLDB.java | 13 ++++++ .../system/database/databases/sql/SQLDB.java | 1 + .../database/databases/sql/SQLiteDB.java | 7 ++++ .../databases/sql/operation/SQLFetchOps.java | 27 ++++++++++++ .../sql/operation/SQLTransferOps.java | 22 ++++++++++ .../plan/system/info/InfoSystem.java | 20 +-------- .../info/connection/WebExceptionLogger.java | 34 +++++++++++++++ .../request/GenerateAnalysisPageRequest.java | 1 + .../request/GenerateInspectPageRequest.java | 1 + .../listeners/bukkit/DeathEventListener.java | 2 +- .../bukkit/PlayerOnlineListener.java | 22 +++++----- .../system/processing/ProcessingQueue.java | 2 +- .../processing/processors/Processor.java | 4 +- .../processors/player/RegisterProcessor.java | 2 +- .../plan/system/settings/Settings.java | 20 +++++++-- .../system/settings/config/ConfigSystem.java | 10 ++--- .../plan/system/tasks/TPSCountTimer.java | 2 +- .../webapi/bukkit/ConfigurationWebAPI.java | 3 +- .../PostOriginalBukkitSettingsWebAPI.java | 4 +- .../bungee/RequestPluginsTabWebAPI.java | 7 ++-- .../systems/info/parsing/InspectPage.java | 6 ++- .../plan/utilities/ManageUtils.java | 2 +- .../com/djrapitops/plan/SettingsTest.java | 4 +- .../main/java/test/utilities/TestInit.java | 6 +-- 33 files changed, 221 insertions(+), 131 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 1b39877aee..d8aaa7b2cf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -5,13 +5,10 @@ package com.djrapitops.plan; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.processing.ProcessingQueue; -import com.djrapitops.plan.system.processing.processors.Processor; 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.api.config.Config; import com.djrapitops.plugin.settings.ColorScheme; import java.io.File; @@ -54,17 +51,8 @@ static PlanPlugin getInstance() { File getDataFolder(); - @Deprecated - ProcessingQueue getProcessingQueue(); - - @Deprecated - void addToProcessQueue(Processor... processors); - InputStream getResource(String resource); - @Deprecated - Config getMainConfig(); - ColorScheme getColorScheme(); boolean isReloading(); diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index 3488a297fa..59cfc4b8c0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -4,19 +4,19 @@ */ package com.djrapitops.plan; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.CacheSystem; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; -import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.tables.SessionsTable; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.Map; import java.util.UUID; @@ -30,64 +30,57 @@ public class ShutdownHook extends Thread { private static boolean active = false; - private static DataCache dataCache; - private static SQLDB db; - public ShutdownHook(Plan plugin) { + public void register() { if (!active) { Runtime.getRuntime().addShutdownHook(this); } active = true; - - db = (SQLDB) plugin.getDB(); - dataCache = plugin.getDataCache(); } @Override public void run() { Log.debug("Shutdown hook triggered."); + + Database db = null; try { Map activeSessions = SessionCache.getActiveSessions(); long now = MiscUtils.getTime(); - if (db == null) { - return; - } + db = Database.getActive(); if (!db.isOpen()) { db.init(); } - saveFirstSessionInformation(now); - saveActiveSessions(activeSessions, now); + saveFirstSessionInformation(db, now); + saveActiveSessions(db, activeSessions, now); } catch (DBInitException e) { Log.toLog(this.getClass().getName(), e); } finally { if (db != null) { try { db.close(); - } catch (SQLException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } - db = null; - dataCache = null; StaticHolder.unRegister(Plan.class); } } - private void saveFirstSessionInformation(long now) { + private void saveFirstSessionInformation(Database db, long now) { + DataCache dataCache = CacheSystem.getInstance().getDataCache(); for (Map.Entry entry : dataCache.getFirstSessionMsgCounts().entrySet()) { try { UUID uuid = entry.getKey(); int messagesSent = entry.getValue(); - db.getActionsTable().insertAction(uuid, new Action(now, Actions.FIRST_LOGOUT, "Messages sent: " + messagesSent)); - } catch (SQLException e) { + db.save().action(uuid, new Action(now, Actions.FIRST_LOGOUT, "Messages sent: " + messagesSent)); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } } - private void saveActiveSessions(Map activeSessions, long now) { - SessionsTable sessionsTable = db.getSessionsTable(); + private void saveActiveSessions(Database db, Map activeSessions, long now) { for (Map.Entry entry : activeSessions.entrySet()) { UUID uuid = entry.getKey(); Session session = entry.getValue(); @@ -98,8 +91,8 @@ private void saveActiveSessions(Map activeSessions, long now) { session.endSession(now); try { Log.debug("Shutdown: Saving a session: " + session.getSessionStart()); - sessionsTable.saveSession(uuid, session); - } catch (SQLException e) { + db.save().session(uuid, session); + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index d19c5a4f19..e66e160f98 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -3,20 +3,17 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.Condition; -import com.djrapitops.plan.utilities.ManageUtils; -import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.utilities.Verify; -import java.io.IOException; - /** * This manage subcommand is used to swap to a different database and reload the * plugin if the connection to the new database can be established. @@ -66,7 +63,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { } try { - final Database database = ManageUtils.getDB(dbName); + final Database database = DBSystem.getActiveDatabaseByName(dbName); // If DB is null return if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { @@ -74,23 +71,19 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { return true; } - assert database != null; - - database.getVersion(); //Test db connection + if (!database.isOpen()) { + return true; + } } catch (Exception e) { Log.toLog(this.getClass().getName(), e); sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); return true; } - Config config = plugin.getMainConfig(); - config.set(Settings.DB_TYPE.getPath(), dbName); - try { - config.save(); - plugin.reloadPlugin(true); - } catch (IOException e) { - Log.toLog(this.getClass().getName(), e); - } + Settings.DB_TYPE.set(dbName); + + Settings.save(); + plugin.reloadPlugin(true); return true; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index e643f326d3..b964eeefb9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -9,7 +9,6 @@ import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.webapi.bungee.RequestSetupWebAPI; import com.djrapitops.plan.utilities.Condition; -import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; @@ -65,9 +64,8 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { address = address.substring(0, address.length() - 1); } try { - Config config = plugin.getMainConfig(); - config.set(Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.getPath(), false); - config.set(Settings.BUNGEE_COPY_CONFIG.getPath(), true); + Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.set(false); + Settings.BUNGEE_COPY_CONFIG.set(true); // plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class).sendRequest(address); plugin.getWebServer().getWebAPI().getAPI(RequestSetupWebAPI.class).sendRequest(address); sender.sendMessage("§eConnection successful, Plan may restart in a few seconds, if it doesn't something has gone wrong."); diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java index 3b7760a9f6..ce62a2f25b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.settings; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -27,7 +27,7 @@ public class ServerSpecificSettings { public static void updateSettings(Plan plugin, Map settings) { Log.debug("Checking new settings.."); - Config config = plugin.getMainConfig(); + Config config = ConfigSystem.getConfig(); boolean changedSomething = false; for (Map.Entry setting : settings.entrySet()) { @@ -77,9 +77,9 @@ private static Object getValue(String value) { return value; } - public void addOriginalBukkitSettings(PlanBungee plugin, UUID serverUUID, Map settings) { + public void addOriginalBukkitSettings(UUID serverUUID, Map settings) { try { - Config config = plugin.getMainConfig(); + Config config = ConfigSystem.getConfig(); if (!Verify.isEmpty(config.getString("Servers." + serverUUID + ".ServerName"))) { return; } @@ -111,25 +111,25 @@ private String getPath(UUID serverUUID, Settings setting) { } public boolean getBoolean(UUID serverUUID, Settings setting) { - Config config = PlanBungee.getInstance().getMainConfig(); + Config config = ConfigSystem.getConfig(); String path = getPath(serverUUID, setting); return config.getBoolean(path); } public String getString(UUID serverUUID, Settings setting) { - Config config = PlanBungee.getInstance().getMainConfig(); + Config config = ConfigSystem.getConfig(); String path = getPath(serverUUID, setting); return config.getString(path); } public Integer getInt(UUID serverUUID, Settings setting) { - Config config = PlanBungee.getInstance().getMainConfig(); + Config config = ConfigSystem.getConfig(); String path = getPath(serverUUID, setting); return config.getInt(path); } public void set(UUID serverUUID, Settings setting, Object value) throws IOException { - Config config = PlanBungee.getInstance().getMainConfig(); + Config config = ConfigSystem.getConfig(); String path = getPath(serverUUID, setting); config.set(path, value); config.save(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index 821fdce1d2..248289951b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.ShutdownHook; import com.djrapitops.plan.system.database.BukkitDBSystem; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.listeners.BukkitListenerSystem; @@ -26,6 +27,8 @@ public BukkitSystem(Plan plugin) { databaseSystem = new BukkitDBSystem(); listenerSystem = new BukkitListenerSystem(plugin); taskSystem = new BukkitTaskSystem(plugin); + + new ShutdownHook().register(); } public static BukkitSystem getInstance() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java index e799a685db..d42fbe3bd1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java @@ -1,11 +1,14 @@ package com.djrapitops.plan.system.cache; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.connection.WebExceptionLogger; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.log.Log; import java.util.HashMap; @@ -32,6 +35,12 @@ public SessionCache(PlanSystem system) { this.system = system; } + public static SessionCache getInstance() { + DataCache dataCache = CacheSystem.getInstance().getDataCache(); + NullCheck.check(dataCache, new IllegalStateException("Data Cache was not initialized.")); + return dataCache; + } + /** * Used to get the Map of active sessions. *

@@ -52,7 +61,11 @@ public void cacheSession(UUID uuid, Session session) { new Processor(system) { @Override public void process() { - system.getInfoManager().cachePlayer(uuid); + try { + system.getInfoSystem().generateAndCachePlayerPage(uuid); + } catch (WebException e) { + WebExceptionLogger.log(this.getClass(), e); + } } }.queue(); } @@ -69,7 +82,11 @@ public void endSession(UUID uuid, long time) { Log.toLog(this.getClass().getName(), e); } finally { activeSessions.remove(uuid); - system.getInfoManager().cachePlayer(uuid); + try { + system.getInfoSystem().generateAndCachePlayerPage(uuid); + } catch (WebException e) { + WebExceptionLogger.log(this.getClass(), e); + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java index 773a7d5d5c..9f8d2fd1e2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/BukkitDBSystem.java @@ -22,7 +22,7 @@ protected void initDatabase() throws DBInitException { databases.add(new SQLiteDB()); String dbType = Settings.DB_TYPE.toString().toLowerCase().trim(); - db = getActiveDatabase(dbType); + db = getActiveDatabaseByName(dbType); db.init(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index 655bbf289b..cc0de459f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -79,8 +79,8 @@ public Database getActiveDatabase() { return db; } - public Database getActiveDatabase(String dbName) throws DBInitException { - for (Database database : getDatabases()) { + public static Database getActiveDatabaseByName(String dbName) throws DBInitException { + for (Database database : getInstance().getDatabases()) { String dbConfigName = database.getConfigName(); if (Verify.equalsIgnoreCase(dbName, dbConfigName)) { database.init(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java index 136606e66d..b1709ac5a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java @@ -1,5 +1,7 @@ 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.plugin.api.utility.log.Log; import org.apache.commons.dbcp2.BasicDataSource; @@ -14,6 +16,17 @@ public class MySQLDB extends SQLDB { private BasicDataSource dataSource; + private final SQLTransferOps transferOps; + + public MySQLDB() { + transferOps = new SQLTransferOps(this); + } + + @Override + public TransferOperations transfer() { + return transferOps; + } + /** * Setups the {@link BasicDataSource} */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 5e65123edc..ee856d147b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -79,6 +79,7 @@ public SQLDB() { countOps = new SQLCountOps(this); searchOps = new SQLSearchOps(this); saveOps = new SQLSaveOps(this); + } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index e9a1f1fd15..b140d0ceb5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -1,7 +1,9 @@ package com.djrapitops.plan.system.database.databases.sql; 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.system.database.databases.operation.TransferOperations; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; @@ -35,6 +37,11 @@ public SQLiteDB(String dbName) { this.dbName = dbName; } + @Override + public TransferOperations transfer() throws UnsupportedTransferDatabaseException { + throw new UnsupportedTransferDatabaseException(this); + } + /** * Setups the {@link BasicDataSource} */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index 1905375d8f..a7fd8ee75f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -318,4 +318,31 @@ public Map getPlayerNames() throws DBException { throw ErrorUtil.getExceptionFor(e); } } + + @Override + public String getPlayerName(UUID playerUUID) throws DBException { + try { + return usersTable.getPlayerName(playerUUID); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public Optional getServerName(UUID serverUUID) throws DBException { + try { + return serverTable.getServerName(serverUUID); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } + + @Override + public List getNicknames(UUID uuid) throws DBException { + try { + return nicknamesTable.getNicknames(uuid); + } catch (SQLException e) { + throw ErrorUtil.getExceptionFor(e); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java new file mode 100644 index 0000000000..e9227ac5e1 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java @@ -0,0 +1,22 @@ +/* + * 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.database.databases.sql.operation; + +import com.djrapitops.plan.system.database.databases.operation.TransferOperations; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; + +/** + * TransferOperations for MySQL Database. + * + * @author Rsl1122 + */ +public class SQLTransferOps extends SQLOps implements TransferOperations { + + public SQLTransferOps(SQLDB db) { + super(db); + } + + // TODO create Transfer table +} \ No newline at end of file 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 07ad5d55cf..fb070d5f7a 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 @@ -6,7 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.api.exceptions.connection.*; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem; @@ -14,16 +14,9 @@ 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; -interface ExceptionLoggingAction { - - void performAction() throws WebException; - -} - /** * Information management system. *

@@ -86,15 +79,4 @@ public ConnectionSystem getConnectionSystem() { } public abstract void updateNetworkPage(); - - public void handlePossibleException(ExceptionLoggingAction action) { - try { - action.performAction(); - } catch (ConnectionFailException | UnsupportedTransferDatabaseException | UnauthorizedServerException - | NotFoundException | NoServersException e) { - Log.warn(e.getMessage()); - } catch (WebException e) { - Log.toLog(this.getClass().getName(), e); - } - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java new file mode 100644 index 0000000000..0fff2f6588 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java @@ -0,0 +1,34 @@ +/* + * 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.info.connection; + +import com.djrapitops.plan.api.exceptions.connection.*; +import com.djrapitops.plugin.api.utility.log.Log; + +/** + * Class that decides what to do with WebExceptions. + * + * @author Rsl1122 + */ +public class WebExceptionLogger { + + public static void log(Class c, ExceptionLoggingAction action) { + try { + action.performAction(); + } catch (ConnectionFailException | UnsupportedTransferDatabaseException | UnauthorizedServerException + | NotFoundException | NoServersException e) { + Log.warn(e.getMessage()); + } catch (WebException e) { + Log.toLog(WebExceptionLogger.class, e); + } + } + + public interface ExceptionLoggingAction { + + void performAction() throws WebException; + + } + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index a54c6d6b3a..f7af6e0293 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -22,6 +22,7 @@ public GenerateAnalysisPageRequest(UUID serverUUID) { @Override public void placeDataToDatabase() { + // No data required in a Generate request } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index 05d2eebf55..2fd168f9a7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -26,6 +26,7 @@ public GenerateInspectPageRequest(UUID uuid) { @Override public void placeDataToDatabase() { + // No data required in a Generate request } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java index 71555aea77..67687c794c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java @@ -46,7 +46,7 @@ public void onDeath(EntityDeathEvent event) { LivingEntity dead = event.getEntity(); if (dead instanceof Player) { - plugin.addToProcessQueue(new DeathProcessor(dead.getUniqueId())); + new DeathProcessor(dead.getUniqueId()).queue(); } try { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index 2b5aacc84c..dd02bba3be 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -3,6 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; import com.djrapitops.plan.system.processing.processors.player.*; import com.djrapitops.plan.system.tasks.TaskSystem; @@ -53,11 +54,8 @@ public void onPlayerLogin(PlayerLoginEvent event) { PlayerLoginEvent.Result result = event.getResult(); UUID uuid = event.getPlayer().getUniqueId(); boolean op = event.getPlayer().isOp(); - if (result == PlayerLoginEvent.Result.KICK_BANNED) { - plugin.addToProcessQueue(new BanAndOpProcessor(uuid, true, op)); - } else { - plugin.addToProcessQueue(new BanAndOpProcessor(uuid, false, op)); - } + boolean banned = result == PlayerLoginEvent.Result.KICK_BANNED; + new BanAndOpProcessor(uuid, banned, op).queue(); } catch (Exception e) { Log.toLog(this.getClass(), e); } @@ -78,7 +76,7 @@ public void onPlayerKick(PlayerKickEvent event) { return; } UUID uuid = event.getPlayer().getUniqueId(); - plugin.addToProcessQueue(new KickProcessor(uuid)); + new KickProcessor(uuid).queue(); } catch (Exception e) { Log.toLog(this.getClass(), e); } @@ -111,13 +109,13 @@ public void onPlayerJoin(PlayerJoinEvent event) { int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline(); cache.cacheSession(uuid, Session.start(time, world, gm)); - plugin.addToProcessQueue( + + Processor.queueMany( new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline, new IPUpdateProcessor(uuid, ip, time), new NameProcessor(uuid, playerName, displayName) ), - new NetworkPageUpdateProcessor(plugin.getInfoManager()) - ); + new NetworkPageUpdateProcessor()); } catch (Exception e) { Log.toLog(this.getClass(), e); } @@ -137,15 +135,15 @@ public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); UUID uuid = player.getUniqueId(); - plugin.addToProcessQueue( + Processor.queueMany( new BanAndOpProcessor(uuid, player.isBanned(), player.isOp()), new EndSessionProcessor(uuid, time), - new NetworkPageUpdateProcessor(plugin.getInfoManager()) + new NetworkPageUpdateProcessor() ); if (cache.isFirstSession(uuid)) { int messagesSent = plugin.getDataCache().getFirstSessionMsgCount(uuid); - plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent)); + new FirstLeaveProcessor(uuid, time, messagesSent).queue(); } } catch (Exception e) { Log.toLog(this.getClass(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index 0f8dd49c0f..467e8735f9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -72,7 +72,7 @@ public void run() { */ public void queue(Processor processor) { if (!queue.offer(processor)) { - Log.toLog("ProcessingQueue.queue", new IllegalStateException("Processor was not added to Queue")); + Log.toLog(Processor.class, new IllegalStateException("Processor was not added to Queue")); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java index 8a93a26ac6..7c87c80594 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java @@ -18,7 +18,7 @@ public Processor(T object) { this.object = object; } - public static void queue(Processor... processors) { + public static void queueMany(Processor... processors) { ProcessingQueue processingQueue = ProcessingQueue.getInstance(); for (Processor processor : processors) { processingQueue.queue(processor); @@ -32,6 +32,6 @@ public T getObject() { } public void queue() { - queue(this); + queueMany(this); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index 2b8573bff8..a77728eb32 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java @@ -56,7 +56,7 @@ public void process() { } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } finally { - Processor.queue(afterProcess); + Processor.queueMany(afterProcess); } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index 5896c2b57a..6c9362d395 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -4,7 +4,9 @@ import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.config.Config; +import com.djrapitops.plugin.api.utility.log.Log; +import java.io.IOException; import java.util.List; /** @@ -125,8 +127,12 @@ public boolean isFalse() { return !isTrue(); } - public void setValue(Boolean value) { - this.value = value; + public static void save() { + try { + ConfigSystem.getConfig().save(); + } catch (IOException e) { + Log.toLog(Settings.class, e); + } } /** @@ -162,7 +168,15 @@ public String getPath() { return configPath; } + public void setTemporaryValue(Boolean value) { + this.value = value; + } + + public void set(Object value) { + getConfig().set(getPath(), value); + } + private Config getConfig() { - return ConfigSystem.getInstance().getConfig(); + return ConfigSystem.getConfig(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index a35dad71be..347b33441a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -39,12 +39,12 @@ public static ConfigSystem getInstance() { return configSystem; } - public Theme getThemeSystem() { - return theme; + public static Config getConfig() { + return getInstance().config; } - public Config getConfig() { - return config; + public Theme getThemeSystem() { + return getInstance().theme; } @Override @@ -81,6 +81,6 @@ public void reload() { } public Locale getLocale() { - return locale; + return getInstance().locale; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java index d1d0b7b02d..a162d42dbb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java @@ -36,7 +36,7 @@ public void run() { addNewTPSEntry(nanoTime, now); if (history.size() >= 60) { - plugin.addToProcessQueue(new TPSInsertProcessor(new ArrayList<>(history))); + new TPSInsertProcessor(new ArrayList<>(history)).queue(); history.clear(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index efe6f06fa8..bf2028abed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.settings.ServerSpecificSettings; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; @@ -33,7 +34,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } if (Settings.BUNGEE_COPY_CONFIG.isFalse() || Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isTrue()) { Log.info("Bungee Config settings overridden on this server."); - Log.debug(plugin.getMainConfig().getConfigNode("Plugin.Bungee-Override").getChildren().toString()); + Log.debug(ConfigSystem.getConfig().getConfigNode("Plugin.Bungee-Override").getChildren().toString()); return success(); } ServerSpecificSettings.updateSettings((Plan) plugin, variables); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java index 502d30bfb7..cb61156850 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java @@ -4,8 +4,6 @@ */ package com.djrapitops.plan.system.webserver.webapi.bungee; - -import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.settings.Settings; @@ -43,7 +41,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { settings.put("WebServerPort", webServerPort); settings.put("ServerName", serverName); settings.put("ThemeBase", themeBase); - Settings.serverSpecific().addOriginalBukkitSettings((PlanBungee) plugin, UUID.fromString(variables.get("sender")), settings); + Settings.serverSpecific().addOriginalBukkitSettings(UUID.fromString(variables.get("sender")), settings); return success(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index 4f10902060..e26295e998 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -4,14 +4,13 @@ */ 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.info.server.ServerInfo; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; @@ -59,7 +58,7 @@ public void sendRequest(String address, UUID uuid) throws WebException { } public void sendRequestsToBukkitServers(PlanPlugin plugin, UUID uuid) { - plugin.addToProcessQueue(new Processor(uuid) { + new Processor(uuid) { @Override public void process() { try { @@ -76,6 +75,6 @@ public void process() { Log.toLog(this.getClass().getName(), e); } } - }); + }.queue(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java index 36608b4eee..e8785e160d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java @@ -13,7 +13,9 @@ import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; @@ -85,7 +87,7 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); String online = "Offline"; - Optional activeSession = plugin.getInfoManager().getDataCache().getCachedSession(uuid); + Optional activeSession = SessionCache.getInstance().getCachedSession(uuid); if (activeSession.isPresent()) { Session session = activeSession.get(); session.setSessionID(Integer.MAX_VALUE); @@ -234,7 +236,7 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp())); - if (!plugin.getInfoManager().isUsingAnotherWebServer()) { + if (!InfoSystem.getInstance().getConnectionSystem().isServerAvailable()) { addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java index 0e773927b4..c3a6d0a609 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java @@ -78,6 +78,6 @@ public static void clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) @Deprecated public static Database getDB(String dbName) throws DBInitException { - return DBSystem.getInstance().getActiveDatabase(dbName); + return DBSystem.getActiveDatabaseByName(dbName); } } diff --git a/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java b/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java index f152fe19ff..0eddb3446a 100644 --- a/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java @@ -40,10 +40,10 @@ public void testIsTrue() { public void testSetValue() { Settings gatherCommands = Settings.LOG_UNKNOWN_COMMANDS; - gatherCommands.setValue(false); + gatherCommands.setTemporaryValue(false); assertFalse(gatherCommands.isTrue()); - gatherCommands.setValue(true); + gatherCommands.setTemporaryValue(true); assertTrue(gatherCommands.isTrue()); } diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index 9bda23bdbc..d2731611a8 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -4,8 +4,8 @@ import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.info.server.BukkitServerInfoManager; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.StaticHolder; @@ -111,15 +111,13 @@ private void setUp() throws Exception { public void save() { } }; - when(planMock.getMainConfig()).thenReturn(iConfig); - Server mockServer = mockServer(); when(planMock.getServer()).thenReturn(mockServer); // Test log settings when(planMock.getLogger()).thenReturn(Logger.getGlobal()); - Settings.DEBUG.setValue(true); + Settings.DEBUG.setTemporaryValue(true); ServerVariableHolder serverVariableHolder = new ServerVariableHolder(mockServer); From 34198543ffa26b8659c421a74528f8964f3aee01 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 18 Jan 2018 17:26:37 +0200 Subject: [PATCH 032/166] Bukkit ServerInfo --- .../main/java/com/djrapitops/plan/Plan.java | 38 +++-- .../java/com/djrapitops/plan/PlanBungee.java | 15 +- .../java/com/djrapitops/plan/PlanPlugin.java | 3 +- .../plan/command/commands/AnalyzeCommand.java | 6 +- .../plan/command/commands/DevCommand.java | 6 +- .../djrapitops/plan/data/ServerProfile.java | 4 +- .../djrapitops/plan/system/PlanSystem.java | 9 +- .../databases/operation/FetchOperations.java | 11 +- .../databases/operation/SaveOperations.java | 3 + .../databases/sql/tables/ServerTable.java | 42 ++--- .../databases/sql/tables/TPSTable.java | 4 +- .../sql/tables/move/BatchOperationTable.java | 4 +- .../plan/system/info/InfoSystem.java | 2 +- .../info/connection/ConnectionSystem.java | 15 +- .../system/info/server/BukkitServerInfo.java | 118 ++++++++++++++ .../info/server/BukkitServerInfoManager.java | 148 ------------------ ...InfoManager.java => BungeeServerInfo.java} | 60 +++---- .../plan/system/info/server/Server.java | 88 +++++++++++ .../plan/system/info/server/ServerInfo.java | 88 ++++------- .../system/info/server/ServerInfoFile.java | 23 +-- .../system/info/server/ServerProperties.java | 83 ++++++++++ .../response/pages/DebugPageResponse.java | 18 +-- .../bungee/RequestPluginsTabWebAPI.java | 6 +- .../webapi/bungee/RequestSetupWebAPI.java | 6 +- .../webapi/universal/PingWebAPI.java | 62 -------- .../info/BukkitInformationManager.java | 5 +- .../info/BungeeInformationManager.java | 58 +++---- .../systems/info/parsing/InspectPage.java | 2 +- .../plan/utilities/html/HtmlStructure.java | 7 +- .../InspectPluginsTabContentCreator.java | 9 +- .../main/resources/DefaultServerInfoFile.yml | 3 - .../plan/ServerVariableHolderTest.java | 34 ---- .../plan/system/database/DatabaseTest.java | 10 +- .../plan/utilities/MiscUtilsTest.java | 4 +- .../main/java/test/utilities/TestInit.java | 15 +- 35 files changed, 516 insertions(+), 493 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfoManager.java rename Plan/src/main/java/com/djrapitops/plan/system/info/server/{BungeeServerInfoManager.java => BungeeServerInfo.java} (73%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java delete mode 100644 Plan/test/main/java/com/djrapitops/plan/ServerVariableHolderTest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 84e5682262..72df1f1ca7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -32,6 +32,9 @@ import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; 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.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; @@ -42,13 +45,11 @@ 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.system.info.server.BukkitServerInfoManager; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; 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; @@ -76,9 +77,9 @@ public class Plan extends BukkitPlugin implements PlanPlugin { private HookHandler hookHandler; // Manages 3rd party data sources private BukkitInformationManager infoManager; - private BukkitServerInfoManager serverInfoManager; + private BukkitServerInfo serverInfoManager; - private ServerVariableHolder serverVariableHolder; + private ServerProperties serverProperties; /** * Used to get the plugin-instance singleton. @@ -94,7 +95,7 @@ public static UUID getServerUUID() { } public UUID getServerUuid() { - return serverInfoManager.getServerUUID(); + return ServerInfo.getServerUUID(); } /** @@ -128,14 +129,14 @@ public void onEnable() { Theme.getInstance().enable(); Benchmark.start("Reading server variables"); - serverVariableHolder = new ServerVariableHolder(getServer()); + serverProperties = new ServerProperties(getServer()); Benchmark.stop("Enable", "Reading server variables"); DBSystem.getInstance().enable(); Benchmark.start("WebServer Initialization"); - serverInfoManager = new BukkitServerInfoManager(this); + serverInfoManager = new BukkitServerInfo(this); infoManager = new BukkitInformationManager(this); WebServerSystem.getInstance().enable(); if (!WebServerSystem.isWebServerEnabled()) { @@ -156,7 +157,7 @@ public void onEnable() { boolean usingBungeeWebServer = infoManager.isUsingAnotherWebServer(); boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); - if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) { + if (!usingAlternativeIP && serverProperties.getIp().isEmpty()) { Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString()); } if (usingBungeeWebServer && usingAlternativeIP) { @@ -259,28 +260,25 @@ public HookHandler getHookHandler() { * Used to get the object storing server variables that are constant after * boot. * - * @return ServerVariableHolder - * @see ServerVariableHolder + * @return ServerProperties + * @see ServerProperties */ - public ServerVariableHolder getVariable() { - return serverVariableHolder; + @Deprecated + public ServerProperties getVariable() { + return serverProperties; } /** * Used to get the object storing server info * - * @return BukkitServerInfoManager - * @see BukkitServerInfoManager + * @return BukkitServerInfo + * @see BukkitServerInfo */ - public BukkitServerInfoManager getServerInfoManager() { + @Deprecated + public BukkitServerInfo getServerInfoManager() { return serverInfoManager; } - @Override - public Config getMainConfig() { - return ConfigSystem.getInstance().getConfig(); - } - @Deprecated public InformationManager getInfoManager() { return infoManager; diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index b27cf87a71..6384cef4ec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -13,6 +13,8 @@ import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.info.server.BungeeServerInfo; +import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.tasks.TaskSystem; @@ -21,7 +23,6 @@ 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.system.info.server.BungeeServerInfoManager; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; @@ -45,9 +46,9 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { private BungeeSystem system; - private BungeeServerInfoManager serverInfoManager; + private BungeeServerInfo serverInfoManager; private BungeeInformationManager infoManager; - private ServerVariableHolder variableHolder; + private ServerProperties variableHolder; @Deprecated private boolean setupAllowed = false; @@ -71,7 +72,7 @@ public void onEnable() { VersionCheckSystem.getInstance().enable(); - variableHolder = new ServerVariableHolder(getProxy()); + variableHolder = new ServerProperties(getProxy()); new Locale().loadLocale(); @@ -87,7 +88,7 @@ public void onEnable() { Benchmark.start("WebServer Initialization"); - serverInfoManager = new BungeeServerInfoManager(this); + serverInfoManager = new BungeeServerInfo(this); infoManager = new BungeeInformationManager(this); WebServerSystem.getInstance().enable(); @@ -132,7 +133,7 @@ public Database getDB() { return DBSystem.getInstance().getActiveDatabase(); } - public BungeeServerInfoManager getServerInfoManager() { + public BungeeServerInfo getServerInfoManager() { return serverInfoManager; } @@ -163,7 +164,7 @@ public ColorScheme getColorScheme() { } @Override - public ServerVariableHolder getVariable() { + public ServerProperties getVariable() { return variableHolder; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index d8aaa7b2cf..157fcc0955 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -5,6 +5,7 @@ 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; @@ -38,7 +39,7 @@ static PlanPlugin getInstance() { Database getDB(); @Deprecated - ServerVariableHolder getVariable(); + ServerProperties getVariable(); @Deprecated UUID getServerUuid(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 4c895ba3b8..1aa0e623b1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -4,7 +4,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plugin.api.utility.log.Log; @@ -86,8 +86,8 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { UUID serverUUID = Plan.getServerUUID(); if (args.length >= 1 && plugin.getInfoManager().isUsingAnotherWebServer()) { try { - List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); - Optional server = bukkitServers.stream().filter(info -> { + List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); + Optional server = bukkitServers.stream().filter(info -> { StringBuilder idBuilder = new StringBuilder(args[0]); if (args.length > 1) { for (int i = 1; i < args.length; i++) { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index 79064eeb84..80a0128615 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; 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.webserver.webapi.WebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI; import com.djrapitops.plan.utilities.Condition; @@ -48,9 +49,10 @@ public boolean onCommand(ISender sender, String cmd, String[] args) { } break; case "web": - Optional bungeeConnectionAddress = plugin.getServerInfoManager().getBungeeConnectionAddress(); + ConnectionSystem connectionSystem = ConnectionSystem.getInstance(); + Optional bungeeConnectionAddress = connectionSystem.getMainAddress(); String accessAddress = plugin.getWebServer().getAccessAddress(); - sender.sendMessage((plugin.getInfoManager().isUsingAnotherWebServer() && bungeeConnectionAddress.isPresent()) + sender.sendMessage((connectionSystem.isMainServerAvailable() && bungeeConnectionAddress.isPresent()) ? "Bungee: " + bungeeConnectionAddress.get() : "Local: " + accessAddress); break; default: diff --git a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java index 99ef745206..f43429c1b8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/ServerProfile.java @@ -6,12 +6,12 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.time.WorldTimes; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; @@ -118,7 +118,7 @@ public static int getPlayersOnline() { } public static int getPlayersMax() { - return PlanPlugin.getInstance().getVariable().getMaxPlayers(); + return ServerInfo.getServerProperties().getMaxPlayers(); } public static long serverDownTime(List tpsData) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 097fde3273..abd1384edb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -9,13 +9,13 @@ import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.listeners.ListenerSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; 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.WebServerSystem; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Check; @@ -42,6 +42,7 @@ public abstract class PlanSystem implements SubSystem { protected ListenerSystem listenerSystem; protected TaskSystem taskSystem; + protected ServerInfo serverInfo; public PlanSystem() { processingQueue = new ProcessingQueue(); @@ -72,6 +73,7 @@ public void enable() throws EnableException { configSystem, databaseSystem, webServerSystem, + serverInfo, infoSystem, processingQueue, cacheSystem, @@ -90,8 +92,9 @@ public void disable() { listenerSystem, processingQueue, databaseSystem, - infoSystem, webServerSystem, + infoSystem, + serverInfo, taskSystem, configSystem, fileSystem, @@ -153,7 +156,7 @@ public WebServerSystem getWebServerSystem() { } public ServerInfo getServerInfo() { - return null; // TODO + return serverInfo; } public CacheSystem getCacheSystem() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 9f7b7ac584..85b9aa2f9d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -5,6 +5,7 @@ import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.container.*; +import com.djrapitops.plan.system.info.server.Server; import java.util.*; @@ -34,6 +35,14 @@ public interface FetchOperations { WebUser getWebUser(String username) throws DBException; + // Servers + + Optional getServerName(UUID serverUUID) throws DBException; + + Optional getBungeeInformation() throws DBException; + + Optional getServerID(UUID serverUUID); + // Raw Data List getTPSData(UUID serverUUID) throws DBException; @@ -66,7 +75,5 @@ public interface FetchOperations { String getPlayerName(UUID playerUUID) throws DBException; - Optional getServerName(UUID serverUUID) throws DBException; - List getNicknames(UUID uuid) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java index d3c4372162..1a317efd6e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.*; +import com.djrapitops.plan.system.info.server.Server; import java.util.List; import java.util.Map; @@ -64,4 +65,6 @@ void insertSessions(Map>> ofServers, boolean conta void insertTPSforThisServer(TPS tps) throws DBException; void session(UUID uuid, Session session) throws DBException; + + void serverInfoForThisServer(Server server) throws DBException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java index 13da89af47..47230fe60a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; import com.djrapitops.plan.system.database.databases.sql.statements.*; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -77,7 +77,7 @@ public void alterTableV11() { } } - public void saveCurrentServerInfo(ServerInfo info) throws SQLException { + public void saveCurrentServerInfo(Server info) throws SQLException { if (getServerID(info.getUuid()).isPresent()) { updateServerInfo(info); } else { @@ -85,7 +85,7 @@ public void saveCurrentServerInfo(ServerInfo info) throws SQLException { } } - private void updateServerInfo(ServerInfo info) throws SQLException { + private void updateServerInfo(Server info) throws SQLException { String sql = Update.values(tableName, columnServerUUID, columnServerName, @@ -112,10 +112,10 @@ public void prepare(PreparedStatement statement) throws SQLException { * Inserts new row for a server into the table. * * @param info Info to instert (All variables should be present. - * @throws IllegalStateException if one of the ServerInfo variables is null + * @throws IllegalStateException if one of the Server variables is null * @throws SQLException DB Error */ - private void saveNewServerInfo(ServerInfo info) throws SQLException { + private void saveNewServerInfo(Server info) throws SQLException { UUID uuid = info.getUuid(); String name = info.getName(); String webAddress = info.getWebAddress(); @@ -253,21 +253,21 @@ public Map processResults(ResultSet set) throws SQLException { * @return information about Bungee server. * @throws SQLException DB Error */ - public Optional getBungeeInfo() throws SQLException { + public Optional getBungeeInfo() throws SQLException { String sql = Select.from(tableName, "*") .where(columnServerName + "=?") .toString(); - return query(new QueryStatement>(sql) { + return query(new QueryStatement>(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, "BungeeCord"); } @Override - public Optional processResults(ResultSet set) throws SQLException { + public Optional processResults(ResultSet set) throws SQLException { if (set.next()) { - return Optional.of(new ServerInfo( + return Optional.of(new Server( set.getInt(columnServerID), UUID.fromString(set.getString(columnServerUUID)), set.getString(columnServerName), @@ -280,22 +280,22 @@ public Optional processResults(ResultSet set) throws SQLException { }); } - public List getBukkitServers() throws SQLException { + public List getBukkitServers() throws SQLException { String sql = Select.from(tableName, "*") .where(columnServerName + "!=?") .toString(); - return query(new QueryStatement>(sql, 100) { + return query(new QueryStatement>(sql, 100) { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, "BungeeCord"); } @Override - public List processResults(ResultSet set) throws SQLException { - List servers = new ArrayList<>(); + public List processResults(ResultSet set) throws SQLException { + List servers = new ArrayList<>(); while (set.next()) { - servers.add(new ServerInfo( + servers.add(new Server( set.getInt(columnServerID), UUID.fromString(set.getString(columnServerUUID)), set.getString(columnServerName), @@ -315,15 +315,15 @@ public String getColumnUUID() { return columnServerUUID; } - public void insertAllServers(List allServerInfo) throws SQLException { - if (Verify.isEmpty(allServerInfo)) { + public void insertAllServers(List allServer) throws SQLException { + if (Verify.isEmpty(allServer)) { return; } executeBatch(new ExecStatement(insertStatement) { @Override public void prepare(PreparedStatement statement) throws SQLException { - for (ServerInfo info : allServerInfo) { + for (Server info : allServer) { UUID uuid = info.getUuid(); String name = info.getName(); String webAddress = info.getWebAddress(); @@ -382,21 +382,21 @@ public Optional processResults(ResultSet set) throws SQLException { }); } - public Optional getServerInfo(UUID serverUUID) throws SQLException { + public Optional getServerInfo(UUID serverUUID) throws SQLException { String sql = Select.from(tableName, "*") .where(columnServerUUID + "=?") .toString(); - return query(new QueryStatement>(sql) { + return query(new QueryStatement>(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, serverUUID.toString()); } @Override - public Optional processResults(ResultSet set) throws SQLException { + public Optional processResults(ResultSet set) throws SQLException { if (set.next()) { - return Optional.of(new ServerInfo( + return Optional.of(new Server( set.getInt(columnServerID), UUID.fromString(set.getString(columnServerUUID)), set.getString(columnServerName), diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java index 761ac358f7..28281bcf17 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Select; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.utilities.Verify; @@ -267,7 +267,7 @@ public void prepare(PreparedStatement statement) throws SQLException { } public List getNetworkOnlineData() throws SQLException { - Optional bungeeInfo = serverTable.getBungeeInfo(); + Optional bungeeInfo = serverTable.getBungeeInfo(); if (!bungeeInfo.isPresent()) { return new ArrayList<>(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java index 51b1fca974..be4fa34f2a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; import com.djrapitops.plan.system.database.databases.sql.tables.Table; import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; @@ -140,7 +140,7 @@ public void copyServers(BatchOperationTable toDB) throws SQLException { } Log.debug("Batch Copy Servers"); ServerTable serverTable = db.getServerTable(); - List servers = serverTable.getBukkitServers(); + List servers = serverTable.getBukkitServers(); serverTable.getBungeeInfo().ifPresent(servers::add); toDB.getDb().getServerTable().insertAllServers(servers); } 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 fb070d5f7a..5ce3e35b7f 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 @@ -56,7 +56,7 @@ public void generateAnalysisPage(UUID serverUUID) throws WebException { } public void sendRequest(InfoRequest infoRequest) throws WebException { - if (!connectionSystem.isServerAvailable()) { + if (!connectionSystem.isMainServerAvailable()) { runLocally(infoRequest); } connectionSystem.sendInfoRequest(infoRequest); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 5e91c32fe0..067987c575 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -10,11 +10,12 @@ import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.request.CacheInspectPageRequest; import com.djrapitops.plan.system.info.request.InfoRequest; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.utilities.NullCheck; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.UUID; /** @@ -28,7 +29,7 @@ public abstract class ConnectionSystem implements SubSystem { protected final Map dataRequests; protected final UUID serverUUID; - protected Map servers; + protected Map servers; public ConnectionSystem(UUID serverUUID) { this.serverUUID = serverUUID; @@ -53,14 +54,16 @@ private void putRequest(Map requests, InfoRequest request) requests.put(request.getClass().getSimpleName(), request); } - protected abstract ServerInfo selectServerForRequest(InfoRequest infoRequest) throws NoServersException; + protected abstract Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException; public void sendInfoRequest(InfoRequest infoRequest) throws WebException { - ServerInfo serverInfo = selectServerForRequest(infoRequest); - String address = serverInfo.getWebAddress(); + Server server = selectServerForRequest(infoRequest); + String address = server.getWebAddress(); new ConnectionOut(address, serverUUID, infoRequest).sendRequest(); } - public abstract boolean isServerAvailable(); + public abstract boolean isMainServerAvailable(); + + public abstract Optional getMainAddress(); } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java new file mode 100644 index 0000000000..d3c3c5a1e3 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java @@ -0,0 +1,118 @@ +/* + * 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.info.server; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.WebServerSystem; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.io.IOException; +import java.util.Optional; +import java.util.UUID; + +/** + * Manages the Server information required for Bungee-Bukkit WebAPI connection. + *

+ * Also manages Server ID required for MySQL database independence. + * + * @author Rsl1122 + */ +public class BukkitServerInfo extends ServerInfo { + + private ServerInfoFile serverInfoFile; + private Database database; + + public BukkitServerInfo(Plan plugin) { + serverProperties = new ServerProperties(plugin.getServer()); + } + + @Override + public void enable() throws EnableException { + database = Database.getActive(); + + try { + serverInfoFile = new ServerInfoFile(FileSystem.getDataFolder()); + } catch (IOException e) { + throw new EnableException("Failed to read ServerInfoFile.yml", e); + } + super.enable(); + } + + @Override + protected Server loadServerInfo() throws EnableException { + Optional serverUUID = serverInfoFile.getUUID(); + try { + return serverUUID.isPresent() ? updateDbInfo(serverUUID.get()) : registerServer(); + } catch (DBException e) { + throw new EnableException("Failed to read Server information from Database", e); + } catch (IOException e) { + throw new EnableException("Failed to read ServerInfoFile.yml", e); + } + } + + private Server updateDbInfo(UUID serverUUID) throws IOException, DBException { + Optional serverID = database.fetch().getServerID(serverUUID); + if (!serverID.isPresent()) { + return registerServer(serverUUID); + } + String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"); + String webAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); + if ("plan".equalsIgnoreCase(name)) { + name = "Server " + serverID.get(); + } + int maxPlayers = serverProperties.getMaxPlayers(); + + Server server = new Server(serverID.get(), serverUUID, name, webAddress, maxPlayers); + database.save().serverInfoForThisServer(server); + return server; + } + + private Server registerServer() throws DBException, IOException { + return registerServer(generateNewUUID(serverProperties)); + } + + private Server registerServer(UUID serverUUID) throws DBException, IOException { + String webAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); + String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"); + int maxPlayers = ServerInfo.getServerProperties().getMaxPlayers(); + + Server server = new Server(-1, serverUUID, name, webAddress, maxPlayers); + database.save().serverInfoForThisServer(server); + + Optional serverID = database.fetch().getServerID(serverUUID); + if (!serverID.isPresent()) { + throw new IllegalStateException("Failed to Register Server (ID not found)"); + } + + int id = serverID.get(); + server.setId(id); + + serverInfoFile.saveServerUUID(serverUUID); + return server; + } + + private UUID generateNewUUID(ServerProperties serverProperties) { + String seed = serverProperties.getServerId() + serverProperties.getName() + serverProperties.getIp() + serverProperties.getPort() + serverProperties.getVersion() + serverProperties.getImplVersion(); + return UUID.nameUUIDFromBytes(seed.getBytes()); + } + + @Deprecated + public Optional getBungeeConnectionAddress() { + try { + Optional bungeeInfo = Database.getActive().fetch().getBungeeInformation(); + if (bungeeInfo.isPresent()) { + return Optional.of(bungeeInfo.get().getWebAddress()); + } + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + } + return Optional.empty(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfoManager.java deleted file mode 100644 index 158d5f4c9c..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfoManager.java +++ /dev/null @@ -1,148 +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.system.info.server; - - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.ServerVariableHolder; -import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.io.IOException; -import java.sql.SQLException; -import java.util.Optional; -import java.util.UUID; - -/** - * Manages the Server information required for Bungee-Bukkit WebAPI connection. - *

- * Also manages Server ID required for MySQL database independence. - * - * @author Rsl1122 - */ -public class BukkitServerInfoManager { - - private final Plan plugin; - private final ServerTable serverTable; - private ServerInfo serverInfo; - private ServerInfoFile serverInfoFile; - - public BukkitServerInfoManager(Plan plugin) throws EnableException { - this.plugin = plugin; - Database db = plugin.getDB(); - serverTable = db.getServerTable(); - - try { - serverInfoFile = new ServerInfoFile(plugin); - } catch (IOException e) { - throw new EnableException("Failed to read ServerInfoFile.yml", e); - } - } - - public void updateServerInfo() throws SQLException, IOException { - Optional serverUUID = serverInfoFile.getUUID(); - if (serverUUID.isPresent()) { - updateDbInfo(serverUUID.get()); - } else { - registerServer(); - } - } - - private void updateDbInfo(UUID serverUUID) throws SQLException, IOException { - Optional serverID = serverTable.getServerID(serverUUID); - if (!serverID.isPresent()) { - registerServer(serverUUID); - return; - } - String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"); - String webAddress = plugin.getWebServer().getAccessAddress(); - if ("plan".equalsIgnoreCase(name)) { - name = "Server " + serverID.get(); - } - int maxPlayers = plugin.getVariable().getMaxPlayers(); - - serverInfo = new ServerInfo(serverID.get(), serverUUID, name, webAddress, maxPlayers); - serverTable.saveCurrentServerInfo(serverInfo); - } - - private void registerServer() throws SQLException, IOException { - registerServer(generateNewUUID(plugin.getVariable())); - } - - private void registerServer(UUID serverUUID) throws SQLException, IOException { - String webAddress = plugin.getWebServer().getAccessAddress(); - String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"); - int maxPlayers = plugin.getVariable().getMaxPlayers(); - serverInfo = new ServerInfo(-1, serverUUID, name, webAddress, maxPlayers); - serverTable.saveCurrentServerInfo(serverInfo); - Optional serverID = serverTable.getServerID(serverUUID); - if (!serverID.isPresent()) { - throw new IllegalStateException("Failed to Register Server (ID not found)"); - } - - int id = serverID.get(); - serverInfo.setId(id); - - serverInfoFile.saveInfo(serverInfo, new ServerInfo(-1, null, name, "", 0)); - } - - private UUID generateNewUUID(ServerVariableHolder variableHolder) { - String seed = plugin.getServer().getServerId() + variableHolder.getName() + variableHolder.getIp() + variableHolder.getPort() + variableHolder.getVersion() + variableHolder.getImplVersion(); - return UUID.nameUUIDFromBytes(seed.getBytes()); - } - - public Optional getBungeeConnectionAddress() { - try { - String bungeeWebAddress = serverInfoFile.getBungeeWebAddress(); - if (!bungeeWebAddress.isEmpty()) { - return Optional.of(bungeeWebAddress); - } - } catch (Exception ignored) { - /* Ignored */ - } - try { - Optional bungeeInfo = plugin.getDB().getServerTable().getBungeeInfo(); - if (bungeeInfo.isPresent()) { - return Optional.of(bungeeInfo.get().getWebAddress()); - } - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } - return Optional.empty(); - } - - /** - * Saves Bungee connection information to local file on Bukkit servers. - * - * @param address Address to save - * @throws IOException If ServerInfo file can not be written to. - */ - public void saveBungeeConnectionAddress(String address) throws IOException { - serverInfoFile.saveInfo(serverInfo, new ServerInfo(-1, null, "Bungee", address, -1)); - } - - public void markConnectionFail() { - serverInfoFile.markConnectionFail(); - } - - public void resetConnectionFails() { - serverInfoFile.resetConnectionFails(); - } - - public int getServerID() { - return serverInfo.getId(); - } - - public UUID getServerUUID() { - return serverInfo.getUuid(); - } - - public String getServerName() { - return serverInfo.getName(); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java similarity index 73% rename from Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfoManager.java rename to Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java index 8721cedcee..57c144e887 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java @@ -5,13 +5,11 @@ package com.djrapitops.plan.system.info.server; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI; -import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; @@ -26,16 +24,16 @@ * * @author Rsl1122 */ -public class BungeeServerInfoManager { +public class BungeeServerInfo extends ServerInfo { private final PlanBungee plugin; private final Database db; - private final Map bukkitServers; + private final Map bukkitServers; private final Set onlineServers; - private ServerInfo serverInfo; + private Server server; private ServerTable serverTable; - public BungeeServerInfoManager(PlanBungee plugin) { + public BungeeServerInfo(PlanBungee plugin) { this.plugin = plugin; this.db = plugin.getDB(); serverTable = db.getServerTable(); @@ -46,62 +44,56 @@ public BungeeServerInfoManager(PlanBungee plugin) { public void loadServerInfo() throws EnableException { try { - Optional bungeeInfo = db.getServerTable().getBungeeInfo(); + Optional bungeeInfo = db.getServerTable().getBungeeInfo(); if (bungeeInfo.isPresent()) { - serverInfo = bungeeInfo.get(); + server = bungeeInfo.get(); String accessAddress = plugin.getWebServer().getAccessAddress(); - if (!accessAddress.equals(serverInfo.getWebAddress())) { - serverInfo.setWebAddress(accessAddress); - serverTable.saveCurrentServerInfo(serverInfo); + if (!accessAddress.equals(server.getWebAddress())) { + server.setWebAddress(accessAddress); + serverTable.saveCurrentServerInfo(server); } } else { - serverInfo = registerBungeeInfo(); + server = registerBungeeInfo(); } } catch (SQLException e) { - throw new EnableException("Failed to read Database for ServerInfo"); + throw new EnableException("Failed to read Database for Server"); } } - private ServerInfo registerBungeeInfo() throws SQLException, EnableException { - ServerVariableHolder variable = plugin.getVariable(); + private Server registerBungeeInfo() throws SQLException, EnableException { + ServerProperties variable = plugin.getVariable(); UUID serverUUID = generateNewUUID(variable); String accessAddress = plugin.getWebServer().getAccessAddress(); serverTable.saveCurrentServerInfo( - new ServerInfo(-1, serverUUID, "BungeeCord", accessAddress, variable.getMaxPlayers()) + new Server(-1, serverUUID, "BungeeCord", accessAddress, variable.getMaxPlayers()) ); - Optional bungeeInfo = db.getServerTable().getBungeeInfo(); + Optional bungeeInfo = db.getServerTable().getBungeeInfo(); if (bungeeInfo.isPresent()) { return bungeeInfo.get(); } throw new EnableException("BungeeCord registration failed (DB)"); } - private UUID generateNewUUID(ServerVariableHolder variableHolder) { + private UUID generateNewUUID(ServerProperties variableHolder) { String seed = variableHolder.getName() + variableHolder.getIp() + variableHolder.getPort() + variableHolder.getVersion() + variableHolder.getImplVersion(); return UUID.nameUUIDFromBytes(seed.getBytes()); } public UUID getServerUUID() { - return serverInfo.getUuid(); + return server.getUuid(); } - public boolean attemptConnection(ServerInfo server, String accessCode) { + public boolean attemptConnection(Server server, String accessCode) { if (server == null) { - Log.debug("Attempted a connection to a null ServerInfo"); + Log.debug("Attempted a connection to a null Server"); return false; } try { String webAddress = server.getWebAddress(); Log.debug("Attempting to connect to Bukkit server.. (" + webAddress + ")"); - PingWebAPI pingApi = plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class); - if (accessCode != null) { - pingApi.sendRequest(webAddress, accessCode); plugin.getWebServer().getWebAPI().getAPI(ConfigurationWebAPI.class).sendRequest(webAddress, server.getUuid(), accessCode); - } else { - pingApi.sendRequest(webAddress); - } connectedToServer(server); return true; } catch (WebException e) { @@ -111,14 +103,14 @@ public boolean attemptConnection(ServerInfo server, String accessCode) { } } - public boolean attemptConnection(ServerInfo server) { + public boolean attemptConnection(Server server) { return attemptConnection(server, null); } public void sendConfigSettings(UUID serverUUID) { String webAddress = null; try { - ServerInfo server = bukkitServers.get(serverUUID); + Server server = bukkitServers.get(serverUUID); if (server == null) { return; } @@ -131,7 +123,7 @@ public void sendConfigSettings(UUID serverUUID) { } } - public void connectedToServer(ServerInfo server) { + public void connectedToServer(Server server) { Log.info("Connection to Bukkit (" + server.getWebAddress() + ") OK"); bukkitServers.put(server.getUuid(), server); onlineServers.add(server.getUuid()); @@ -154,9 +146,9 @@ public void run() { return true; } try { - Optional serverInfo = db.getServerTable().getServerInfo(serverUUID); + Optional serverInfo = db.getServerTable().getServerInfo(serverUUID); if (serverInfo.isPresent()) { - ServerInfo server = serverInfo.get(); + Server server = serverInfo.get(); Log.info("Server Info found from DB: " + server.getName()); RunnableFactory.createNew("BukkitConnectionTask: " + server.getName(), new AbsRunnable() { @Override @@ -174,14 +166,14 @@ public void run() { return false; } - public Collection getOnlineBukkitServers() { + public Collection getOnlineBukkitServers() { return bukkitServers.entrySet().stream() .filter(entry -> onlineServers.contains(entry.getKey())) .map(Map.Entry::getValue) .collect(Collectors.toSet()); } - public Collection getBukkitServers() { + public Collection getBukkitServers() { return bukkitServers.values(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java new file mode 100644 index 0000000000..cd54ad203e --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java @@ -0,0 +1,88 @@ +/* + * 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.info.server; + +import java.util.Objects; +import java.util.UUID; + +/** + * Represents a Server that is running Plan. + * + * @author Rsl1122 + */ +public class Server { + private final UUID uuid; + private int id; + private String name; + private String webAddress; + private int maxPlayers = -1; + + public Server(int id, UUID uuid, String name, String webAddress, int maxPlayers) { + this.id = id; + this.uuid = uuid; + this.name = name; + this.webAddress = webAddress; + this.maxPlayers = maxPlayers; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public UUID getUuid() { + return uuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getWebAddress() { + return webAddress; + } + + public void setWebAddress(String webAddress) { + this.webAddress = webAddress; + } + + public int getMaxPlayers() { + return maxPlayers; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Server that = (Server) o; + return id == that.id && + Objects.equals(uuid, that.uuid) && + Objects.equals(name, that.name) && + Objects.equals(webAddress, that.webAddress); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, id, name, webAddress); + } + + @Override + public String toString() { + return "Server{" + + "uuid=" + uuid + + ", id=" + id + + ", name='" + name + '\'' + + ", webAddress='" + webAddress + '\'' + + ", maxPlayers=" + maxPlayers + + '}'; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfo.java index cc103e77a4..9ef1899560 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfo.java @@ -4,85 +4,63 @@ */ package com.djrapitops.plan.system.info.server; -import java.util.Objects; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.utilities.NullCheck; + import java.util.UUID; /** - * Represents a Server that is running Plan. + * SubSystem for managing Server information. + * + * Most information is accessible via static methods. * * @author Rsl1122 */ -public class ServerInfo { - private final UUID uuid; - private int id; - private String name; - private String webAddress; - private int maxPlayers = -1; - - public ServerInfo(int id, UUID uuid, String name, String webAddress, int maxPlayers) { - this.id = id; - this.uuid = uuid; - this.name = name; - this.webAddress = webAddress; - this.maxPlayers = maxPlayers; - } - - public int getId() { - return id; - } +public abstract class ServerInfo implements SubSystem { - public void setId(int id) { - this.id = id; - } + protected Server server; + protected ServerProperties serverProperties; - public UUID getUuid() { - return uuid; + public static ServerInfo getInstance() { + ServerInfo serverInfo = PlanSystem.getInstance().getServerInfo(); + NullCheck.check(serverInfo, new IllegalStateException("ServerInfo was not initialized.")); + return serverInfo; } - public String getName() { - return name; + public static Server getServer() { + return getInstance().server; } - public void setName(String name) { - this.name = name; + public static ServerProperties getServerProperties() { + return getInstance().serverProperties; } - public String getWebAddress() { - return webAddress; + public static UUID getServerUUID() { + return getServer().getUuid(); } - public void setWebAddress(String webAddress) { - this.webAddress = webAddress; + public static String getServerName() { + return getServer().getName(); } - public int getMaxPlayers() { - return maxPlayers; + public static int getServerID() { + return getServer().getId(); } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ServerInfo that = (ServerInfo) o; - return id == that.id && - Objects.equals(uuid, that.uuid) && - Objects.equals(name, that.name) && - Objects.equals(webAddress, that.webAddress); + public void enable() throws EnableException { + // ServerProperties are required when creating Server + NullCheck.check(serverProperties, new IllegalStateException("Server Properties did not load!")); + server = loadServerInfo(); + NullCheck.check(server, new IllegalStateException("Server information did not load!")); } - @Override - public int hashCode() { - return Objects.hash(uuid, id, name, webAddress); - } + protected abstract Server loadServerInfo() throws EnableException; @Override - public String toString() { - return "ServerInfo{" + - "uuid=" + uuid + - ", id=" + id + - ", name='" + name + '\'' + - ", webAddress='" + webAddress + '\'' + - ", maxPlayers=" + maxPlayers + - '}'; + public void disable() { + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java index 2a1ad5d5c9..e3f12d5c37 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java @@ -4,8 +4,7 @@ */ package com.djrapitops.plan.system.info.server; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.utilities.file.FileUtil; +import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -18,28 +17,20 @@ /** * Manages local server info file. *

- * ServerInfo.yml contains current server's ID, UUID and Bungee WebServer connection information. + * Server.yml contains current server's ID, UUID and Bungee WebServer connection information. * It * * @author Rsl1122 */ public class ServerInfoFile extends Config { - public ServerInfoFile(Plan plugin) throws IOException { - super(new File(plugin.getDataFolder(), "ServerInfoFile.yml")); - copyDefaults(FileUtil.lines(plugin, "DefaultServerInfoFile.yml")); + public ServerInfoFile(File dataFolder) throws IOException { + super(new File(dataFolder, "ServerInfoFile.yml")); + copyDefaults(FileSystem.readFromResource("DefaultServerInfoFile.yml")); save(); } - public void saveInfo(ServerInfo thisServer, ServerInfo bungee) throws IOException { - set("Server.UUID", thisServer.getUuid().toString()); - - String oldAddress = getString("Bungee.WebAddress"); - String newAddress = bungee.getWebAddress(); - - if (!newAddress.equals(oldAddress)) { - set("Bungee.Fail", 0); - set("Bungee.WebAddress", newAddress); - } + public void saveServerUUID(UUID serverUUID) throws IOException { + set("Server.UUID", serverUUID.toString()); save(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java new file mode 100644 index 0000000000..8835512fc0 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java @@ -0,0 +1,83 @@ +package com.djrapitops.plan.system.info.server; + +import com.djrapitops.plan.system.settings.Settings; +import net.md_5.bungee.api.ProxyServer; +import org.bukkit.Server; + +/** + * Class responsible for holding server variable values that do not change + * without a reload. + * + * @author Rsl1122 + * @since 3.4.1 + */ +public class ServerProperties { + + private final String id; + private final String name; + private final int port; + private final String version; + private final String implVersion; + private final String ip; + private final int maxPlayers; + + public ServerProperties(Server server) { + id = server.getServerId(); + ip = server.getIp(); + name = server.getName(); + port = server.getPort(); + version = server.getVersion(); + implVersion = server.getBukkitVersion(); + + maxPlayers = server.getMaxPlayers(); + } + + /** + * Constructor, grabs the variables. + * + * @param server instance the plugin is running on. + */ + public ServerProperties(ProxyServer server) { + id = server.getServers().toString(); + ip = Settings.BUNGEE_IP.toString(); + name = "BungeeCord"; + port = -1; + version = server.getVersion(); + implVersion = server.getVersion(); + + maxPlayers = server.getConfig().getPlayerLimit(); + } + + /** + * Ip string in server.properties. + * + * @return the ip. + */ + public String getIp() { + return ip; + } + + public String getName() { + return name; + } + + public int getPort() { + return port; + } + + public String getVersion() { + return version; + } + + public String getImplVersion() { + return implVersion; + } + + public int getMaxPlayers() { + return maxPlayers; + } + + public String getServerId() { + return id; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 1033ef419c..561781dae7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -6,12 +6,12 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.info.server.BungeeServerInfo; +import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; -import com.djrapitops.plan.system.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.Benchmark; @@ -66,7 +66,7 @@ private String buildParagraph() { private void appendServerInformation(StringBuilder content) { PlanPlugin plugin = PlanPlugin.getInstance(); - ServerVariableHolder variable = plugin.getVariable(); + ServerProperties variable = plugin.getVariable(); content.append("

### Server Information
") .append("**Plan Version:** ").append(plugin.getVersion()).append("
"); @@ -134,13 +134,13 @@ private void appendConfig(StringBuilder content) { private void appendBungeeConfiguration(StringBuilder content) { PlanBungee plugin = PlanBungee.getInstance(); - BungeeServerInfoManager serverInfoManager = plugin.getServerInfoManager(); - Collection online = serverInfoManager.getOnlineBukkitServers(); - Collection bukkitServers = serverInfoManager.getBukkitServers(); + BungeeServerInfo serverInfoManager = plugin.getServerInfoManager(); + Collection online = serverInfoManager.getOnlineBukkitServers(); + Collection bukkitServers = serverInfoManager.getBukkitServers(); if (!bukkitServers.isEmpty()) { content.append("

If your issue is about Bungee-Bukkit connection relations, please include the following debug information of available servers as well:

"); - for (ServerInfo info : bukkitServers) { + for (Server info : bukkitServers) { String link = Html.LINK.parse(info.getWebAddress() + "/debug", info.getWebAddress() + "/debug"); content.append("

").append(link).append("

"); } @@ -150,7 +150,7 @@ private void appendBungeeConfiguration(StringBuilder content) { content.append("Server name | Online | Address | UUID
") .append("-- | -- | -- | --
"); - for (ServerInfo info : bukkitServers) { + for (Server info : bukkitServers) { content.append(info.getName()).append(" | ") .append(online.contains(info) ? "Online" : "Offline").append(" | ") .append(info.getWebAddress()).append(" | ") diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index e26295e998..a39a66120d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; @@ -62,8 +62,8 @@ public void sendRequestsToBukkitServers(PlanPlugin plugin, UUID uuid) { @Override public void process() { try { - List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); - for (ServerInfo server : bukkitServers) { + List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); + for (Server server : bukkitServers) { String webAddress = server.getWebAddress(); try { plugin.getWebServer().getWebAPI().getAPI(RequestInspectPluginsTabBukkitWebAPI.class).sendRequest(webAddress, uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index a61327ec1e..9d898a6510 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -9,10 +9,10 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -43,9 +43,9 @@ public Response onRequest(PlanPlugin plugin, Map variables) { if (!Verify.notNull(serverUUIDS, webAddress, accessCode)) { return badRequest("Variable was null"); } - ServerInfo serverInfo = new ServerInfo(-1, UUID.fromString(serverUUIDS), "", webAddress, 0); + Server server = new Server(-1, UUID.fromString(serverUUIDS), "", webAddress, 0); - ((PlanBungee) plugin).getServerInfoManager().attemptConnection(serverInfo, accessCode); + ((PlanBungee) plugin).getServerInfoManager().attemptConnection(server, accessCode); return success(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java deleted file mode 100644 index 9ad15501ab..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/universal/PingWebAPI.java +++ /dev/null @@ -1,62 +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.system.webserver.webapi.universal; - - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.info.BukkitInformationManager; -import com.djrapitops.plugin.api.Check; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.io.IOException; -import java.util.Map; -import java.util.UUID; - -/** - * @author Rsl1122 - */ -public class PingWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - if (Check.isBungeeAvailable()) { - if (!((PlanBungee) plugin).getServerInfoManager().serverConnected(UUID.fromString(variables.get("sender")))) { - return fail("Server info not found from the database"); - } - } else if (!plugin.getInfoManager().isUsingAnotherWebServer()) { - try { - String webAddress = variables.get("webAddress"); - if (webAddress != null) { - ((Plan) plugin).getServerInfoManager().saveBungeeConnectionAddress(webAddress); - } - - ((BukkitInformationManager) plugin.getInfoManager()).updateConnection(); - } catch (IOException e) { - Log.toLog(this.getClass().getName(), e); - } - } - return success(); - } - - @Override - public void sendRequest(String address) throws WebException { - if (Check.isBukkitAvailable()) { - super.sendRequest(address); - } else { - addVariable("webAddress", PlanBungee.getInstance().getWebServer().getAccessAddress()); - super.sendRequest(address); - } - } - - public void sendRequest(String address, String accessCode) throws WebException { - addVariable("accessKey", accessCode); - addVariable("version", PlanPlugin.getInstance().getVersion()); - sendRequest(address); - } -} \ No newline at end of file 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 index c893665242..443b21d912 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -34,7 +34,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.*; -import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI; import com.djrapitops.plan.systems.info.parsing.AnalysisPage; import com.djrapitops.plan.systems.info.parsing.InspectPage; import com.djrapitops.plan.utilities.MiscUtils; @@ -336,9 +335,9 @@ public boolean attemptConnection() { try { Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")"); - PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class); +// PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class); try { - api.sendRequest(webServerAddress); +// api.sendRequest(webServerAddress); getWebAPI().getAPI(PostOriginalBukkitSettingsWebAPI.class).sendRequest(webServerAddress); Log.info("Bungee Connection OK"); plugin.getServerInfoManager().resetConnectionFails(); 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 index fa560f0464..2898853dd4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -11,8 +11,8 @@ import com.djrapitops.plan.api.exceptions.connection.NotFoundException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.BungeeServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.PageId; @@ -50,8 +50,8 @@ public class BungeeInformationManager extends InformationManager { private final PlanBungee plugin; private final Map networkPageContent; private final Map> pluginsTabContent; - private final BungeeServerInfoManager serverInfoManager; - private Map bukkitServers; + private final BungeeServerInfo serverInfoManager; + private Map bukkitServers; public BungeeInformationManager(PlanBungee plugin) { usingAnotherWebServer = false; @@ -68,7 +68,7 @@ public BungeeInformationManager(PlanBungee plugin) { * @throws SQLException If DB Error occurs. */ private void refreshBukkitServerMap() { - bukkitServers = plugin.getDB().getServerTable().getBukkitServers().stream().collect(Collectors.toMap(ServerInfo::getUuid, Function.identity())); + bukkitServers = plugin.getDB().getServerTable().getBukkitServers().stream().collect(Collectors.toMap(Server::getUuid, Function.identity())); } /** @@ -83,14 +83,14 @@ public void refreshAnalysis(UUID serverUUID) { if (PlanBungee.getServerUUID().equals(serverUUID)) { return; } - ServerInfo serverInfo = getOnlineServerInfo(serverUUID); - if (serverInfo == null) { + Server server = getOnlineServerInfo(serverUUID); + if (server == null) { return; } AnalyzeWebAPI api = plugin.getWebServer().getWebAPI().getAPI(AnalyzeWebAPI.class); try { - api.sendRequest(serverInfo.getWebAddress(), serverUUID); + api.sendRequest(server.getWebAddress(), serverUUID); } catch (ConnectionFailException e) { attemptConnection(); } catch (WebException e) { @@ -104,24 +104,24 @@ public void refreshAnalysis(UUID serverUUID) { * Returns null if server doesn't exist. * * @param serverUUID UUID of server - * @return Online ServerInfo or null + * @return Online Server or null */ - private ServerInfo getOnlineServerInfo(UUID serverUUID) { - ServerInfo serverInfo = bukkitServers.get(serverUUID); - if (serverInfo == 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); } - serverInfo = bukkitServers.get(serverUUID); + server = bukkitServers.get(serverUUID); } - if (serverInfo == null) { + if (server == null) { return null; } - if (serverInfoManager.getOnlineBukkitServers().contains(serverInfo) || serverInfoManager.attemptConnection(serverInfo)) { - return serverInfo; + if (serverInfoManager.getOnlineBukkitServers().contains(server) || serverInfoManager.attemptConnection(server)) { + return server; } return null; } @@ -137,7 +137,7 @@ private ServerInfo getOnlineServerInfo(UUID serverUUID) { */ @Override public void cachePlayer(UUID uuid) { - ServerInfo inspectServer = null; + Server inspectServer = null; try { inspectServer = getInspectRequestProcessorServer(uuid); @@ -153,17 +153,17 @@ public void cachePlayer(UUID uuid) { } /** - * Get ServerInfo of an online server that should process an inspect request. + * Get Server of an online server that should process an inspect request. *

* If the player is online, an attempt to use the server where the player resides is made. *

* If the player is offline or in the lobby, any server can be used. * * @param uuid UUID of the player - * @return ServerInfo of the server that should handle the request. + * @return Server of the server that should handle the request. * @throws IllegalStateException If no Bukkit servers are online. */ - private ServerInfo getInspectRequestProcessorServer(UUID uuid) { + private Server getInspectRequestProcessorServer(UUID uuid) { if (bukkitServers.isEmpty()) { try { refreshBukkitServerMap(); @@ -175,9 +175,9 @@ private ServerInfo getInspectRequestProcessorServer(UUID uuid) { } } - Collection onlineServers = serverInfoManager.getOnlineBukkitServers(); + Collection onlineServers = serverInfoManager.getOnlineBukkitServers(); if (plugin.getProxy().getPlayer(uuid) != null) { - for (ServerInfo server : onlineServers) { + for (Server server : onlineServers) { try { getWebAPI().getAPI(IsOnlineWebAPI.class).sendRequest(server.getWebAddress(), uuid); return server; @@ -191,7 +191,7 @@ private ServerInfo getInspectRequestProcessorServer(UUID uuid) { } } - Optional bukkitServer = serverInfoManager.getOnlineBukkitServers().stream().findAny(); + Optional bukkitServer = serverInfoManager.getOnlineBukkitServers().stream().findAny(); if (bukkitServer.isPresent()) { return bukkitServer.get(); } @@ -218,8 +218,8 @@ public DataCache getDataCache() { @Override public boolean attemptConnection() { try { - List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); - for (ServerInfo server : bukkitServers) { + List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); + for (Server server : bukkitServers) { serverInfoManager.attemptConnection(server); } } catch (SQLException e) { @@ -361,9 +361,9 @@ public Map getNetworkPageContent() { @Override public void analysisReady(UUID serverUUID) { AnalysisReadyWebAPI api = getWebAPI().getAPI(AnalysisReadyWebAPI.class); - for (ServerInfo serverInfo : serverInfoManager.getOnlineBukkitServers()) { + for (Server server : serverInfoManager.getOnlineBukkitServers()) { try { - api.sendRequest(serverInfo.getWebAddress(), serverUUID); + api.sendRequest(server.getWebAddress(), serverUUID); } catch (WebException ignored) { /*Ignored*/ } @@ -380,8 +380,8 @@ public void updateNetworkPageContent() { } public void sendConfigSettings() { - Collection online = serverInfoManager.getOnlineBukkitServers(); - online.stream().map(ServerInfo::getUuid) + Collection online = serverInfoManager.getOnlineBukkitServers(); + online.stream().map(Server::getUuid) .forEach(serverInfoManager::sendConfigSettings); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java index e8785e160d..cf7de9f89e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java @@ -236,7 +236,7 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp())); - if (!InfoSystem.getInstance().getConnectionSystem().isServerAvailable()) { + if (!InfoSystem.getInstance().getConnectionSystem().isMainServerAvailable()) { addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 0ae910ee0e..72c021ccce 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -5,10 +5,11 @@ package com.djrapitops.plan.utilities.html; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.utilities.FormatUtils; @@ -107,13 +108,13 @@ public static String createNetworkPageContent(Map networkPageConte } public static String createServerContainer(Plan plugin) { - ServerVariableHolder variable = plugin.getVariable(); + ServerProperties variable = plugin.getVariable(); int maxPlayers = variable.getMaxPlayers(); int online = plugin.getServer().getOnlinePlayers().size(); Optional analysisRefreshDate = ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisRefreshDate(); String refresh = analysisRefreshDate.map(FormatUtils::formatTimeStamp).orElse("-"); - String serverName = plugin.getServerInfoManager().getServerName(); + String serverName = ServerInfo.getServerName(); String serverType = variable.getVersion(); String address = "../server/" + serverName; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java index b7b1ed8adc..46f9f383b9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java @@ -7,7 +7,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.system.info.server.BukkitServerInfoManager; +import com.djrapitops.plan.system.info.server.BukkitServerInfo; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator; import java.util.ArrayList; @@ -22,9 +23,9 @@ public class InspectPluginsTabContentCreator { public static String[] createContent(Map containers) { - BukkitServerInfoManager serverInfoManager = Plan.getInstance().getServerInfoManager(); - String serverName = serverInfoManager.getServerName(); - String actualServerName = serverName.equals("Plan") ? "Server " + serverInfoManager.getServerID() : serverName; + BukkitServerInfo serverInfoManager = Plan.getInstance().getServerInfoManager(); + String serverName = ServerInfo.getServerName(); + String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName; if (containers.isEmpty()) { return new String[]{"

  • " + actualServerName + "(No Data)
  • ", diff --git a/Plan/src/main/resources/DefaultServerInfoFile.yml b/Plan/src/main/resources/DefaultServerInfoFile.yml index 1afc6c0e9a..3978cd4d5a 100644 --- a/Plan/src/main/resources/DefaultServerInfoFile.yml +++ b/Plan/src/main/resources/DefaultServerInfoFile.yml @@ -2,6 +2,3 @@ # Thread with caution. Server: UUID: -Bungee: - WebAddress: '' - Fail: 1 diff --git a/Plan/test/main/java/com/djrapitops/plan/ServerVariableHolderTest.java b/Plan/test/main/java/com/djrapitops/plan/ServerVariableHolderTest.java deleted file mode 100644 index 008cc37746..0000000000 --- a/Plan/test/main/java/com/djrapitops/plan/ServerVariableHolderTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.djrapitops.plan; - -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.TestInit; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertFalse; - -/** - * @author Fuzzlemann - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) -public class ServerVariableHolderTest { - - @Before - public void setUp() throws Exception { - TestInit.init(); - } - - @Test - public void testServerVariable() { - boolean usingPaper = Plan.getInstance().getVariable().isUsingPaper(); - assertFalse(usingPaper); - - String exp = Plan.getInstance().getVariable().getIp(); - assertEquals(exp, "0.0.0.0"); - } -} diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index b7a6b3febc..4224349457 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -19,8 +19,8 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; @@ -83,7 +83,7 @@ public void markFirstSession(UUID uuid) { }; when(plan.getDataCache()).thenReturn(dataCache); - db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20)); + db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20)); File f = new File(plan.getDataFolder(), "Errors.txt"); rows = FileUtil.lines(f).size(); @@ -691,11 +691,11 @@ private void saveAllData(Database database) throws SQLException { public void testServerTableBungeeSave() throws SQLException, DBInitException { ServerTable serverTable = db.getServerTable(); - Optional bungeeInfo = serverTable.getBungeeInfo(); + Optional bungeeInfo = serverTable.getBungeeInfo(); assertFalse(bungeeInfo.isPresent()); UUID bungeeUUID = UUID.randomUUID(); - ServerInfo bungeeCord = new ServerInfo(-1, bungeeUUID, "BungeeCord", "Random:1234", 20); + Server bungeeCord = new Server(-1, bungeeUUID, "BungeeCord", "Random:1234", 20); serverTable.saveCurrentServerInfo(bungeeCord); commitTest(); @@ -716,7 +716,7 @@ public void testServerTableBungee() throws SQLException, DBInitException { testServerTableBungeeSave(); ServerTable serverTable = db.getServerTable(); - List bukkitServers = serverTable.getBukkitServers(); + List bukkitServers = serverTable.getBukkitServers(); assertEquals(1, bukkitServers.size()); } diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index 2573071901..f2ee6dee79 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; -import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.bukkit.BukkitCMDSender; @@ -166,7 +166,7 @@ private void setupDatabase() throws Exception { db = new SQLiteDB("debug" + MiscUtils.getTime()); db.init(); - db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20)); + db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20)); when(plan.getDB()).thenReturn(db); } diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index d2731611a8..980a0bf825 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -1,10 +1,11 @@ package test.utilities; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.ServerVariableHolder; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.info.server.BukkitServerInfoManager; +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.settings.Settings; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.IPlugin; @@ -119,10 +120,10 @@ public void save() { when(planMock.getLogger()).thenReturn(Logger.getGlobal()); Settings.DEBUG.setTemporaryValue(true); - ServerVariableHolder serverVariableHolder = new ServerVariableHolder(mockServer); + ServerProperties serverProperties = new ServerProperties(mockServer); - when(planMock.getVariable()).thenReturn(serverVariableHolder); - BukkitServerInfoManager bukkitServerInfoManager = PowerMockito.mock(BukkitServerInfoManager.class); + when(planMock.getVariable()).thenReturn(serverProperties); + BukkitServerInfo bukkitServerInfo = PowerMockito.mock(BukkitServerInfo.class); DataCache dataCache = new DataCache(planMock) { @Override @@ -132,9 +133,9 @@ public String getName(UUID uuid) { }; when(planMock.getDataCache()).thenReturn(dataCache); - when(bukkitServerInfoManager.getServerUUID()).thenReturn(serverUUID); + when(ServerInfo.getServerUUID()).thenReturn(serverUUID); when(planMock.getServerUuid()).thenReturn(serverUUID); - when(planMock.getServerInfoManager()).thenReturn(bukkitServerInfoManager); + when(planMock.getServerInfoManager()).thenReturn(bukkitServerInfo); ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK); when(planMock.getColorScheme()).thenReturn(cs); initLocale(null); From a22aa95c22410e34495bfae0ecf6376233c4a3dd Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 19 Jan 2018 12:26:29 +0200 Subject: [PATCH 033/166] Refactored Graphs to be Objects. Sensible after "Creator" name removal. --- .../djrapitops/plan/ServerVariableHolder.java | 97 ------------------- .../djrapitops/plan/data/AnalysisData.java | 30 +++--- .../plan/data/element/ActivityIndex.java | 4 + .../systems/info/parsing/InspectPage.java | 12 +-- .../systems/info/parsing/NetworkPage.java | 4 +- .../plan/utilities/html/HtmlStructure.java | 6 +- .../html/graphs/ActivityStackGraph.java | 48 ++++++--- .../plan/utilities/html/graphs/HighChart.java | 16 +++ .../utilities/html/graphs/PunchCardGraph.java | 25 +++-- .../plan/utilities/html/graphs/WorldMap.java | 65 +++++++------ .../html/graphs/line/AbstractLineGraph.java | 78 +++++++++++++++ .../utilities/html/graphs/line/CPUGraph.java | 21 ++-- .../html/graphs/line/ChunkGraph.java | 27 ++++++ .../html/graphs/line/EntityGraph.java | 27 ++++++ .../html/graphs/line/LineSeries.java | 56 ----------- ...ityGraph.java => OnlineActivityGraph.java} | 18 ++-- .../utilities/html/graphs/line/RamGraph.java | 27 ++---- .../html/graphs/line/ServerPreferencePie.java | 33 ------- .../utilities/html/graphs/line/TPSGraph.java | 20 ++-- .../html/graphs/line/WorldLoadGraph.java | 51 ---------- .../{PieSeries.java => AbstractPieChart.java} | 33 ++++++- .../pie/AbstractPieChartWithDrilldown.java | 25 +++++ .../html/graphs/pie/ActivityPie.java | 25 +++-- .../utilities/html/graphs/pie/PieSlice.java | 16 ++- .../html/graphs/pie/ServerPreferencePie.java | 31 ++++++ .../utilities/html/graphs/pie/WorldPie.java | 43 ++++---- .../structure/ServerAccordionCreator.java | 6 +- .../structure/SessionTabStructureCreator.java | 6 +- .../djrapitops/plan/ui/graphs/GraphTest.java | 84 ++++------------ 29 files changed, 444 insertions(+), 490 deletions(-) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/HighChart.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/AbstractLineGraph.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ChunkGraph.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/EntityGraph.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/LineSeries.java rename Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/{PlayerActivityGraph.java => OnlineActivityGraph.java} (50%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ServerPreferencePie.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java rename Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/{PieSeries.java => AbstractPieChart.java} (50%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/AbstractPieChartWithDrilldown.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ServerPreferencePie.java diff --git a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java b/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java deleted file mode 100644 index a4e96366ea..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/ServerVariableHolder.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.djrapitops.plan; - -import com.djrapitops.plan.system.settings.Settings; -import net.md_5.bungee.api.ProxyServer; -import org.bukkit.Server; - -/** - * Class responsible for holding server variable values that do not change - * without a reload. - * - * @author Rsl1122 - * @since 3.4.1 - */ -public class ServerVariableHolder { - - private final String name; - private final int port; - private final String version; - private final String implVersion; - private final String ip; - private final int maxPlayers; - private final boolean usingPaper; - - /** - * Constructor, grabs the variables. - * - * @param server instance the plugin is running on. - */ - public ServerVariableHolder(Server server) { - ip = server.getIp(); - name = server.getName(); - port = server.getPort(); - version = server.getVersion(); - implVersion = server.getBukkitVersion(); - - maxPlayers = server.getMaxPlayers(); - - usingPaper = name.equals("Paper") - || name.equals("TacoSpigot"); //Fork of Paper - } - - /** - * Constructor, grabs the variables. - * - * @param server instance the plugin is running on. - */ - public ServerVariableHolder(ProxyServer server) { - ip = Settings.BUNGEE_IP.toString(); - name = "BungeeCord"; - port = -1; - version = server.getVersion(); - implVersion = server.getVersion(); - - maxPlayers = server.getConfig().getPlayerLimit(); - - usingPaper = false; - } - - /** - * Ip string in server.properties. - * - * @return the ip. - */ - public String getIp() { - return ip; - } - - /** - * Returns if the server is using PaperSpigot. - * - * @return if the server is using PaperSpigot. - */ - @Deprecated - public boolean isUsingPaper() { - return usingPaper; - } - - public String getName() { - return name; - } - - public int getPort() { - return port; - } - - public String getVersion() { - return version; - } - - public String getImplVersion() { - return implVersion; - } - - public int getMaxPlayers() { - return maxPlayers; - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java index 20473945e2..d7671546eb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java @@ -144,11 +144,11 @@ private void healthTab(long now, List players, List tpsDataM Map> activityNow = activityData.getOrDefault(now, new HashMap<>()); - String[] activityStackSeries = ActivityStackGraph.createSeries(activityData); - String activityPieSeries = ActivityPie.createSeries(activityNow); + ActivityStackGraph activityStackGraph = new ActivityStackGraph(activityData); + String activityPieSeries = new ActivityPie(activityNow).toHighChartsSeries(); - addValue("activityStackCategories", activityStackSeries[0]); - addValue("activityStackSeries", activityStackSeries[1]); + addValue("activityStackCategories", activityStackGraph.toHighChartsLabels()); + addValue("activityStackSeries", activityStackGraph.toHighChartsSeries()); addValue("activityPieSeries", activityPieSeries); Set veryActiveNow = activityNow.getOrDefault("Very Active", new HashSet<>()); @@ -171,7 +171,7 @@ private void commandUsage(Map commandUsage) { } private void geolocationsTab(List geoLocations) { - addValue("geoMapSeries", WorldMap.createSeries(geoLocations)); + addValue("geoMapSeries", new WorldMap(geoLocations).toHighChartsSeries()); } private void onlineActivityNumbers(ServerProfile profile, Map> sessions, List players) { @@ -286,7 +286,7 @@ private void sessionData(long monthAgo, Map> sessions, List< addValue("tableBodySessions", tables[0]); addValue("listRecentLogins", tables[1]); addValue("sessionAverage", FormatUtils.formatTimeAmount(MathUtils.averageLong(allSessions.stream().map(Session::getLength)))); - addValue("punchCardSeries", PunchCardGraph.createSeries(sessionsMonth)); + addValue("punchCardSeries", new PunchCardGraph(sessionsMonth).toHighChartsSeries()); addValue("deaths", ServerProfile.getDeathCount(allSessions)); addValue("mobKillCount", ServerProfile.getMobKillCount(allSessions)); @@ -303,9 +303,9 @@ private void directProfileVariables(ServerProfile profile) { Html.TABLE_PLAYERS_FOOTER.parse(playersTableBody) : Html.TABLE_PLAYERS.parse(playersTableBody)); addValue("worldTotal", FormatUtils.formatTimeAmount(worldTimes.getTotal())); - String[] seriesData = WorldPie.createSeries(worldTimes); - addValue("worldSeries", seriesData[0]); - addValue("gmSeries", seriesData[1]); + WorldPie worldPie = new WorldPie(worldTimes); + addValue("worldSeries", worldPie.toHighChartsSeries()); + addValue("gmSeries", worldPie.toHighChartsDrilldown()); addValue("lastPeakTime", lastPeak != -1 ? FormatUtils.formatTimeStampYear(lastPeak) : "No Data"); addValue("playersLastPeak", lastPeak != -1 ? profile.getLastPeakPlayers() : "-"); addValue("bestPeakTime", allTimePeak != -1 ? FormatUtils.formatTimeStampYear(allTimePeak) : "No Data"); @@ -320,12 +320,12 @@ private void performanceTab(List tpsData, List tpsDataDay, List t addValue("tpsSpikeWeek", value("tpsSpikeWeek")); addValue("tpsSpikeDay", value("tpsSpikeDay")); - addValue("playersOnlineSeries", PlayerActivityGraph.createSeries(tpsData)); - addValue("tpsSeries", TPSGraph.createSeries(tpsData)); - addValue("cpuSeries", CPUGraph.createSeries(tpsData)); - addValue("ramSeries", RamGraph.createSeries(tpsData)); - addValue("entitySeries", WorldLoadGraph.createSeriesEntities(tpsData)); - addValue("chunkSeries", WorldLoadGraph.createSeriesChunks(tpsData)); + addValue("playersOnlineSeries", new OnlineActivityGraph(tpsData).toHighChartsSeries()); + addValue("tpsSeries", new TPSGraph(tpsData).toHighChartsSeries()); + addValue("cpuSeries", new CPUGraph(tpsData).toHighChartsSeries()); + addValue("ramSeries", new RamGraph(tpsData).toHighChartsSeries()); + addValue("entitySeries", new EntityGraph(tpsData).toHighChartsSeries()); + addValue("chunkSeries", new ChunkGraph(tpsData).toHighChartsSeries()); double averageCPUMonth = MathUtils.averageDouble(tpsDataMonth.stream().map(TPS::getCPUUsage).filter(i -> i != 0)); double averageCPUWeek = MathUtils.averageDouble(tpsDataWeek.stream().map(TPS::getCPUUsage).filter(i -> i != 0)); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java index e719e86d37..bbd773da82 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java @@ -21,6 +21,10 @@ private static long loadSetting(long value) { return value < 0 ? 1 : value; } + public static String[] getGroups() { + return new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"}; + } + private double calculate(PlayerProfile player, long date) { long week = TimeAmount.WEEK.ms(); long weekAgo = date - week; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java index cf7de9f89e..1838aa9981 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java @@ -27,7 +27,7 @@ import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plan.utilities.html.graphs.PunchCardGraph; -import com.djrapitops.plan.utilities.html.graphs.line.ServerPreferencePie; +import com.djrapitops.plan.utilities.html.graphs.pie.ServerPreferencePie; import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie; import com.djrapitops.plan.utilities.html.structure.ServerAccordionCreator; import com.djrapitops.plan.utilities.html.tables.ActionsTableCreator; @@ -110,7 +110,7 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se } Map worldTimesPerServer = profile.getWorldTimesPerServer(); - addValue("serverPieSeries", ServerPreferencePie.createSeries(serverNames, worldTimesPerServer)); + addValue("serverPieSeries", new ServerPreferencePie(serverNames, worldTimesPerServer).toHighChartsSeries()); addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE)); addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE)); addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE)); @@ -197,14 +197,14 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se List actions = profile.getAllActions(); addValue("tableBodyActions", ActionsTableCreator.createTable(actions)); - String punchCardData = PunchCardGraph.createSeries(allSessions); + String punchCardData = new PunchCardGraph(allSessions).toHighChartsSeries(); WorldTimes worldTimes = profile.getWorldTimes(); AnalysisUtils.addMissingWorlds(worldTimes); - String[] worldPieData = WorldPie.createSeries(worldTimes); + WorldPie worldPie = new WorldPie(worldTimes); - addValue("worldPieSeries", worldPieData[0]); - addValue("gmSeries", worldPieData[1]); + addValue("worldPieSeries", worldPie.toHighChartsSeries()); + addValue("gmSeries", worldPie.toHighChartsDrilldown()); addValue("punchCardSeries", punchCardData); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java index 013d7c1123..10b0c82c28 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java @@ -20,7 +20,7 @@ import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plan.utilities.html.HtmlUtils; -import com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraph; +import com.djrapitops.plan.utilities.html.graphs.line.OnlineActivityGraph; import com.djrapitops.plugin.api.TimeAmount; import java.util.List; @@ -56,7 +56,7 @@ public String toHtml() throws ParseException { addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); addValue("networkName", Settings.BUNGEE_NETWORK_NAME.toString()); addValue("version", plugin.getVersion()); - addValue("playersOnlineSeries", PlayerActivityGraph.createSeries(networkOnlineData)); + addValue("playersOnlineSeries", new OnlineActivityGraph(networkOnlineData).toHighChartsSeries()); addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE)); addValue("playersOnline", plugin.getProxy().getOnlineCount()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 72c021ccce..7a85e4375f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -13,7 +13,7 @@ import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraph; +import com.djrapitops.plan.utilities.html.graphs.line.OnlineActivityGraph; import com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator; import com.djrapitops.plan.utilities.html.tables.SessionsTableCreator; import com.djrapitops.plugin.api.utility.log.Log; @@ -108,7 +108,7 @@ public static String createNetworkPageContent(Map networkPageConte } public static String createServerContainer(Plan plugin) { - ServerProperties variable = plugin.getVariable(); + ServerProperties variable = ServerInfo.getServerProperties(); int maxPlayers = variable.getMaxPlayers(); int online = plugin.getServer().getOnlinePlayers().size(); Optional analysisRefreshDate = ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisRefreshDate(); @@ -127,7 +127,7 @@ public static String createServerContainer(Plan plugin) { String playerData = "[]"; try { playerCount = db.count().getServerPlayerCount(serverUUID); - playerData = PlayerActivityGraph.createSeries(db.fetch().getTPSData(serverUUID)); + playerData = new OnlineActivityGraph(db.fetch().getTPSData(serverUUID)).toHighChartsSeries(); } catch (DBException e) { Log.toLog(HtmlStructure.class.getClass().getName(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java index c60c38d44b..3da25c3686 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java @@ -4,10 +4,10 @@ */ package com.djrapitops.plan.utilities.html.graphs; +import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.html.graphs.pie.ActivityPie; import java.util.Map; import java.util.Set; @@ -15,30 +15,46 @@ import java.util.UUID; /** - * Graph creation utility for Activity Stack graph. - * - * This graph represents evolution of the playerbase. + * Stack Graph that represents evolution of the PlayerBase in terms of ActivityIndex Groups. * * @author Rsl1122 + * @see ActivityIndex + * @since 4.2.0 */ -public class ActivityStackGraph { +public class ActivityStackGraph implements HighChart { + + private final String[] builtSeries; + + public ActivityStackGraph(TreeMap>> activityData) { + this.builtSeries = createSeries(activityData); + } + + public String toHighChartsLabels() { + return builtSeries[0]; + } + + @Override + public String toHighChartsSeries() { + return builtSeries[1]; + } private ActivityStackGraph() { throw new IllegalStateException("Utility Class"); } - public static String[] createSeries(TreeMap>> activityData) { - String[] sliceNames = ActivityPie.getSliceNames(); + private String[] createSeries(TreeMap>> activityData) { + String[] groups = ActivityIndex.getGroups(); String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", "); int maxCol = colors.length; - StringBuilder[] series = new StringBuilder[sliceNames.length + 1]; - for (int i = 0; i <= sliceNames.length; i++) { + // Series 0 is Labels for Graph x-axis, others are data for each group. + StringBuilder[] series = new StringBuilder[groups.length + 1]; + for (int i = 0; i <= groups.length; i++) { series[i] = new StringBuilder(); } - for (int i = 1; i <= sliceNames.length; i++) { + for (int i = 1; i <= groups.length; i++) { series[i] = new StringBuilder("{name: '") - .append(sliceNames[i - 1]) + .append(groups[i - 1]) .append("',color:").append(colors[(i - 1) % maxCol]) .append(",data: ["); } @@ -49,13 +65,13 @@ public static String[] createSeries(TreeMap>> activi Map> data = activityData.get(date); series[0].append("'").append(FormatUtils.formatTimeStamp(date)).append("'"); - for (int j = 1; j <= sliceNames.length; j++) { - Set players = data.get(sliceNames[j - 1]); + for (int j = 1; j <= groups.length; j++) { + Set players = data.get(groups[j - 1]); series[j].append(players != null ? players.size() : 0); } if (i < size - 1) { - for (int j = 0; j <= sliceNames.length; j++) { + for (int j = 0; j <= groups.length; j++) { series[j].append(","); } } @@ -64,9 +80,9 @@ public static String[] createSeries(TreeMap>> activi StringBuilder seriesBuilder = new StringBuilder("["); - for (int j = 1; j <= sliceNames.length; j++) { + for (int j = 1; j <= groups.length; j++) { seriesBuilder.append(series[j].append("]}").toString()); - if (j < sliceNames.length) { + if (j < groups.length) { seriesBuilder.append(","); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/HighChart.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/HighChart.java new file mode 100644 index 0000000000..39e444dd50 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/HighChart.java @@ -0,0 +1,16 @@ +/* + * 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.utilities.html.graphs; + +/** + * Interface for Graphs with HighCharts data support. + * + * @author Rsl1122 + */ +public interface HighChart { + + String toHighChartsSeries(); + +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/PunchCardGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/PunchCardGraph.java index 6e4db9c7af..567a9f4bf1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/PunchCardGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/PunchCardGraph.java @@ -14,27 +14,26 @@ import java.util.stream.Collectors; /** - * Utility class for creating Punch Card Data Array for the JavaScripts. + * Bubble Chart that represents login "punches" of players. * * @author Rsl1122 - * @since 3.6.0 + * @since 4.2.0 */ -public class PunchCardGraph { +public class PunchCardGraph implements HighChart { - /** - * Constructor used to hide the public constructor - */ - private PunchCardGraph() { - throw new IllegalStateException("Utility class"); - } + private final Collection sessions; /** - * Creates a PunchCard series data Array for HighCharts + * Constuctor for the graph. * - * @param sessions Sessions (Unique/Player) to be placed into the PunchCard. - * @return Data array as a string. + * @param sessions All sessions of All users this PunchCard represents. */ - public static String createSeries(Collection sessions) { + public PunchCardGraph(Collection sessions) { + this.sessions = sessions; + } + + @Override + public String toHighChartsSeries() { List sessionStarts = getSessionStarts(sessions); List daysAndHours = AnalysisUtils.getDaysAndHours(sessionStarts); int[][] dataArray = turnIntoArray(daysAndHours); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldMap.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldMap.java index a148494096..9330a6001e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldMap.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldMap.java @@ -4,23 +4,38 @@ import java.util.List; import java.util.Map; -public class WorldMap { +/** + * World Map that uses iso-a3 specification of Country codes. + * + * @author Rsl1122 + * @since 4.2.0 + */ +public class WorldMap implements HighChart { - /** - * Constructor used to hide the public constructor - */ - private WorldMap() { - throw new IllegalStateException("Utility class"); + private final List geoLocations; + + public WorldMap(List geoLocations) { + this.geoLocations = geoLocations; } - /** - * Creates a data series with iso-a3 specification of Country codes. - * - * @param geoLocations The country names of players - * @return The created data series - */ - public static String createSeries(List geoLocations) { + private static Map getGeoCodes(Map geoCodeCounts) { + Map geoCodes = new HashMap<>(); + // Countries & Codes have been copied from a iso-a3 specification file. + // Each index corresponds to each code. + String[] countries = new String[]{"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea-Bissau", "Guinea", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Nigeria", "Niger", "Niue", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "West Bank", "Yemen", "Zambia", "Zimbabwe"}; + String[] codes = new String[]{"AFG", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATG", "ARG", "ARM", "ABW", "AUS", "AUT", "AZE", "BHM", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", "BOL", "BIH", "BWA", "BRA", "VGB", "BRN", "BGR", "BFA", "MMR", "BDI", "CPV", "KHM", "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "COL", "COM", "COD", "COG", "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", "EGY", "SLV", "GNQ", "ERI", "EST", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "PYF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GUM", "GTM", "GGY", "GNB", "GIN", "GUY", "HTI", "HND", "HKG", "HUN", "ISL", "IND", "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", "KIR", "KOR", "PRK", "KSV", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", "LUX", "MAC", "MKD", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MRT", "MUS", "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MAR", "MOZ", "NAM", "NPL", "NLD", "NCL", "NZL", "NIC", "NGA", "NER", "NIU", "MNP", "NOR", "OMN", "PAK", "PLW", "PAN", "PNG", "PRY", "PER", "PHL", "POL", "PRT", "PRI", "QAT", "ROU", "RUS", "RWA", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SSD", "ESP", "LKA", "SDN", "SUR", "SWZ", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", "TLS", "TGO", "TON", "TTO", "TUN", "TUR", "TKM", "TUV", "UGA", "UKR", "ARE", "GBR", "USA", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "WBG", "YEM", "ZMB", "ZWE"}; + for (int i = 0; i < countries.length; i++) { + String country = countries[i]; + String countryCode = codes[i]; + + geoCodes.put(country, countryCode); + geoCodeCounts.put(countryCode, 0); + } + return geoCodes; + } + @Override + public String toHighChartsSeries() { Map geoCodeCounts = new HashMap<>(); Map geoCodes = getGeoCodes(geoCodeCounts); @@ -31,7 +46,7 @@ public static String createSeries(List geoLocations) { } } - StringBuilder arrayBuilder = new StringBuilder("["); + StringBuilder dataBuilder = new StringBuilder("["); int i = 0; int size = geoCodeCounts.size(); @@ -40,30 +55,16 @@ public static String createSeries(List geoLocations) { Integer players = entry.getValue(); if (players != 0) { - arrayBuilder.append("{'code':'").append(geoCode).append("','value':").append(players).append("}"); + dataBuilder.append("{'code':'").append(geoCode).append("','value':").append(players).append("}"); if (i < size - 1) { - arrayBuilder.append(","); + dataBuilder.append(","); } } i++; } - arrayBuilder.append("]"); - return arrayBuilder.toString(); - } - - private static Map getGeoCodes(Map geoCodeCounts) { - Map geoCodes = new HashMap<>(); - String[] countries = new String[]{"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea-Bissau", "Guinea", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Nigeria", "Niger", "Niue", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "West Bank", "Yemen", "Zambia", "Zimbabwe"}; - String[] codes = new String[]{"AFG", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATG", "ARG", "ARM", "ABW", "AUS", "AUT", "AZE", "BHM", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", "BOL", "BIH", "BWA", "BRA", "VGB", "BRN", "BGR", "BFA", "MMR", "BDI", "CPV", "KHM", "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "COL", "COM", "COD", "COG", "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", "EGY", "SLV", "GNQ", "ERI", "EST", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "PYF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GUM", "GTM", "GGY", "GNB", "GIN", "GUY", "HTI", "HND", "HKG", "HUN", "ISL", "IND", "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", "KIR", "KOR", "PRK", "KSV", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", "LUX", "MAC", "MKD", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MRT", "MUS", "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MAR", "MOZ", "NAM", "NPL", "NLD", "NCL", "NZL", "NIC", "NGA", "NER", "NIU", "MNP", "NOR", "OMN", "PAK", "PLW", "PAN", "PNG", "PRY", "PER", "PHL", "POL", "PRT", "PRI", "QAT", "ROU", "RUS", "RWA", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SSD", "ESP", "LKA", "SDN", "SUR", "SWZ", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", "TLS", "TGO", "TON", "TTO", "TUN", "TUR", "TKM", "TUV", "UGA", "UKR", "ARE", "GBR", "USA", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "WBG", "YEM", "ZMB", "ZWE"}; - for (int i = 0; i < countries.length; i++) { - String country = countries[i]; - String countryCode = codes[i]; - - geoCodes.put(country, countryCode); - geoCodeCounts.put(countryCode, 0); - } - return geoCodes; + dataBuilder.append("]"); + return dataBuilder.toString(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/AbstractLineGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/AbstractLineGraph.java new file mode 100644 index 0000000000..a41ca6d0d6 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/AbstractLineGraph.java @@ -0,0 +1,78 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.djrapitops.plan.utilities.html.graphs.line; + +import com.djrapitops.plan.utilities.analysis.DouglasPeuckerAlgorithm; +import com.djrapitops.plan.utilities.analysis.Point; +import com.djrapitops.plan.utilities.analysis.ReduceGapTriangles; +import com.djrapitops.plan.utilities.html.graphs.HighChart; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * This is a LineGraph for any set of Points, thus it is Abstract. + * + * @author Rsl1122 + * @since 4.2.0 + */ +public class AbstractLineGraph implements HighChart { + + protected List points; + protected boolean reduceGapTriangles = false; + protected boolean reducePoints = false; + + public AbstractLineGraph() { + points = new ArrayList<>(); + } + + public AbstractLineGraph(List points) { + this.points = points; + } + + @Override + public String toHighChartsSeries() { + StringBuilder arrayBuilder = new StringBuilder("["); + + if (reducePoints) { + points = DouglasPeuckerAlgorithm.reducePoints(points, 0); + } + if (reduceGapTriangles) { + points = ReduceGapTriangles.reduce(points); + } + + int size = points.size(); + for (int i = 0; i < size; i++) { + Point point = points.get(i); + double y = point.getY(); + long date = (long) point.getX(); + arrayBuilder.append("[").append(date).append(",").append(y).append("]"); + if (i < size - 1) { + arrayBuilder.append(","); + } + } + + arrayBuilder.append("]"); + return arrayBuilder.toString(); + } + + public void reduceGapTriangles() { + this.reduceGapTriangles = true; + } + + public void reducePoints() { + this.reducePoints = true; + } + + public void setPoints(List points) { + this.points = points; + } + + public void addPoints(Collection points) { + this.points.addAll(points); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/CPUGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/CPUGraph.java index 49a9d40c6a..ff168a2337 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/CPUGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/CPUGraph.java @@ -6,19 +6,22 @@ import java.util.List; import java.util.stream.Collectors; -public class CPUGraph { +/** + * Graph about CPU Usage gathered by TPSCountTimer. + * + * @author Rsl1122 + * @see com.djrapitops.plan.system.tasks.TPSCountTimer + * @since 4.2.0 + */ +public class CPUGraph extends AbstractLineGraph { - /** - * Constructor used to hide the public constructor - */ - private CPUGraph() { - throw new IllegalStateException("Utility class"); + public CPUGraph(List tpsData) { + super(transformToPoints(tpsData)); } - public static String createSeries(List tpsData) { - List points = tpsData.stream() + private static List transformToPoints(List tpsData) { + return tpsData.stream() .map(tps -> new Point(tps.getDate(), tps.getCPUUsage())) .collect(Collectors.toList()); - return LineSeries.createSeries(points, true); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ChunkGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ChunkGraph.java new file mode 100644 index 0000000000..1d79e271b9 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ChunkGraph.java @@ -0,0 +1,27 @@ +package com.djrapitops.plan.utilities.html.graphs.line; + +import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.utilities.analysis.Point; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Graph about Chunk Counts gathered by TPSCountTimer. + * + * @author Rsl1122 + * @see com.djrapitops.plan.system.tasks.TPSCountTimer + * @since 4.2.0 + */ +public class ChunkGraph extends AbstractLineGraph { + + public ChunkGraph(List tpsData) { + super(turnToPoints(tpsData)); + } + + private static List turnToPoints(List tpsData) { + return tpsData.stream() + .map(tps -> new Point(tps.getDate(), tps.getChunksLoaded())) + .collect(Collectors.toList()); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/EntityGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/EntityGraph.java new file mode 100644 index 0000000000..2927d9386b --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/EntityGraph.java @@ -0,0 +1,27 @@ +package com.djrapitops.plan.utilities.html.graphs.line; + +import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.utilities.analysis.Point; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Graph about Entity Counts gathered by TPSCountTimer. + * + * @author Rsl1122 + * @see com.djrapitops.plan.system.tasks.TPSCountTimer + * @since 4.2.0 + */ +public class EntityGraph extends AbstractLineGraph { + + public EntityGraph(List tpsData) { + super(turnToPoints(tpsData)); + } + + private static List turnToPoints(List tpsData) { + return tpsData.stream() + .map(tps -> new Point(tps.getDate(), tps.getEntityCount())) + .collect(Collectors.toList()); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/LineSeries.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/LineSeries.java deleted file mode 100644 index 932a3938b0..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/LineSeries.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.utilities.html.graphs.line; - -import com.djrapitops.plan.utilities.analysis.Point; - -import java.util.List; - -/** - * Abstract scatter graph creator used by other graph creators. - * - * @author Rsl1122 - * @since 3.5.2 - */ -public class LineSeries { - - /** - * Constructor used to hide the public constructor - */ - private LineSeries() { - throw new IllegalStateException("Utility class"); - } - - public static String createSeries(List points, boolean reduceGapTriangles) { - return createSeries(points, reduceGapTriangles, true); - } - - public static String createSeries(List points, boolean reduceGapTriangles, boolean reducePoints) { - StringBuilder arrayBuilder = new StringBuilder("["); - -// if (reducePoints) { -// points = DouglasPeuckerAlgorithm.reducePoints(points, 0); -// } -// -// if (reduceGapTriangles) { -// points = ReduceGapTriangles.reduce(points); -// } - - int size = points.size(); - for (int i = 0; i < size; i++) { - Point point = points.get(i); - double y = point.getY(); - long date = (long) point.getX(); - arrayBuilder.append("[").append(date).append(",").append(y).append("]"); - if (i < size - 1) { - arrayBuilder.append(","); - } - } - - arrayBuilder.append("]"); - return arrayBuilder.toString(); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/PlayerActivityGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/OnlineActivityGraph.java similarity index 50% rename from Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/PlayerActivityGraph.java rename to Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/OnlineActivityGraph.java index 0398fde9d0..7cab2e5973 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/PlayerActivityGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/OnlineActivityGraph.java @@ -7,21 +7,21 @@ import java.util.stream.Collectors; /** + * Graph about Player Counts gathered by TPSCountTimer. + * * @author Rsl1122 + * @see com.djrapitops.plan.system.tasks.TPSCountTimer + * @since 4.2.0 */ -public class PlayerActivityGraph { +public class OnlineActivityGraph extends AbstractLineGraph { - /** - * Constructor used to hide the public constructor - */ - private PlayerActivityGraph() { - throw new IllegalStateException("Utility class"); + public OnlineActivityGraph(List tpsData) { + super(turnToPoints(tpsData)); } - public static String createSeries(List tpsData) { - List points = tpsData.stream() + private static List turnToPoints(List tpsData) { + return tpsData.stream() .map(tps -> new Point(tps.getDate(), tps.getPlayers())) .collect(Collectors.toList()); - return LineSeries.createSeries(points, true); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java index 61ef570a63..a32a393d5e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java @@ -1,38 +1,27 @@ package com.djrapitops.plan.utilities.html.graphs.line; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plan.utilities.analysis.Point; import java.util.List; import java.util.stream.Collectors; /** - * Class for creating scatter graph data from RAM Usage snapshots with TPS task. + * Graph about RAM Usage gathered by TPSCountTimer. * * @author Rsl1122 - * @see TPSCountTimer - * @since 3.6.0 + * @see com.djrapitops.plan.system.tasks.TPSCountTimer + * @since 4.2.0 */ -public class RamGraph { +public class RamGraph extends AbstractLineGraph { - /** - * Constructor used to hide the public constructor - */ - private RamGraph() { - throw new IllegalStateException("Utility class"); + public RamGraph(List tpsData) { + super(turnToPoints(tpsData)); } - /** - * Creates a series data string from given data. - * - * @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute. - * @return Series data for HighCharts - */ - public static String createSeries(List tpsData) { - List points = tpsData.stream() + private static List turnToPoints(List tpsData) { + return tpsData.stream() .map(tps -> new Point(tps.getDate(), tps.getUsedMemory())) .collect(Collectors.toList()); - return LineSeries.createSeries(points, true); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ServerPreferencePie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ServerPreferencePie.java deleted file mode 100644 index 0d985a9445..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/ServerPreferencePie.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.djrapitops.plan.utilities.html.graphs.line; - -import com.djrapitops.plan.data.time.WorldTimes; - -import java.util.Map; -import java.util.UUID; - -public class ServerPreferencePie { - - private ServerPreferencePie() { - throw new IllegalStateException("Utility Class"); - } - - public static String createSeries(Map serverNames, Map serverWorldTimes) { - StringBuilder seriesBuilder = new StringBuilder("["); - int i = 0; - int size = serverWorldTimes.size(); - for (Map.Entry server : serverWorldTimes.entrySet()) { - String serverName = serverNames.getOrDefault(server.getKey(), "Unknown"); - seriesBuilder.append("{name:'").append(serverName) - .append("',y:").append(server.getValue().getTotal()); - - seriesBuilder.append("}"); - if (i < size - 1) { - seriesBuilder.append(","); - } - i++; - } - seriesBuilder.append("]"); - - return seriesBuilder.toString(); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/TPSGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/TPSGraph.java index 7bf6c63ae8..b8acd18318 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/TPSGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/TPSGraph.java @@ -7,23 +7,21 @@ import java.util.stream.Collectors; /** + * Graph about TPS gathered by TPSCountTimer. + * * @author Rsl1122 - * @since 3.5.0 + * @see com.djrapitops.plan.system.tasks.TPSCountTimer + * @since 4.2.0 */ -public class TPSGraph { +public class TPSGraph extends AbstractLineGraph { - /** - * Constructor used to hide the public constructor - */ - private TPSGraph() { - throw new IllegalStateException("Utility class"); + public TPSGraph(List tpsData) { + super(turnToPoints(tpsData)); } - public static String createSeries(List tpsData) { - List points = tpsData.stream() + private static List turnToPoints(List tpsData) { + return tpsData.stream() .map(tps -> new Point(tps.getDate(), tps.getTicksPerSecond())) .collect(Collectors.toList()); - return LineSeries.createSeries(points, true); - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java deleted file mode 100644 index 40cee358c6..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.djrapitops.plan.utilities.html.graphs.line; - -import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.system.tasks.TPSCountTimer; -import com.djrapitops.plan.utilities.analysis.Point; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * Class for creating scatter graph data from Chunk and Entity load snapshots with TPS task. - * - * @author Rsl1122 - * @see TPSCountTimer - * @since 3.6.0 - */ -public class WorldLoadGraph { - - /** - * Constructor used to hide the public constructor - */ - private WorldLoadGraph() { - throw new IllegalStateException("Utility class"); - } - - /** - * Creates series graph data of entity load. - * - * @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute. - * @return Series data for HighCharts - */ - public static String createSeriesEntities(List tpsData) { - List points = tpsData.stream() - .map(tps -> new Point(tps.getDate(), tps.getEntityCount())) - .collect(Collectors.toList()); - return LineSeries.createSeries(points, true); - } - - /** - * Creates series data of chunk load. - * - * @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute. - * @return Series data for HighCharts - */ - public static String createSeriesChunks(List tpsData) { - List points = tpsData.stream() - .map(tps -> new Point(tps.getDate(), tps.getChunksLoaded())) - .collect(Collectors.toList()); - return LineSeries.createSeries(points, true); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSeries.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/AbstractPieChart.java similarity index 50% rename from Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSeries.java rename to Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/AbstractPieChart.java index a71d24120f..00009126d4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSeries.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/AbstractPieChart.java @@ -4,19 +4,36 @@ */ package com.djrapitops.plan.utilities.html.graphs.pie; +import com.djrapitops.plan.utilities.html.graphs.HighChart; + +import java.util.ArrayList; import java.util.List; /** - * PieSeries data creation utility class. + * This is a PieChart for any set of PieSlices, thus it is Abstract. * * @author Rsl1122 + * @since 4.2.0 */ -public class PieSeries { - private PieSeries() { - throw new IllegalStateException("Utility Class"); +public class AbstractPieChart implements HighChart { + + protected List slices; + + public AbstractPieChart() { + slices = new ArrayList<>(); } + public AbstractPieChart(List slices) { + this.slices = slices; + } + + @Deprecated public static String createSeries(List slices) { + return new AbstractPieChart(slices).toHighChartsSeries(); + } + + @Override + public String toHighChartsSeries() { StringBuilder seriesBuilder = new StringBuilder("["); int i = 0; int size = slices.size(); @@ -31,4 +48,12 @@ public static String createSeries(List slices) { return seriesBuilder.toString(); } + + public void setSlices(List slices) { + this.slices = slices; + } + + public void addSlices(List slices) { + this.slices.addAll(slices); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/AbstractPieChartWithDrilldown.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/AbstractPieChartWithDrilldown.java new file mode 100644 index 0000000000..8044b0955d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/AbstractPieChartWithDrilldown.java @@ -0,0 +1,25 @@ +/* + * 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.utilities.html.graphs.pie; + +import java.util.List; + +/** + * PieChart with a Pie about each slice as well. + * + * @author Rsl1122 + */ +public abstract class AbstractPieChartWithDrilldown extends AbstractPieChart { + + public AbstractPieChartWithDrilldown() { + } + + public AbstractPieChartWithDrilldown(List slices) { + super(slices); + } + + public abstract String toHighChartsDrilldown(); + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java index 944a4c8a24..7c6e41a189 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java @@ -4,40 +4,39 @@ */ package com.djrapitops.plan.utilities.html.graphs.pie; +import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; import java.util.*; /** - * Utility class for creating Activity Pie data. + * Pie about different Activity Groups defined by ActivityIndex. * * @author Rsl1122 + * @see ActivityIndex + * @since 4.2.0 */ -public class ActivityPie { +public class ActivityPie extends AbstractPieChart { - private ActivityPie() { - throw new IllegalStateException("Utility Class"); + public ActivityPie(Map> activityData) { + super(turnToSlices(activityData)); } - public static String[] getSliceNames() { - return new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"}; - } - - public static String createSeries(Map> activityData) { + private static List turnToSlices(Map> activityData) { String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", "); int maxCol = colors.length; List slices = new ArrayList<>(); int i = 0; - for (String slice : getSliceNames()) { - Set players = activityData.getOrDefault(slice, new HashSet<>()); + for (String group : ActivityIndex.getGroups()) { + Set players = activityData.getOrDefault(group, new HashSet<>()); int num = players.size(); - slices.add(new PieSlice(slice, num, colors[i % maxCol], false)); + slices.add(new PieSlice(group, num, colors[i % maxCol], false)); i++; } - return PieSeries.createSeries(slices); + return slices; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java index f941f6a073..180be2ad19 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/PieSlice.java @@ -15,6 +15,18 @@ public class PieSlice { private final String color; private final boolean drilldown; + public PieSlice(String name, long y) { + this(name, y, null, false); + } + + public PieSlice(String name, long y, String color) { + this(name, y, color, false); + } + + public PieSlice(String name, long y, boolean drilldown) { + this(name, y, null, drilldown); + } + public PieSlice(String name, long y, String color, boolean drilldown) { this.name = name; this.y = y; @@ -25,8 +37,8 @@ public PieSlice(String name, long y, String color, boolean drilldown) { @Override public String toString() { return "{name:'" + name + "'," + - "y:" + y + "," + - "color:" + color + "y:" + y + + (color != null ? "," + "color:" + color : "") + (drilldown ? "," + "drilldown: '" + name + "'" : "") + "}"; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ServerPreferencePie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ServerPreferencePie.java new file mode 100644 index 0000000000..81791d328f --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ServerPreferencePie.java @@ -0,0 +1,31 @@ +package com.djrapitops.plan.utilities.html.graphs.pie; + +import com.djrapitops.plan.data.time.WorldTimes; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class ServerPreferencePie extends AbstractPieChart { + + public ServerPreferencePie(Map serverNames, Map serverWorldTimes) { + super(turnToSlices(serverNames, serverWorldTimes)); + } + + private static List turnToSlices(Map serverNames, Map serverWorldTimes) { + List slices = new ArrayList<>(); + + for (Map.Entry server : serverWorldTimes.entrySet()) { + UUID serverUUID = server.getKey(); + WorldTimes worldTimes = server.getValue(); + + String serverName = serverNames.getOrDefault(serverUUID, "Unknown"); + long num = worldTimes.getTotal(); + + slices.add(new PieSlice(serverName, num)); + } + + return slices; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java index afa5d3e244..ac6e9c76f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java @@ -11,30 +11,18 @@ import java.util.*; import java.util.stream.Collectors; -public class WorldPie { +public class WorldPie extends AbstractPieChartWithDrilldown { - private WorldPie() { - throw new IllegalStateException("Utility Class"); - } + private WorldTimes worldTimes; + + public WorldPie(WorldTimes worldTimes) { + super(turnIntoSlices(worldTimes)); - /** - * Used to create HighCharts series string for series and drilldown. - * - * @param worldTimes WorldTimes object. - * @return String array, index 0: Series data, 1: drilldown data - */ - public static String[] createSeries(WorldTimes worldTimes) { - List slices = turnIntoSlices(worldTimes); + this.worldTimes = worldTimes; if (Settings.ORDER_WORLD_PIE_BY_PERC.isTrue()) { slices.sort(new PieSliceComparator()); } - - String seriesData = PieSeries.createSeries(slices); - - String drilldownData = createDrilldown(worldTimes); - - return new String[]{seriesData, drilldownData}; } private static List turnIntoSlices(WorldTimes worldTimes) { @@ -59,6 +47,7 @@ private static List turnIntoSlices(WorldTimes worldTimes) { } i++; } + return slices; } @@ -68,8 +57,9 @@ private static Map transformToAliases(Map playtimePe return transformToAliases(playtimePerWorld, aliases); } + // TODO Move to another class public static Map transformToAliases(Map playtimePerWorld, Map aliases) { - // TODO Optimization is possible + // TODO Optimization is possible (WorldAliasSettings) WorldAliasSettings aliasSettings = new WorldAliasSettings(); Map playtimePerAlias = new HashMap<>(); @@ -89,7 +79,8 @@ public static Map transformToAliases(Map playtimePer return playtimePerAlias; } - private static String createDrilldown(WorldTimes worldTimes) { + @Override + public String toHighChartsDrilldown() { StringBuilder drilldownBuilder = new StringBuilder(); int i = 0; @@ -118,8 +109,8 @@ private static String createDrilldown(WorldTimes worldTimes) { return drilldownBuilder.toString(); } - private static Map transformToGMAliases(Map gmTimesMap) { - // TODO Optimization is possible + private Map transformToGMAliases(Map gmTimesMap) { + // TODO Optimization is possible (WorldAliasSettings) WorldAliasSettings aliasSettings = new WorldAliasSettings(); Map aliases = aliasSettings.getAliases(); @@ -138,16 +129,16 @@ private static Map transformToGMAliases(Map gm String alias = aliases.get(worldName); - GMTimes aliasGMtimes = gmTimesPerAlias.getOrDefault(alias, new GMTimes()); + GMTimes aliasGMTimes = gmTimesPerAlias.getOrDefault(alias, new GMTimes()); for (String gm : gms) { - aliasGMtimes.addTime(gm, gmTimes.getTime(gm)); + aliasGMTimes.addTime(gm, gmTimes.getTime(gm)); } - gmTimesPerAlias.put(alias, aliasGMtimes); + gmTimesPerAlias.put(alias, aliasGMTimes); } return gmTimesPerAlias; } - private static void appendGMTimesForWorld(StringBuilder drilldownBuilder, Map.Entry world) { + private void appendGMTimesForWorld(StringBuilder drilldownBuilder, Map.Entry world) { Map gmTimes = world.getValue().getTimes(); int smallSize = gmTimes.size(); int j = 0; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java index 7c87b27eb0..2c09a0dc37 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java @@ -68,7 +68,7 @@ public static String[] createAccordion(PlayerProfile profile, Map String worldId = "worldPieServer" + sanitizedServerName; AnalysisUtils.addMissingWorlds(worldTimes); - String[] worldData = WorldPie.createSeries(worldTimes); + WorldPie worldPie = new WorldPie(worldTimes); // Accordion panel header html.append("
    ") @@ -104,8 +104,8 @@ public static String[] createAccordion(PlayerProfile profile, Map .append("
    ") // World Pie data script .append("") .append("
    ") // Right col-6 .append("") // Closes row clearfix diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index df8e118f09..073e423e8a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -87,7 +87,7 @@ public static String[] createStructure(Map>> ses WorldTimes worldTimes = session.getWorldTimes(); AnalysisUtils.addMissingWorlds(worldTimes); - String[] worldData = WorldPie.createSeries(worldTimes); + WorldPie worldPie = new WorldPie(worldTimes); String killTable = KillsTableCreator.createTable(session.getPlayerKills()); @@ -131,8 +131,8 @@ public static String[] createStructure(Map>> ses .append("
    ") // World Pie data script .append("") .append("") // Right col-6 .append("") // Closes row clearfix diff --git a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java b/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java index 05695ef927..2d071de613 100644 --- a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java @@ -8,12 +8,10 @@ import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.utilities.analysis.Point; -import com.djrapitops.plan.utilities.html.graphs.PunchCardGraph; import com.djrapitops.plan.utilities.html.graphs.line.*; -import org.apache.commons.lang3.StringUtils; import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -21,9 +19,10 @@ import test.utilities.RandomData; import test.utilities.TestInit; -import java.util.*; - -import static junit.framework.TestCase.assertEquals; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Fuzzlemann @@ -52,69 +51,20 @@ public void setUp() throws Exception { } @Test - public void testGraphCreators() { - String expected = "[[0,0.0],[1,1.0],[2,2.0],[3,3.0],[4,4.0],[5,5.0],[6,6.0],[7,7.0],[8,8.0],[9,9.0]]"; - assertEquals(expected, CPUGraph.createSeries(tpsList)); - assertEquals(expected, PlayerActivityGraph.createSeries(tpsList)); - // TODO Fix TimeZone Dependency of this test - // assertEquals("[{x:3600000, y:3, z:14, marker: { radius:14}},]", PunchCardGraph.createSeries(sessionList)); - - assertEquals(expected, RamGraph.createSeries(tpsList)); - assertEquals(expected, TPSGraph.createSeries(tpsList)); - assertEquals(expected, WorldLoadGraph.createSeriesChunks(tpsList)); - assertEquals(expected, WorldLoadGraph.createSeriesEntities(tpsList)); -// assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMap.createSeries(geoList)); - // TODO fix config mock dependency - // assertEquals("[[{name:'WORLD',y:0,drilldown: 'WORLD'}], [{name:'WORLD', id:'WORLD',colors: gmPieColors,data: [['SURVIVAL',0],['SPECTATOR',0],['CREATIVE',0],['ADVENTURE',0]]}]]", -// Arrays.toString(WorldPie.createSeries(worldTimes))); - } - - @Test - public void testGraphCreatorsForBracketMistakes() { - String[] series = new String[]{ - CPUGraph.createSeries(tpsList), - PlayerActivityGraph.createSeries(tpsList), - PunchCardGraph.createSeries(sessionList), - RamGraph.createSeries(tpsList), - TPSGraph.createSeries(tpsList), - WorldLoadGraph.createSeriesChunks(tpsList), - WorldLoadGraph.createSeriesEntities(tpsList), -// WorldMap.createSeries(geoList), - // TODO fix config mock dependency -// Arrays.toString(WorldPie.createSeries(worldTimes)) + @Ignore("Test should use Stack instead") + public void testLineGraphsForBracketErrors() { + AbstractLineGraph[] graphs = new AbstractLineGraph[]{ + new CPUGraph(tpsList), + new OnlineActivityGraph(tpsList), + new RamGraph(tpsList), + new TPSGraph(tpsList), + new EntityGraph(tpsList), + new ChunkGraph(tpsList) }; - for (String test : series) { - int opened = StringUtils.countMatches(test, "{"); - int closed = StringUtils.countMatches(test, "}"); - Assert.assertEquals(opened, closed); - opened = StringUtils.countMatches(test, "["); - closed = StringUtils.countMatches(test, "]"); - Assert.assertEquals(opened, closed); - } - } - - @Test - public void testSeriesCreator() { - String result = StringUtils.removeAll(LineSeries.createSeries(points, false, false), "[\\[\\]]"); - String[] splittedResult = result.split(","); - - Map expected = new LinkedHashMap<>(); - - for (int i = 0; i < splittedResult.length; i++) { - expected.put(splittedResult[i++], splittedResult[i]); - } - - int i2 = 0; - for (Map.Entry entry : expected.entrySet()) { - String expectedX = entry.getKey(); - String expectedY = entry.getValue(); - - Point point = points.get(i2); - - assertEquals("Given X does not match expected X", expectedX, String.valueOf((long) point.getX())); - assertEquals("Given Y does not match expected Y", expectedY, String.valueOf(point.getY())); - i2++; + for (AbstractLineGraph graph : graphs) { + String series = graph.toHighChartsSeries(); + // TODO Use Stack instead. } } } From a6b5b25d9a555de5b8fbf9ca4b7759c911a2c6d1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 19 Jan 2018 16:06:12 +0200 Subject: [PATCH 034/166] Work on GenerateInspectPageRequest & GenerateAnalysisPageRequest --- .../operation/TransferOperations.java | 12 ++- .../request/CacheAnalysisPageRequest.java | 76 +++++++++++++++++++ .../request/GenerateAnalysisPageRequest.java | 25 +++++- .../request/GenerateInspectPageRequest.java | 25 +++++- .../systems/info/parsing/InspectPage.java | 4 +- 5 files changed, 132 insertions(+), 10 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index 3970add48c..f1d723a7a9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -20,13 +20,19 @@ public interface TransferOperations { // Save - void playerHtml(UUID player, String html) throws DBException; + void playerHtml(UUID player, String encodedHtml) throws DBException; + + void serverHtml(UUID serverUUID, String encodedHtml) throws DBException; + + void networkPageContent(UUID serverUUID, String encodedHtml) throws DBException; // Get Map getPlayerHtml() throws DBException; - void networkPageContent(UUID serverUUID, String html) throws DBException; - Map getNetworkPageContent() throws DBException; + + Map getServerHtml() throws DBException; + + } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java new file mode 100644 index 0000000000..7599abbe1c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java @@ -0,0 +1,76 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +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.utilities.Base64Util; +import com.djrapitops.plugin.utilities.Verify; + +import java.util.Map; +import java.util.UUID; + +/** + * InfoRequest used to place HTML of a server to ResponseCache. + * + * @author Rsl1122 + */ +public class CacheAnalysisPageRequest implements InfoRequest { + + private final UUID serverUUID; + private final String html; + + private CacheAnalysisPageRequest() { + serverUUID = null; + html = null; + } + + public CacheAnalysisPageRequest(UUID serverUUID, String html) { + this.serverUUID = serverUUID; + this.html = html; + } + + public static CacheAnalysisPageRequest createHandler() { + return new CacheAnalysisPageRequest(); + } + + @Override + public void placeDataToDatabase() throws WebException { + Verify.nullCheck(serverUUID, html); + + String encodedHtml = Base64Util.encode(html); + try { + Database.getActive().transfer().serverHtml(serverUUID, encodedHtml); + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + } + + @Override + public Response handleRequest(Map variables) throws WebException { + // Available variables: sender + + try { + Map pages = Database.getActive().transfer().getServerHtml(); + + for (Map.Entry entry : pages.entrySet()) { + UUID serverUUID = entry.getKey(); + String html = Base64Util.decode(entry.getValue()); + + ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); + } + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + return DefaultResponses.SUCCESS.get(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index f7af6e0293..fe788f4618 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -4,7 +4,13 @@ */ package com.djrapitops.plan.system.info.request; +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.webserver.pages.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.utilities.NullCheck; import java.util.Map; import java.util.UUID; @@ -26,8 +32,25 @@ public void placeDataToDatabase() { } @Override - public Response handleRequest(Map variables) { + public Response handleRequest(Map variables) throws WebException { + // Variables available: sender, server + String server = variables.get("server"); + NullCheck.check(server, new BadRequestException("Server UUID 'server' variable not supplied.")); + + UUID serverUUID = UUID.fromString(server); + if (!ServerInfo.getServerUUID().equals(serverUUID)) { + throw new BadRequestException("Requested Analysis page from wrong server."); + } + String html = getHtml(); + + InfoSystem.getInstance().sendRequest(new CacheAnalysisPageRequest(serverUUID, html)); + + return DefaultResponses.SUCCESS.get(); + } + + public String getHtml() { + // TODO Perform Analysis & get HTML return null; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index 2fd168f9a7..6482416874 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -4,10 +4,16 @@ */ package com.djrapitops.plan.system.info.request; +import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.WebFailException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.webserver.pages.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.systems.info.parsing.InspectPage; import com.djrapitops.plan.utilities.NullCheck; import java.util.Map; @@ -35,12 +41,25 @@ public Response handleRequest(Map variables) throws WebException String player = variables.get("player"); NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied.")); - UUID uuid = UUID.fromString(player); - // TODO Generate HTML + UUID uuid = UUID.fromString(player); + String html = getHtml(uuid); - // TODO InfoSystem.getInstance().sendRequest(new CacheInspectPageRequest(uuid, html)); + InfoSystem.getInstance().sendRequest(new CacheInspectPageRequest(uuid, html)); return DefaultResponses.SUCCESS.get(); } + + private String getHtml(UUID uuid) throws WebException { + try { + return new InspectPage(uuid).toHtml(); + } catch (ParseException e) { + Throwable cause = e.getCause(); + if (cause instanceof DBException) { + throw new TransferDatabaseException((DBException) cause); + } else { + throw new WebFailException("Exception during HTML Parsing", cause); + } + } + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java index 1838aa9981..6f2f6128d0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java @@ -49,11 +49,9 @@ public class InspectPage extends Page { private final UUID uuid; - private final PlanPlugin plugin; - public InspectPage(UUID uuid, PlanPlugin plugin) { + public InspectPage(UUID uuid) { this.uuid = uuid; - this.plugin = plugin; } public String toHtml() throws ParseException { From 60257a30047b50ac8a670493f101de75c28c14a7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 19 Jan 2018 17:18:51 +0200 Subject: [PATCH 035/166] Implementation to WebServer for the new InfoRequest system --- .../databases/operation/CheckOperations.java | 6 +- .../system/info/connection/ConnectionIn.java | 68 ++++++++++++++++++- .../info/connection/ConnectionSystem.java | 14 +++- .../request/CacheAnalysisPageRequest.java | 1 + .../info/request/CacheInspectPageRequest.java | 1 + .../CacheNetworkPageContentRequest.java | 11 +++ .../request/GenerateAnalysisPageRequest.java | 9 +++ .../request/GenerateInspectPageRequest.java | 13 +++- .../info/request/RequestSetupRequest.java | 28 ++++++++ .../system/webserver/ResponseHandler.java | 4 +- .../pages/InfoRequestPageHandler.java | 40 +++++++++++ .../pages}/parsing/AnalysisPage.java | 2 +- .../webserver/pages}/parsing/InspectPage.java | 2 +- .../webserver/pages}/parsing/NetworkPage.java | 2 +- .../webserver/pages}/parsing/Page.java | 2 +- .../plan/system/webserver/webapi/WebAPI.java | 2 +- .../info/BukkitInformationManager.java | 4 +- .../info/BungeeInformationManager.java | 2 +- 18 files changed, 193 insertions(+), 18 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java rename Plan/src/main/java/com/djrapitops/plan/{systems/info => system/webserver/pages}/parsing/AnalysisPage.java (96%) rename Plan/src/main/java/com/djrapitops/plan/{systems/info => system/webserver/pages}/parsing/InspectPage.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{systems/info => system/webserver/pages}/parsing/NetworkPage.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{systems/info => system/webserver/pages}/parsing/Page.java (93%) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java index d24f5f8bc8..c58e4f3b21 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/CheckOperations.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.system.database.databases.operation; import com.djrapitops.plan.api.exceptions.database.DBException; -import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.info.server.ServerInfo; import java.util.UUID; @@ -14,6 +14,8 @@ public interface CheckOperations { boolean doesWebUserExists(String username) throws DBException; default boolean isPlayerRegisteredOnThisServer(UUID player) throws DBException { - return isPlayerRegistered(player, PlanSystem.getInstance().getServerInfo().getUuid()); + return isPlayerRegistered(player, ServerInfo.getServerUUID()); } + + boolean isServerInDatabase(UUID serverUUID) throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java index 2b7b942bf8..12f43406fb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java @@ -1,22 +1,84 @@ package com.djrapitops.plan.system.info.connection; -import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.*; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.info.request.RequestSetupRequest; +import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.utilities.Verify; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; public class ConnectionIn { - + private final Map variables; private final InfoRequest infoRequest; - public ConnectionIn(Map variables, InfoRequest infoRequest) { + public ConnectionIn(Request httpRequest, InfoRequest infoRequest) throws WebException { + Verify.nullCheck(httpRequest, infoRequest); + + Map variables = readVariables(httpRequest); + checkAuthentication(variables); + this.variables = variables; this.infoRequest = infoRequest; } + private void checkAuthentication(Map variables) throws WebException { + String sender = variables.get("sender"); + NullCheck.check(sender, new BadRequestException("Sender ('sender') was not included.")); + UUID serverUUID = UUID.fromString(sender); + + try { + if (!Database.getActive().check().isServerInDatabase(serverUUID)) { + if (infoRequest instanceof RequestSetupRequest) { + return; + } + throw new UnauthorizedServerException(sender + "Sender was not found from database"); + } + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + } + + private Map readVariables(Request request) throws WebException { + String requestBody = readRequestBody(request.getRequestBody()); + String[] variables = requestBody.split(";&variable;"); + + return Arrays.stream(variables) + .map(variable -> variable.split("=", 2)) + .filter(splitVariables -> splitVariables.length == 2) + .collect(Collectors.toMap(splitVariables -> splitVariables[0], splitVariables -> splitVariables[1], (a, b) -> b)); + } + public Response handleRequest() throws WebException { return infoRequest.handleRequest(variables); } + + private String readRequestBody(InputStream in) throws WebFailException { + try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { + byte[] bytes; + + byte[] buf = new byte[4096]; + for (int n = in.read(buf); n > 0; n = in.read(buf)) { + out.write(buf, 0, n); + } + + bytes = out.toByteArray(); + + return new String(bytes, StandardCharsets.UTF_8); + } catch (IOException e) { + throw new WebFailException("Exception while reading Request.", e); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 067987c575..2264c4f946 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -8,8 +8,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.info.InfoSystem; -import com.djrapitops.plan.system.info.request.CacheInspectPageRequest; -import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.utilities.NullCheck; @@ -44,14 +43,23 @@ public static ConnectionSystem getInstance() { return connectionSystem; } + public InfoRequest getInfoRequest(String name) { + return dataRequests.get(name.toLowerCase()); + } + private Map loadDataRequests() { Map requests = new HashMap<>(); putRequest(requests, CacheInspectPageRequest.createHandler()); + putRequest(requests, CacheAnalysisPageRequest.createHandler()); + putRequest(requests, CacheNetworkPageContentRequest.createHandler()); + + putRequest(requests, GenerateAnalysisPageRequest.createHandler()); + putRequest(requests, GenerateInspectPageRequest.createHandler()); return requests; } private void putRequest(Map requests, InfoRequest request) { - requests.put(request.getClass().getSimpleName(), request); + requests.put(request.getClass().getSimpleName().toLowerCase(), request); } protected abstract Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java index 7599abbe1c..1f287d4b37 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java @@ -35,6 +35,7 @@ private CacheAnalysisPageRequest() { } public CacheAnalysisPageRequest(UUID serverUUID, String html) { + Verify.nullCheck(serverUUID, html); this.serverUUID = serverUUID; this.html = html; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index fba44f50d8..1e6355cd2a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -35,6 +35,7 @@ private CacheInspectPageRequest() { } public CacheInspectPageRequest(UUID player, String html) { + Verify.nullCheck(player, html); this.player = player; this.html = html; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java index c203705d9b..8fcf91e5af 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java @@ -14,6 +14,7 @@ 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.parts.NetworkPageContent; +import com.djrapitops.plugin.utilities.Verify; import java.util.Map; import java.util.UUID; @@ -29,10 +30,16 @@ public class CacheNetworkPageContentRequest implements InfoRequest { private final String html; public CacheNetworkPageContentRequest(UUID serverUUID, String html) { + Verify.nullCheck(serverUUID, html); this.serverUUID = serverUUID; this.html = html; } + private CacheNetworkPageContentRequest() { + serverUUID = null; + html = null; + } + @Override public void placeDataToDatabase() throws WebException { try { @@ -70,4 +77,8 @@ public Response handleRequest(Map variables) throws WebException return DefaultResponses.SUCCESS.get(); } + + public static CacheNetworkPageContentRequest createHandler() { + return new CacheNetworkPageContentRequest(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index fe788f4618..ca8c49347f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -11,6 +11,7 @@ import com.djrapitops.plan.system.webserver.pages.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.utilities.Verify; import java.util.Map; import java.util.UUID; @@ -23,9 +24,13 @@ public class GenerateAnalysisPageRequest extends InfoRequestWithVariables { public GenerateAnalysisPageRequest(UUID serverUUID) { + Verify.nullCheck(serverUUID); variables.put("server", serverUUID.toString()); } + private GenerateAnalysisPageRequest() { + } + @Override public void placeDataToDatabase() { // No data required in a Generate request @@ -53,4 +58,8 @@ public String getHtml() { // TODO Perform Analysis & get HTML return null; } + + public static GenerateAnalysisPageRequest createHandler() { + return new GenerateAnalysisPageRequest(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index 6482416874..a6e8c0a6fd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -12,9 +12,10 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.pages.parsing.InspectPage; import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.systems.info.parsing.InspectPage; import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.utilities.Verify; import java.util.Map; import java.util.UUID; @@ -26,10 +27,18 @@ */ public class GenerateInspectPageRequest extends InfoRequestWithVariables { + private GenerateInspectPageRequest() { + } + public GenerateInspectPageRequest(UUID uuid) { + Verify.nullCheck(uuid); variables.put("player", uuid.toString()); } + public static GenerateInspectPageRequest createHandler() { + return new GenerateInspectPageRequest(); + } + @Override public void placeDataToDatabase() { // No data required in a Generate request @@ -52,7 +61,9 @@ public Response handleRequest(Map variables) throws WebException private String getHtml(UUID uuid) throws WebException { try { + return new InspectPage(uuid).toHtml(); + } catch (ParseException e) { Throwable cause = e.getCause(); if (cause instanceof DBException) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java new file mode 100644 index 0000000000..64a9d089c8 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java @@ -0,0 +1,28 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.Map; + +/** + * InfoRequest for /plan m setup command. + * + * @author Rsl1122 + */ +// TODO +public class RequestSetupRequest extends InfoRequestWithVariables { + + @Override + public void placeDataToDatabase() { + // Not Required with setup request. + } + + @Override + public Response handleRequest(Map variables) { + return null; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 406b5d6f9a..0fbf0e541b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -48,7 +48,9 @@ public void registerDefaultPages() { } public void registerWebAPIPages() { -// TODO WebAPIPageHandler + registerPage("api", new InfoRequestPageHandler()); + + // TODO Remove redundant comment after implementing replacements // private void registerWebAPIs() { // webAPI.registerNewAPI( // new AnalysisReadyWebAPI(), diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java new file mode 100644 index 0000000000..ded1fae515 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java @@ -0,0 +1,40 @@ +/* + * 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.webserver.pages; + +import com.djrapitops.plan.api.exceptions.connection.NotFoundException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.connection.ConnectionIn; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; +import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.utilities.NullCheck; + +import java.util.List; + +/** + * PageHandler for /info/requestname pages. + *

    + * Used for answering info requests by other servers. + * + * @author Rsl1122 + */ +public class InfoRequestPageHandler extends PageHandler { + + @Override + public Response getResponse(Request request, List target) throws WebException { + if (target.isEmpty()) { + return DefaultResponses.NOT_FOUND.get(); + } + + String requestName = target.get(0); + InfoRequest infoRequest = ConnectionSystem.getInstance().getInfoRequest(requestName); + + NullCheck.check(infoRequest, new NotFoundException("Info Request has not been registered.")); + + return new ConnectionIn(request, infoRequest).handleRequest(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java similarity index 96% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPage.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java index 5fab0f0b52..567cf2d7e8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/AnalysisPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.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.systems.info.parsing; +package com.djrapitops.plan.system.webserver.pages.parsing; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java index 6f2f6128d0..5f55943b13 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.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.systems.info.parsing; +package com.djrapitops.plan.system.webserver.pages.parsing; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java index 10b0c82c28..5ec571e7a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/NetworkPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.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.systems.info.parsing; +package com.djrapitops.plan.system.webserver.pages.parsing; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.api.exceptions.ParseException; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/Page.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/Page.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/Page.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/Page.java index 6fe13967ee..427b64775a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/Page.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/Page.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.systems.info.parsing; +package com.djrapitops.plan.system.webserver.pages.parsing; import com.djrapitops.plan.api.exceptions.ParseException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index 47be80f0ed..7261b40353 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -144,7 +144,7 @@ public void sendRequest(String address) throws WebException { case 403: throw new ForbiddenException(url.toString()); case 404: - throw new NotFoundException(); + throw new NotFoundException(""); case 500: throw new InternalErrorException(); default: 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 index 443b21d912..fd65773d88 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -21,6 +21,8 @@ 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.pages.parsing.InspectPage; 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; @@ -34,8 +36,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.*; -import com.djrapitops.plan.systems.info.parsing.AnalysisPage; -import com.djrapitops.plan.systems.info.parsing.InspectPage; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.file.export.HtmlExport; 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 index 2898853dd4..0191f0e663 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -14,6 +14,7 @@ import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.pages.parsing.NetworkPage; 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; @@ -27,7 +28,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI; import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI; import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI; -import com.djrapitops.plan.systems.info.parsing.NetworkPage; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plugin.api.utility.log.ErrorLogger; From ba661ca2e0f4a85688d5adc5864ac67cb50d0ed8 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 19 Jan 2018 17:24:28 +0200 Subject: [PATCH 036/166] Implemented a couple missing Check, Fetch & Save Operations for SQL --- .../databases/operation/FetchOperations.java | 2 +- .../sql/{ErrorUtil.java => SQLErrorUtil.java} | 4 +- .../databases/sql/operation/SQLBackupOps.java | 8 +- .../databases/sql/operation/SQLCheckOps.java | 35 ++++++--- .../databases/sql/operation/SQLCountOps.java | 6 +- .../databases/sql/operation/SQLFetchOps.java | 75 ++++++++++++------- .../databases/sql/operation/SQLRemoveOps.java | 8 +- .../databases/sql/operation/SQLSaveOps.java | 52 +++++++------ .../databases/sql/operation/SQLSearchOps.java | 4 +- 9 files changed, 117 insertions(+), 77 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/{ErrorUtil.java => SQLErrorUtil.java} (95%) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 85b9aa2f9d..bb4e3b4434 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -41,7 +41,7 @@ public interface FetchOperations { Optional getBungeeInformation() throws DBException; - Optional getServerID(UUID serverUUID); + Optional getServerID(UUID serverUUID) throws DBException; // Raw Data diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/ErrorUtil.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLErrorUtil.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/ErrorUtil.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLErrorUtil.java index ef2b9abbd9..3e283adef8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/ErrorUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLErrorUtil.java @@ -5,9 +5,9 @@ import java.sql.SQLException; -public class ErrorUtil { +public class SQLErrorUtil { - private ErrorUtil() { + private SQLErrorUtil() { } public static DBException getExceptionFor(SQLException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLBackupOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLBackupOps.java index f60f7c46d4..d9cfca617e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLBackupOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLBackupOps.java @@ -4,19 +4,19 @@ import com.djrapitops.plan.system.database.databases.operation.BackupOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -public class SQLBackupOps implements BackupOperations { - - private final SQLDB db; +public class SQLBackupOps extends SQLOps implements BackupOperations { public SQLBackupOps(SQLDB db) { - this.db = db; + super(db); } @Override public void backup(Database toDatabase) { + // TODO } @Override public void restore(Database fromDatabase) { + // TODO } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java index e8ed8518c4..ffae957924 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java @@ -2,44 +2,57 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.CheckOperations; -import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; +import com.djrapitops.plan.system.info.server.ServerInfo; import java.sql.SQLException; import java.util.UUID; -public class SQLCheckOps implements CheckOperations { - - private final SQLDB db; +public class SQLCheckOps extends SQLOps implements CheckOperations { public SQLCheckOps(SQLDB db) { - this.db = db; + super(db); } @Override public boolean isPlayerRegistered(UUID player) throws DBException { try { - return db.getUsersTable().isRegistered(player); + return usersTable.isRegistered(player); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @Override public boolean isPlayerRegistered(UUID player, UUID server) throws DBException { try { - return db.getUserInfoTable().isRegistered(player, server); + return userInfoTable.isRegistered(player, server); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @Override public boolean doesWebUserExists(String username) throws DBException { try { - return db.getSecurityTable().userExists(username); + return securityTable.userExists(username); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public boolean isPlayerRegisteredOnThisServer(UUID player) throws DBException { + return isPlayerRegistered(player, ServerInfo.getServerUUID()); + } + + @Override + public boolean isServerInDatabase(UUID serverUUID) throws DBException { + try { + return serverTable.getServerID(serverUUID).isPresent(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java index 32537b4d9c..515b54edf2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java @@ -2,8 +2,8 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.CountOperations; -import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import java.sql.SQLException; import java.util.UUID; @@ -19,7 +19,7 @@ public int getServerPlayerCount(UUID server) throws DBException { try { return userInfoTable.getServerUserCount(server); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -28,7 +28,7 @@ public int getNetworkPlayerCount() throws DBException { try { return usersTable.getPlayerCount(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index a7fd8ee75f..7443dec8fa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -6,8 +6,9 @@ import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; -import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; @@ -45,7 +46,7 @@ public ServerProfile getServerProfile(UUID serverUUID) throws DBException { return profile; } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -83,7 +84,7 @@ public List getPlayers(UUID serverUUID) throws DBException { } return players; } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -118,7 +119,7 @@ public PlayerProfile getPlayerProfile(UUID uuid) throws DBException { return profile; } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -142,7 +143,7 @@ public Set getSavedUUIDs() throws DBException { try { return usersTable.getSavedUUIDs(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -151,7 +152,7 @@ public Set getSavedUUIDs(UUID server) throws DBException { try { return userInfoTable.getSavedUUIDs(server); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -160,7 +161,7 @@ public Map getServerNames() throws DBException { try { return serverTable.getServerNames(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -169,7 +170,7 @@ public Optional getServerUUID(String serverName) throws DBException { try { return serverTable.getServerUUID(serverName); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -178,27 +179,25 @@ public UUID getUuidOf(String playerName) throws DBException { try { return usersTable.getUuidOf(playerName); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } - @Override public WebUser getWebUser(String username) throws DBException { try { return securityTable.getWebUser(username); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } - @Override public List getTPSData(UUID serverUUID) throws DBException { try { return tpsTable.getTPSData(serverUUID); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -207,7 +206,7 @@ public List getNetworkOnlineData() throws DBException { try { return tpsTable.getNetworkOnlineData(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -216,7 +215,7 @@ public List getRegisterDates() throws DBException { try { return usersTable.getRegisterDates(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -225,7 +224,7 @@ public Optional getAllTimePeak(UUID serverUUID) throws DBException { try { return tpsTable.getAllTimePeak(serverUUID); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -234,7 +233,7 @@ public Optional getPeakPlayerCount(UUID serverUUID, long afterDate) throws try { return tpsTable.getPeakPlayerCount(serverUUID, afterDate); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -243,7 +242,7 @@ public Map>> getSessionsWithNoExtras() throws DBEx try { return sessionsTable.getAllSessions(false); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -252,7 +251,7 @@ public Map>> getSessionsAndExtras() throws DBExcep try { return sessionsTable.getAllSessions(true); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -261,7 +260,7 @@ public Set getWorldNames(UUID serverUuid) throws DBException { try { return worldTable.getWorldNames(serverUuid); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -270,7 +269,7 @@ public List getNicknamesOfPlayerOnServer(UUID uuid, UUID serverUUID) thr try { return nicknamesTable.getNicknames(uuid, serverUUID); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -279,7 +278,7 @@ public List getActions(UUID uuid) throws DBException { try { return actionsTable.getActions(uuid); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -288,7 +287,7 @@ public Map getUsers() throws DBException { try { return usersTable.getUsers(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -297,7 +296,7 @@ public Map getLastSeenForAllPlayers() throws DBException { try { return sessionsTable.getLastSeenForAllPlayers(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -306,7 +305,7 @@ public Map> getAllGeoInfo() throws DBException { try { return geoInfoTable.getAllGeoInfo(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -315,7 +314,7 @@ public Map getPlayerNames() throws DBException { try { return usersTable.getPlayerNames(); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -324,7 +323,7 @@ public String getPlayerName(UUID playerUUID) throws DBException { try { return usersTable.getPlayerName(playerUUID); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -333,7 +332,7 @@ public Optional getServerName(UUID serverUUID) throws DBException { try { return serverTable.getServerName(serverUUID); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -342,7 +341,25 @@ public List getNicknames(UUID uuid) throws DBException { try { return nicknamesTable.getNicknames(uuid); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public Optional getBungeeInformation() throws DBException { + try { + return serverTable.getBungeeInfo(); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public Optional getServerID(UUID serverUUID) throws DBException { + try { + return serverTable.getServerID(serverUUID); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java index 1f6aee27d5..18309700a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java @@ -3,8 +3,8 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.FatalDBException; import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; -import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import com.djrapitops.plan.system.database.databases.sql.tables.Table; import com.djrapitops.plan.system.database.databases.sql.tables.UserIDTable; import com.djrapitops.plugin.api.Benchmark; @@ -41,7 +41,7 @@ public void player(UUID uuid) throws DBException { securityTable.removeUser(webUser); } catch (SQLException e) { - throw ErrorUtil.getFatalExceptionFor(e); + throw SQLErrorUtil.getFatalExceptionFor(e); } finally { Benchmark.stop("Database", "Remove Account"); } @@ -64,7 +64,7 @@ public void everything() throws DBException { table.removeAllData(); } } catch (SQLException e) { - throw ErrorUtil.getFatalExceptionFor(e); + throw SQLErrorUtil.getFatalExceptionFor(e); } } @@ -73,7 +73,7 @@ public void webUser(String userName) throws DBException { try { securityTable.removeUser(userName); } catch (SQLException e) { - throw ErrorUtil.getFatalExceptionFor(e); + throw SQLErrorUtil.getFatalExceptionFor(e); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java index 57f3148d07..0e56532f38 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java @@ -7,8 +7,9 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.operation.SaveOperations; -import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; +import com.djrapitops.plan.system.info.server.Server; import java.sql.SQLException; import java.util.List; @@ -31,7 +32,7 @@ public void insertTPS(Map> ofServers) throws DBException { try { tpsTable.insertAllTPS(ofServers); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -40,7 +41,7 @@ public void insertCommandUsage(Map> ofServers) throws try { commandUseTable.insertCommandUsage(ofServers); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -49,7 +50,7 @@ public void insertUsers(Map ofServers) throws DBException { try { usersTable.insertUsers(ofServers); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -58,7 +59,7 @@ public void insertSessions(Map>> ofServers, boolea try { sessionsTable.insertSessions(ofServers, containsExtraData); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -67,7 +68,7 @@ public void kickAmount(Map ofUsers) throws DBException { try { usersTable.updateKicked(ofUsers); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -76,7 +77,7 @@ public void insertUserInfo(Map> ofServers) throws DBExcepti try { userInfoTable.insertUserInfo(ofServers); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -85,7 +86,7 @@ public void insertNicknames(Map>> ofServers) throws try { nicknamesTable.insertNicknames(ofServers); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -94,7 +95,7 @@ public void insertAllGeoInfo(Map> ofUsers) throws DBExceptio try { geoInfoTable.insertAllGeoInfo(ofUsers); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -103,7 +104,7 @@ public void banStatus(UUID uuid, boolean banned) throws DBException { try { userInfoTable.updateBanStatus(uuid, banned); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -112,7 +113,7 @@ public void opStatus(UUID uuid, boolean op) throws DBException { try { userInfoTable.updateOpStatus(uuid, op); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -121,7 +122,7 @@ public void registerNewUser(UUID uuid, long registered, String name) throws DBEx try { usersTable.registerUser(uuid, registered, name); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -130,7 +131,7 @@ public void action(UUID uuid, Action action) throws DBException { try { actionsTable.insertAction(uuid, action); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -139,7 +140,7 @@ public void geoInfo(UUID uuid, GeoInfo geoInfo) throws DBException { try { geoInfoTable.saveGeoInfo(uuid, geoInfo); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -148,7 +149,7 @@ public void playerWasKicked(UUID uuid) throws DBException { try { usersTable.kicked(uuid); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -157,7 +158,7 @@ public void playerName(UUID uuid, String playerName) throws DBException { try { usersTable.updateName(uuid, playerName); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -166,7 +167,7 @@ public void playerDisplayName(UUID uuid, String displayName) throws DBException try { nicknamesTable.saveUserName(uuid, displayName); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -175,7 +176,7 @@ public void registerNewUserOnThisServer(UUID uuid, long registered) throws DBExc try { userInfoTable.registerUserInfo(uuid, registered); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -184,7 +185,7 @@ public void commandUsed(String commandName) throws DBException { try { commandUseTable.commandUsed(commandName); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -193,7 +194,7 @@ public void insertTPSforThisServer(TPS tps) throws DBException { try { tpsTable.insertTPS(tps); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } @@ -202,7 +203,16 @@ public void session(UUID uuid, Session session) throws DBException { try { sessionsTable.saveSession(uuid, session); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public void serverInfoForThisServer(Server server) throws DBException { + try { + serverTable.saveCurrentServerInfo(server); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java index fca34c47fd..9f0c843518 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java @@ -2,8 +2,8 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.SearchOperations; -import com.djrapitops.plan.system.database.databases.sql.ErrorUtil; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import java.sql.SQLException; import java.util.List; @@ -19,7 +19,7 @@ public List matchingPlayers(String search) throws DBException { try { return usersTable.getMatchingNames(search); } catch (SQLException e) { - throw ErrorUtil.getExceptionFor(e); + throw SQLErrorUtil.getExceptionFor(e); } } } From b333fb99190eba9e661fe27a281d5679986ec82b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 20 Jan 2018 10:41:43 +0200 Subject: [PATCH 037/166] Implemented TransferTable operations that are called so far. --- .../operation/TransferOperations.java | 12 +- .../system/database/databases/sql/SQLDB.java | 10 +- .../databases/sql/operation/SQLOps.java | 2 + .../sql/operation/SQLTransferOps.java | 60 ++++++- .../databases/sql/tables/TransferTable.java | 150 ++++++++++++++++++ .../request/CacheAnalysisPageRequest.java | 4 +- .../info/request/CacheInspectPageRequest.java | 4 +- .../CacheNetworkPageContentRequest.java | 4 +- 8 files changed, 231 insertions(+), 15 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index f1d723a7a9..e04e10e8b5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -20,19 +20,19 @@ public interface TransferOperations { // Save - void playerHtml(UUID player, String encodedHtml) throws DBException; + void storePlayerHtml(UUID player, String encodedHtml) throws DBException; - void serverHtml(UUID serverUUID, String encodedHtml) throws DBException; + void storeServerHtml(UUID serverUUID, String encodedHtml) throws DBException; - void networkPageContent(UUID serverUUID, String encodedHtml) throws DBException; + void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws DBException; // Get - Map getPlayerHtml() throws DBException; + Map getEncodedPlayerHtml() throws DBException; - Map getNetworkPageContent() throws DBException; + Map getEncodedNetworkPageContent() throws DBException; - Map getServerHtml() throws DBException; + Map getEncodedServerHtml() throws DBException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index ee856d147b..01808fb479 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -39,6 +39,7 @@ public abstract class SQLDB extends Database { private final WorldTable worldTable; private final WorldTimesTable worldTimesTable; private final ServerTable serverTable; + private final TransferTable transferTable; private final SQLBackupOps backupOps; private final SQLCheckOps checkOps; @@ -71,6 +72,7 @@ public SQLDB() { killsTable = new KillsTable(this); worldTable = new WorldTable(this); worldTimesTable = new WorldTimesTable(this); + transferTable = new TransferTable(this); backupOps = new SQLBackupOps(this); checkOps = new SQLCheckOps(this); @@ -200,7 +202,7 @@ public Table[] getAllTables() { serverTable, usersTable, userInfoTable, geoInfoTable, nicknamesTable, sessionsTable, killsTable, commandUseTable, actionsTable, tpsTable, - worldTable, worldTimesTable, securityTable + worldTable, worldTimesTable, securityTable, transferTable }; } @@ -211,7 +213,7 @@ public Table[] getAllTables() { */ public Table[] getAllTablesInRemoveOrder() { return new Table[]{ - geoInfoTable, nicknamesTable, killsTable, + transferTable, geoInfoTable, nicknamesTable, killsTable, worldTimesTable, sessionsTable, actionsTable, worldTable, userInfoTable, usersTable, commandUseTable, tpsTable, securityTable, @@ -346,6 +348,10 @@ public UserInfoTable getUserInfoTable() { return userInfoTable; } + public TransferTable getTransferTable() { + return transferTable; + } + public boolean isUsingMySQL() { return this instanceof MySQLDB; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java index 406537830d..72de0ab2fb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLOps.java @@ -20,6 +20,7 @@ public class SQLOps { protected final WorldTable worldTable; protected final WorldTimesTable worldTimesTable; protected final ServerTable serverTable; + protected final TransferTable transferTable; public SQLOps(SQLDB db) { this.db = db; @@ -37,5 +38,6 @@ public SQLOps(SQLDB db) { worldTable = db.getWorldTable(); worldTimesTable = db.getWorldTimesTable(); serverTable = db.getServerTable(); + transferTable = db.getTransferTable(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java index e9227ac5e1..1304622b9a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java @@ -4,8 +4,14 @@ */ package com.djrapitops.plan.system.database.databases.sql.operation; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.TransferOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; + +import java.sql.SQLException; +import java.util.Map; +import java.util.UUID; /** * TransferOperations for MySQL Database. @@ -18,5 +24,57 @@ public SQLTransferOps(SQLDB db) { super(db); } - // TODO create Transfer table + @Override + public void storePlayerHtml(UUID player, String encodedHtml) throws DBException { + try { + transferTable.storePlayerHtml(player, encodedHtml); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public void storeServerHtml(UUID serverUUID, String encodedHtml) throws DBException { + try { + transferTable.storeServerHtml(serverUUID, encodedHtml); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws DBException { + try { + transferTable.storeNetworkPageContent(serverUUID, encodedHtml); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getEncodedPlayerHtml() throws DBException { + try { + return transferTable.getPlayerHtml(); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getEncodedNetworkPageContent() throws DBException { + try { + return transferTable.getNetworkPageContent(); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getEncodedServerHtml() throws DBException { + try { + return transferTable.getServerHtml(); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java new file mode 100644 index 0000000000..21db2abe51 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -0,0 +1,150 @@ +/* + * 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.database.databases.sql.tables; + +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Sql; +import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.info.request.CacheAnalysisPageRequest; +import com.djrapitops.plan.system.info.request.CacheInspectPageRequest; +import com.djrapitops.plan.system.info.request.CacheNetworkPageContentRequest; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.TimeAmount; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * Table that represents plan_transfer in SQL database. + * + * @author Rsl1122 + */ +public class TransferTable extends Table { + + private final String columnSenderID = "sender_server_id"; + private final String columnExpiry = "expiry_date"; + private final String columnInfoType = "type"; + private final String columnContent = "content_64"; + private final String columnExtraVariables = "extra_variables"; + + private final ServerTable serverTable; + + private final String insertStatement; + private String selectStatement; + + public TransferTable(SQLDB db) { + super("plan_transfer", db); + + serverTable = db.getServerTable(); + insertStatement = "INSERT INTO " + tableName + " (" + + columnSenderID + ", " + + columnExpiry + ", " + + columnInfoType + ", " + + columnExtraVariables + ", " + + columnContent + + ") VALUES (" + + serverTable.statementSelectServerID + ", " + + "?, ?, ?, ?, ?)"; + + selectStatement = "SELECT * FROM " + tableName + + " WHERE " + columnInfoType + "= ?" + + " AND " + columnExpiry + "> ?"; + } + + @Override + public void createTable() throws DBCreateTableException { + createTable(TableSqlParser.createTable(tableName) + .column(columnSenderID, Sql.INT).notNull() + .column(columnExpiry, Sql.LONG).notNull().defaultValue("0") + .column(columnInfoType, Sql.varchar(100)).notNull() + .column(columnExtraVariables, Sql.varchar(255)).defaultValue("") + .column(columnContent, usingMySQL ? "MEDIUMTEXT" : Sql.varchar(1)) // SQLite does not enforce varchar limits. + .foreignKey(columnSenderID, serverTable.toString(), serverTable.getColumnID()) + .toString() + ); + } + + public void storePlayerHtml(UUID player, String encodedHtml) throws SQLException { + execute(new ExecStatement(insertStatement) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, ServerInfo.getServerUUID().toString()); + statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms()); + statement.setString(3, CacheInspectPageRequest.class.getSimpleName().toLowerCase()); + statement.setString(4, player.toString()); + statement.setString(5, encodedHtml); + } + }); + } + + public void storeServerHtml(UUID serverUUID, String encodedHtml) throws SQLException { + execute(new ExecStatement(insertStatement) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, ServerInfo.getServerUUID().toString()); + statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms()); + statement.setString(3, CacheAnalysisPageRequest.class.getSimpleName().toLowerCase()); + statement.setString(4, serverUUID.toString()); + statement.setString(5, encodedHtml); + } + }); + } + + public void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws SQLException { + execute(new ExecStatement(insertStatement) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, ServerInfo.getServerUUID().toString()); + statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms()); + statement.setString(3, CacheNetworkPageContentRequest.class.getSimpleName().toLowerCase()); + statement.setString(4, serverUUID.toString()); + statement.setString(5, encodedHtml); + } + }); + } + + private Map getHtmlPerUUIDForCacheRequest(Class c) throws SQLException { + return query(new QueryStatement>(selectStatement, 250) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, c.getSimpleName().toLowerCase()); + statement.setLong(2, MiscUtils.getTime()); + } + + @Override + public Map processResults(ResultSet set) throws SQLException { + Map htmlPerUUID = new HashMap<>(); + while (set.next()) { + String uuidString = set.getString(columnExtraVariables); + UUID uuid = UUID.fromString(uuidString); + String html64 = set.getString(columnContent); + + htmlPerUUID.put(uuid, html64); + } + return htmlPerUUID; + } + }); + } + + public Map getPlayerHtml() throws SQLException { + return getHtmlPerUUIDForCacheRequest(CacheInspectPageRequest.class); + } + + public Map getNetworkPageContent() throws SQLException { + return getHtmlPerUUIDForCacheRequest(CacheNetworkPageContentRequest.class); + } + + public Map getServerHtml() throws SQLException { + return getHtmlPerUUIDForCacheRequest(CacheAnalysisPageRequest.class); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java index 1f287d4b37..3b04ebc29a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java @@ -50,7 +50,7 @@ public void placeDataToDatabase() throws WebException { String encodedHtml = Base64Util.encode(html); try { - Database.getActive().transfer().serverHtml(serverUUID, encodedHtml); + Database.getActive().transfer().storeServerHtml(serverUUID, encodedHtml); } catch (DBException e) { throw new TransferDatabaseException(e); } @@ -61,7 +61,7 @@ public Response handleRequest(Map variables) throws WebException // Available variables: sender try { - Map pages = Database.getActive().transfer().getServerHtml(); + Map pages = Database.getActive().transfer().getEncodedServerHtml(); for (Map.Entry entry : pages.entrySet()) { UUID serverUUID = entry.getKey(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index 1e6355cd2a..285253744e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -50,7 +50,7 @@ public void placeDataToDatabase() throws WebException { String encodedHtml = Base64Util.encode(html); try { - Database.getActive().transfer().playerHtml(player, encodedHtml); + Database.getActive().transfer().storePlayerHtml(player, encodedHtml); } catch (DBException e) { throw new TransferDatabaseException(e); } @@ -61,7 +61,7 @@ public Response handleRequest(Map variables) throws WebException // Available variables: sender try { - Map pages = Database.getActive().transfer().getPlayerHtml(); + Map pages = Database.getActive().transfer().getEncodedPlayerHtml(); for (Map.Entry entry : pages.entrySet()) { UUID uuid = entry.getKey(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java index 8fcf91e5af..a16fa52b2b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java @@ -43,7 +43,7 @@ private CacheNetworkPageContentRequest() { @Override public void placeDataToDatabase() throws WebException { try { - Database.getActive().transfer().networkPageContent(serverUUID, html); + Database.getActive().transfer().storeNetworkPageContent(serverUUID, html); } catch (DBException e) { throw new TransferDatabaseException(e); } @@ -57,7 +57,7 @@ public Response handleRequest(Map variables) throws WebException Map serverNames; try { Database database = Database.getActive(); - networkPageHtml = database.transfer().getNetworkPageContent(); + networkPageHtml = database.transfer().getEncodedNetworkPageContent(); serverNames = database.fetch().getServerNames(); } catch (DBException e) { throw new TransferDatabaseException(e); From e9b9c68d078509bea476cc1b29233d3155536fd7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 20 Jan 2018 10:42:54 +0200 Subject: [PATCH 038/166] Moved SQLErrorUtil --- .../system/database/databases/sql/operation/SQLCheckOps.java | 1 - .../system/database/databases/sql/operation/SQLCountOps.java | 1 - .../database/databases/sql/{ => operation}/SQLErrorUtil.java | 2 +- .../system/database/databases/sql/operation/SQLFetchOps.java | 1 - .../system/database/databases/sql/operation/SQLRemoveOps.java | 1 - .../system/database/databases/sql/operation/SQLSaveOps.java | 1 - .../system/database/databases/sql/operation/SQLSearchOps.java | 1 - .../system/database/databases/sql/operation/SQLTransferOps.java | 1 - 8 files changed, 1 insertion(+), 8 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/{ => operation}/SQLErrorUtil.java (94%) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java index ffae957924..a496a03ef7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCheckOps.java @@ -3,7 +3,6 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.CheckOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import com.djrapitops.plan.system.info.server.ServerInfo; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java index 515b54edf2..7d544aca9b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLCountOps.java @@ -3,7 +3,6 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.CountOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import java.sql.SQLException; import java.util.UUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLErrorUtil.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java similarity index 94% rename from Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLErrorUtil.java rename to Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java index 3e283adef8..4cbe78a90b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLErrorUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.system.database.databases.sql; +package com.djrapitops.plan.system.database.databases.sql.operation; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.FatalDBException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index 7443dec8fa..a9b32d2c62 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -7,7 +7,6 @@ import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java index 18309700a5..5d009f3b0b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLRemoveOps.java @@ -4,7 +4,6 @@ import com.djrapitops.plan.api.exceptions.database.FatalDBException; import com.djrapitops.plan.system.database.databases.operation.RemoveOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import com.djrapitops.plan.system.database.databases.sql.tables.Table; import com.djrapitops.plan.system.database.databases.sql.tables.UserIDTable; import com.djrapitops.plugin.api.Benchmark; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java index 0e56532f38..bbb572873a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java @@ -8,7 +8,6 @@ import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.operation.SaveOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import com.djrapitops.plan.system.info.server.Server; import java.sql.SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java index 9f0c843518..a560fbd6e0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSearchOps.java @@ -3,7 +3,6 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.SearchOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import java.sql.SQLException; import java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java index 1304622b9a..e724aeb983 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java @@ -7,7 +7,6 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.operation.TransferOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil; import java.sql.SQLException; import java.util.Map; From a62e15fccd45edc7fb638bded925d81d259a4b84 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 20 Jan 2018 11:07:07 +0200 Subject: [PATCH 039/166] Moved interfaces to inside the using class. --- .../plan/system/cache/SessionCache.java | 14 ++-------- .../info/connection/WebExceptionLogger.java | 4 +-- .../webserver/response/cache/PageLoader.java | 15 ---------- .../response/cache/ResponseCache.java | 28 +++++++++++++------ 4 files changed, 25 insertions(+), 36 deletions(-) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageLoader.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java index d42fbe3bd1..84d34f1189 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.cache; -import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.PlanSystem; @@ -61,11 +60,7 @@ public void cacheSession(UUID uuid, Session session) { new Processor(system) { @Override public void process() { - try { - system.getInfoSystem().generateAndCachePlayerPage(uuid); - } catch (WebException e) { - WebExceptionLogger.log(this.getClass(), e); - } + WebExceptionLogger.logIfOccurs(this.getClass(), () -> system.getInfoSystem().generateAndCachePlayerPage(uuid)); } }.queue(); } @@ -82,11 +77,8 @@ public void endSession(UUID uuid, long time) { Log.toLog(this.getClass().getName(), e); } finally { activeSessions.remove(uuid); - try { - system.getInfoSystem().generateAndCachePlayerPage(uuid); - } catch (WebException e) { - WebExceptionLogger.log(this.getClass(), e); - } + + WebExceptionLogger.logIfOccurs(this.getClass(), () -> system.getInfoSystem().generateAndCachePlayerPage(uuid)); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java index 0fff2f6588..d61bca6a2a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java @@ -14,14 +14,14 @@ */ public class WebExceptionLogger { - public static void log(Class c, ExceptionLoggingAction action) { + public static void logIfOccurs(Class c, ExceptionLoggingAction action) { try { action.performAction(); } catch (ConnectionFailException | UnsupportedTransferDatabaseException | UnauthorizedServerException | NotFoundException | NoServersException e) { Log.warn(e.getMessage()); } catch (WebException e) { - Log.toLog(WebExceptionLogger.class, e); + Log.toLog(c, e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageLoader.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageLoader.java deleted file mode 100644 index 2ececae8d6..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageLoader.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.djrapitops.plan.system.webserver.response.cache; - -import com.djrapitops.plan.system.webserver.response.Response; - -/** - * This interface is used for providing the method to load the page. - * - * @author Fuzzlemann - * @since 3.6.0 - */ -public interface PageLoader { - - Response createResponse(); - -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java index d8fe8b9273..f0c14bc9d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java @@ -29,18 +29,18 @@ private ResponseCache() { } /** - * Loads the page from the page cache. + * Loads the response from the response cache. *

    - * If the {@link Response} isn't cached, {@link PageLoader#createResponse()} in the {@code loader} + * If the {@link Response} isn't cached, {@link ResponseLoader#createResponse()} in the {@code loader} * is called to create the Response. *

    * If the Response is created, it's automatically cached. * * @param identifier The identifier of the page - * @param loader The {@link PageLoader} (How should it load the page if it's not cached) - * @return The Response that was cached or created by the {@link PageLoader loader} + * @param loader The {@link ResponseLoader} (How should it load the page if it's not cached) + * @return The Response that was cached or created by the {@link ResponseLoader loader} */ - public static Response loadResponse(String identifier, PageLoader loader) { + public static Response loadResponse(String identifier, ResponseLoader loader) { Response response = loadResponse(identifier); if (response != null) { @@ -72,7 +72,7 @@ public static Response loadResponse(String identifier) { * @param identifier The identifier of the page * @return Copied Response of loadResponse, so that cache contents are not changed. */ - public static Response copyResponse(String identifier, PageLoader loader) { + public static Response copyResponse(String identifier, ResponseLoader loader) { Response response = loadResponse(identifier, loader); if (response instanceof InspectPageResponse) { return InspectPageResponse.copyOf((InspectPageResponse) response); @@ -86,9 +86,9 @@ public static Response copyResponse(String identifier, PageLoader loader) { * If the cache already inherits that {@code identifier}, it's renewed. * * @param identifier The identifier of the page - * @param loader The {@link PageLoader} (How it should load the page) + * @param loader The {@link ResponseLoader} (How it should load the page) */ - public static void cacheResponse(String identifier, PageLoader loader) { + public static void cacheResponse(String identifier, ResponseLoader loader) { Response response = loader.createResponse(); cache.put(identifier, response); } @@ -122,4 +122,16 @@ public static void removeIf(Predicate filter) { public static void clearCache() { cache.clear(); } + + /** + * This interface is used for providing the method to load the page. + * + * @author Fuzzlemann + * @since 4.2.0 + */ + public interface ResponseLoader { + + Response createResponse(); + + } } From 18b8deac7c6cc974ac96e90de1942238660df63a Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 21 Jan 2018 13:24:50 +0200 Subject: [PATCH 040/166] Started work on Info system implementations --- .../api/exceptions/WebUserAuthException.java | 3 +- .../djrapitops/plan/system/BukkitSystem.java | 3 + .../djrapitops/plan/system/BungeeSystem.java | 5 ++ .../djrapitops/plan/system/PlanSystem.java | 1 + .../databases/operation/FetchOperations.java | 2 + .../plan/system/info/BukkitInfoSystem.java | 30 +++++++ .../connection/BukkitConnectionSystem.java | 72 +++++++++++++++++ .../system/info/connection/ConnectionLog.java | 66 ++++++++++++++++ .../system/info/connection/ConnectionOut.java | 17 ++-- .../info/connection/ConnectionSystem.java | 15 ++-- .../system/webserver/ResponseHandler.java | 78 +++++++++++-------- .../errors/UnauthorizedServerResponse.java | 20 +++++ .../response/pages/DebugPageResponse.java | 32 ++++++++ 13 files changed, 299 insertions(+), 45 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/UnauthorizedServerResponse.java diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java index 1616a186e9..8ec1fc1eb0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.api.exceptions; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.auth.FailReason; /** @@ -11,7 +12,7 @@ * * @author Rsl1122 */ -public class WebUserAuthException extends Exception { +public class WebUserAuthException extends WebException { private final FailReason failReason; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index 248289951b..30072f0784 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.ShutdownHook; import com.djrapitops.plan.system.database.BukkitDBSystem; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.info.server.BukkitServerInfo; import com.djrapitops.plan.system.listeners.BukkitListenerSystem; import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; import com.djrapitops.plan.system.tasks.BukkitTaskSystem; @@ -28,6 +29,8 @@ public BukkitSystem(Plan plugin) { listenerSystem = new BukkitListenerSystem(plugin); taskSystem = new BukkitTaskSystem(plugin); + serverInfo = new BukkitServerInfo(plugin); + new ShutdownHook().register(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java index 72d157d9c0..d31e3a1a30 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -7,6 +7,8 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.system.database.BungeeDBSystem; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.info.BukkitInfoSystem; +import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.listeners.BungeeListenerSystem; import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; import com.djrapitops.plan.system.tasks.BungeeTaskSystem; @@ -26,6 +28,9 @@ public BungeeSystem(PlanBungee plugin) { databaseSystem = new BungeeDBSystem(); listenerSystem = new BungeeListenerSystem(plugin); taskSystem = new BungeeTaskSystem(plugin); + + infoSystem = new BukkitInfoSystem(); + serverInfo = new BungeeServerInfo(plugin); } public static BungeeSystem getInstance() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index abd1384edb..2be10b2393 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -114,6 +114,7 @@ private void checkSubSystemInitialization() throws EnableException { NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized.")); NullCheck.check(databaseSystem, new IllegalStateException("Database system was not initialized.")); NullCheck.check(infoSystem, new IllegalStateException("Info system was not initialized.")); + NullCheck.check(serverInfo, new IllegalStateException("ServerInfo was not initialized.")); NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); NullCheck.check(taskSystem, new IllegalStateException("Task system was not initialized.")); } catch (Exception e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index bb4e3b4434..ec987cf3f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -76,4 +76,6 @@ public interface FetchOperations { String getPlayerName(UUID playerUUID) throws DBException; List getNicknames(UUID uuid) throws DBException; + + Set getBukkitServers() throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java new file mode 100644 index 0000000000..db5cc9e9e0 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java @@ -0,0 +1,30 @@ +/* + * 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.info; + +import com.djrapitops.plan.system.info.connection.BukkitConnectionSystem; +import com.djrapitops.plan.system.info.request.InfoRequest; + +/** + * InfoSystem for Bukkit servers. + * + * @author Rsl1122 + */ +public class BukkitInfoSystem extends InfoSystem { + + public BukkitInfoSystem() { + super(new BukkitConnectionSystem()); + } + + @Override + protected void runLocally(InfoRequest infoRequest) { + + } + + @Override + public void updateNetworkPage() { + runLocally(new GenerateNetworkPageContentRequest()); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java new file mode 100644 index 0000000000..5534a182b5 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -0,0 +1,72 @@ +/* + * 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.info.connection; + +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.TimeAmount; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.task.AbsRunnable; +import com.djrapitops.plugin.task.RunnableFactory; + +import java.util.Optional; +import java.util.Set; + +/** + * Connection system for Bukkit servers. + * + * @author Rsl1122 + */ +public class BukkitConnectionSystem extends ConnectionSystem { + + private long latestServerMapRefresh = 0; + + private Server mainServer; + private Set servers; + + public BukkitConnectionSystem() { + } + + @Override + protected Server selectServerForRequest(InfoRequest infoRequest) { + return null; + } + + @Override + public boolean isMainServerAvailable() { + return false; + } + + @Override + public Optional getMainAddress() { + return Optional.empty(); + } + + @Override + public void enable() { + RunnableFactory.createNew("Server List Update Task", new AbsRunnable() { + @Override + public void run() { + try { + Database database = Database.getActive(); + Optional bungeeInformation = database.fetch().getBungeeInformation(); + bungeeInformation.ifPresent(server -> mainServer = server); + servers = database.fetch().getBukkitServers(); + latestServerMapRefresh = MiscUtils.getTime(); + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + } + } + }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 30L, TimeAmount.MINUTE.ticks() * 5L); + } + + @Override + public void disable() { + + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java new file mode 100644 index 0000000000..aaaae70856 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java @@ -0,0 +1,66 @@ +/* + * 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.info.connection; + +import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.utilities.MiscUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * Class responsible for logging what ConnectionOut objects get in return. + * + * @author Rsl1122 + */ +public class ConnectionLog { + + private Map> log; + + public ConnectionLog() { + this.log = new HashMap<>(); + } + + public static Map> getLogEntries() { + return getInstance().getLog(); + } + + public static void logConnection(Server toServer, InfoRequest request, int responseCode) { + Map> log = getInstance().log; + + Map requestMap = log.getOrDefault(toServer, new HashMap<>()); + requestMap.put(request.getClass().getSimpleName(), new Entry(responseCode, MiscUtils.getTime())); + log.put(toServer, requestMap); + } + + private static ConnectionLog getInstance() { + return ConnectionSystem.getInstance().getConnectionLog(); + } + + public Map> getLog() { + return log; + } + + public static class Entry { + + private final int responseCode; + private final long timeSent; + + public Entry(int responseCode, long timeSent) { + this.responseCode = responseCode; + this.timeSent = timeSent; + } + + public int getResponseCode() { + return responseCode; + } + + public long getTimeSent() { + return timeSent; + } + } + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index d9bec9430c..108248de70 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.info.request.InfoRequest; import com.djrapitops.plan.system.info.request.InfoRequestWithVariables; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -45,25 +46,26 @@ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, Strin } }; - private final String address; + private final Server toServer; private final UUID serverUUID; private final InfoRequest infoRequest; /** * Constructor. * - * @param address Full address to another Plan webserver. (http://something:port) + * @param toServer Full address to another Plan webserver. (http://something:port) * @param serverUUID UUID of server this outbound connection. * @param infoRequest Type of the action this connection wants to be performed. */ - public ConnectionOut(String address, UUID serverUUID, InfoRequest infoRequest) { - Verify.nullCheck(address, serverUUID, infoRequest); - this.address = address; + public ConnectionOut(Server toServer, UUID serverUUID, InfoRequest infoRequest) { + Verify.nullCheck(toServer, serverUUID, infoRequest); + this.toServer = toServer; this.serverUUID = serverUUID; this.infoRequest = infoRequest; } public void sendRequest() throws WebException { + String address = toServer.getWebAddress(); try { URL url = new URL(address + "/api/" + this.getClass().getSimpleName().toLowerCase()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); @@ -112,7 +114,8 @@ public void sendRequest() throws WebException { } int responseCode = connection.getResponseCode(); - Log.debug("Response: " + responseCode); + + ConnectionLog.logConnection(toServer, infoRequest, responseCode); switch (responseCode) { case 200: return; @@ -130,11 +133,13 @@ public void sendRequest() throws WebException { throw new WebException(url.toString() + "| Wrong response code " + responseCode); } } catch (SocketTimeoutException e) { + ConnectionLog.logConnection(toServer, infoRequest, 0); throw new ConnectionFailException("Connection timed out after 10 seconds.", e); } catch (NoSuchAlgorithmException | KeyManagementException | IOException e) { if (Settings.DEV_MODE.isTrue()) { Log.toLog(this.getClass().getName(), e); } + ConnectionLog.logConnection(toServer, infoRequest, -1); throw new ConnectionFailException("Connection failed to address: " + address, e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 2264c4f946..de6152e76a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.NullCheck; import java.util.HashMap; @@ -26,15 +27,14 @@ */ public abstract class ConnectionSystem implements SubSystem { + protected final ConnectionLog connectionLog; protected final Map dataRequests; - protected final UUID serverUUID; protected Map servers; - public ConnectionSystem(UUID serverUUID) { - this.serverUUID = serverUUID; - + public ConnectionSystem() { servers = new HashMap<>(); dataRequests = loadDataRequests(); + connectionLog = new ConnectionLog(); } public static ConnectionSystem getInstance() { @@ -66,9 +66,12 @@ private void putRequest(Map requests, InfoRequest request) public void sendInfoRequest(InfoRequest infoRequest) throws WebException { Server server = selectServerForRequest(infoRequest); - String address = server.getWebAddress(); - new ConnectionOut(address, serverUUID, infoRequest).sendRequest(); + new ConnectionOut(server, ServerInfo.getServerUUID(), infoRequest).sendRequest(); + } + + public ConnectionLog getConnectionLog() { + return connectionLog; } public abstract boolean isMainServerAvailable(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 0fbf0e541b..9b77498009 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -5,13 +5,17 @@ package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.pages.*; import com.djrapitops.plan.system.webserver.response.*; +import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; 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.ForbiddenResponse; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; +import com.djrapitops.plan.system.webserver.response.errors.UnauthorizedServerResponse; import com.djrapitops.plugin.api.utility.log.Log; import java.util.Arrays; @@ -25,12 +29,10 @@ */ public class ResponseHandler extends TreePageHandler { - private final boolean authRequired; - private final boolean usingHttps; + private final WebServer webServer; public ResponseHandler(WebServer webServer) { - authRequired = webServer.isAuthRequired(); - this.usingHttps = webServer.isUsingHTTPS(); + this.webServer = webServer; } public void registerDefaultPages() { @@ -42,7 +44,7 @@ public void registerDefaultPages() { ServerPageHandler serverPageHandler = new ServerPageHandler(); registerPage("network", serverPageHandler); registerPage("server", serverPageHandler); - if (authRequired) { + if (webServer.isAuthRequired()) { registerPage("", new RootPageHandler(this)); } } @@ -80,41 +82,53 @@ public Response getResponse(Request request) { List target = Arrays.asList(targetString.split("/")); target.remove(0); try { - Optional authentication = Optional.empty(); - if (authRequired) { - authentication = request.getAuth(); - if (!authentication.isPresent()) { - if (usingHttps) { - return DefaultResponses.BASIC_AUTH.get(); - } else { - return forbiddenResponse(0, 0); - } - } - } - - PageHandler pageHandler = getPageHandler(target); - if (pageHandler == null) { - if (targetString.endsWith(".css")) { - return ResponseCache.loadResponse(PageId.CSS.of(targetString), () -> new CSSResponse(targetString)); - } - if (targetString.endsWith(".js")) { - return ResponseCache.loadResponse(PageId.JS.of(targetString), () -> new JavaScriptResponse(targetString)); - } - return DefaultResponses.NOT_FOUND.get(); - } else { - if (authentication.isPresent() && pageHandler.isAuthorized(authentication.get(), target)) { - return forbiddenResponse(0, 0); - } - return pageHandler.getResponse(request, target); - } + return getResponse(request, targetString, target); } catch (WebUserAuthException e) { return PromptAuthorizationResponse.getBasicAuthResponse(e); + } catch (NotFoundException e) { + return new NotFoundResponse(e.getMessage()); + } catch (ForbiddenException e) { + return new ForbiddenResponse(e.getMessage()); + } catch (BadRequestException e) { + return new BadRequestResponse(e.getMessage()); + } catch (UnauthorizedServerException e) { + return new UnauthorizedServerResponse(e.getMessage()); } catch (Exception e) { Log.toLog(this.getClass().getName(), e); return new InternalErrorResponse(request.getTarget(), e); } } + private Response getResponse(Request request, String targetString, List target) throws WebException { + Optional authentication = Optional.empty(); + if (webServer.isAuthRequired()) { + authentication = request.getAuth(); + if (!authentication.isPresent()) { + if (webServer.isUsingHTTPS()) { + return DefaultResponses.BASIC_AUTH.get(); + } else { + return forbiddenResponse(0, 0); + } + } + } + + PageHandler pageHandler = getPageHandler(target); + if (pageHandler == null) { + if (targetString.endsWith(".css")) { + return ResponseCache.loadResponse(PageId.CSS.of(targetString), () -> new CSSResponse(targetString)); + } + if (targetString.endsWith(".js")) { + return ResponseCache.loadResponse(PageId.JS.of(targetString), () -> new JavaScriptResponse(targetString)); + } + return DefaultResponses.NOT_FOUND.get(); + } else { + if (authentication.isPresent() && pageHandler.isAuthorized(authentication.get(), target)) { + return forbiddenResponse(0, 0); + } + return pageHandler.getResponse(request, target); + } + } + public Response forbiddenResponse(int required, int permLevel) { return ResponseCache.loadResponse(PageId.FORBIDDEN.of(required + "/" + permLevel), () -> new ForbiddenResponse("Unauthorized User.
    " diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/UnauthorizedServerResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/UnauthorizedServerResponse.java new file mode 100644 index 0000000000..cda90bd7b6 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/UnauthorizedServerResponse.java @@ -0,0 +1,20 @@ +/* + * 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.webserver.response.errors; + +/** + * Response when Server is not found in database when attempting to InfoRequest. + * + * @author Rsl1122 + */ +public class UnauthorizedServerResponse extends ErrorResponse { + + public UnauthorizedServerResponse(String message) { + super.setHeader("HTTP/1.1 412 Unauthorized"); + super.setTitle("Unauthorized Server"); + super.setParagraph(message); + super.replacePlaceholders(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 561781dae7..2077da47e5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -8,10 +8,12 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.info.connection.ConnectionLog; import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; +import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.Benchmark; @@ -52,6 +54,8 @@ private String buildParagraph() { appendServerInformation(content); + appendConnectionLog(content); + if (Check.isBungeeAvailable()) { appendBungeeConfiguration(content); } @@ -64,6 +68,34 @@ private String buildParagraph() { return content.toString(); } + private void appendConnectionLog(StringBuilder content) { + try { + Map> logEntries = ConnectionLog.getLogEntries(); + + content.append("

    ");
    +            content.append("Server name | Request Type | Sent | Response
    ") + .append("-- | -- | -- | --
    "); + for (Map.Entry> entry : logEntries.entrySet()) { + Server server = entry.getKey(); + Map requests = entry.getValue(); + for (Map.Entry requestEntry : requests.entrySet()) { + String infoRequest = requestEntry.getKey(); + ConnectionLog.Entry logEntry = requestEntry.getValue(); + + content.append(server.getName()).append(" | ") + .append(infoRequest).append(" | ") + .append(logEntry.getResponseCode()).append(" | ") + .append(FormatUtils.formatTimeStampSecond(logEntry.getTimeSent())).append("
    "); + } + + } + content.append("
    "); + + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } + } + private void appendServerInformation(StringBuilder content) { PlanPlugin plugin = PlanPlugin.getInstance(); ServerProperties variable = plugin.getVariable(); From 56717a8947265358de72e7838e7f740fef51b2ae Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 21 Jan 2018 17:03:56 +0200 Subject: [PATCH 041/166] Implemented Network Page updating --- .../plan/command/commands/DevCommand.java | 2 +- .../databases/operation/FetchOperations.java | 2 +- .../operation/TransferOperations.java | 2 +- .../plan/system/info/BukkitInfoSystem.java | 20 ++++-- .../plan/system/info/BungeeInfoSystem.java | 45 ++++++++++++ .../plan/system/info/InfoSystem.java | 6 +- .../connection/BukkitConnectionSystem.java | 71 +++++++++++++++---- .../connection/BungeeConnectionSystem.java | 13 ++++ .../info/connection/ConnectionSystem.java | 14 ++-- .../request/CacheAnalysisPageRequest.java | 2 +- .../info/request/CacheInspectPageRequest.java | 2 +- .../CacheNetworkPageContentRequest.java | 6 +- .../system/info/request/CacheRequest.java | 13 ++++ .../request/GenerateAnalysisPageRequest.java | 10 ++- .../request/GenerateInspectPageRequest.java | 10 ++- .../system/info/request/GenerateRequest.java | 13 ++++ .../system/info/server/ServerProperties.java | 14 ++++ .../info/NetworkPageUpdateProcessor.java | 8 ++- .../system/update/VersionCheckSystem.java | 4 ++ .../webserver/pages/parsing/InspectPage.java | 2 +- .../webserver/pages/parsing/NetworkPage.java | 37 +++++----- .../webserver/response/cache/PageId.java | 2 +- .../plan/utilities/analysis/Analysis.java | 5 ++ .../plan/utilities/html/HtmlStructure.java | 25 +++---- 24 files changed, 260 insertions(+), 68 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateRequest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index 80a0128615..e7f5eb3a2d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -52,7 +52,7 @@ public boolean onCommand(ISender sender, String cmd, String[] args) { ConnectionSystem connectionSystem = ConnectionSystem.getInstance(); Optional bungeeConnectionAddress = connectionSystem.getMainAddress(); String accessAddress = plugin.getWebServer().getAccessAddress(); - sender.sendMessage((connectionSystem.isMainServerAvailable() && bungeeConnectionAddress.isPresent()) + sender.sendMessage((connectionSystem.isServerAvailable() && bungeeConnectionAddress.isPresent()) ? "Bungee: " + bungeeConnectionAddress.get() : "Local: " + accessAddress); break; default: diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index ec987cf3f5..5ea8cfa1e3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -77,5 +77,5 @@ public interface FetchOperations { List getNicknames(UUID uuid) throws DBException; - Set getBukkitServers() throws DBException; + Map getBukkitServers() throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index e04e10e8b5..84201fb987 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -34,5 +34,5 @@ public interface TransferOperations { Map getEncodedServerHtml() throws DBException; - + UUID getServerPlayerIsOnline(UUID playerUUID) throws DBException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java index db5cc9e9e0..c7dad76ad1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java @@ -4,8 +4,15 @@ */ package com.djrapitops.plan.system.info; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.connection.BukkitConnectionSystem; +import com.djrapitops.plan.system.info.request.CacheNetworkPageContentRequest; import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.info.request.InfoRequestWithVariables; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.utilities.html.HtmlStructure; + +import java.util.HashMap; /** * InfoSystem for Bukkit servers. @@ -19,12 +26,17 @@ public BukkitInfoSystem() { } @Override - protected void runLocally(InfoRequest infoRequest) { - + protected void runLocally(InfoRequest infoRequest) throws WebException { + if (infoRequest instanceof InfoRequestWithVariables) { + infoRequest.handleRequest(((InfoRequestWithVariables) infoRequest).getVariables()); + } else { + infoRequest.handleRequest(new HashMap<>()); + } } @Override - public void updateNetworkPage() { - runLocally(new GenerateNetworkPageContentRequest()); + public void updateNetworkPage() throws WebException { + String html = HtmlStructure.createServerContainer(); + sendRequest(new CacheNetworkPageContentRequest(ServerInfo.getServerUUID(), html)); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java new file mode 100644 index 0000000000..98ddd5d375 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java @@ -0,0 +1,45 @@ +/* + * 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.info; + +import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.api.exceptions.connection.NoServersException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.WebFailException; +import com.djrapitops.plan.system.info.connection.BungeeConnectionSystem; +import com.djrapitops.plan.system.info.request.InfoRequest; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.webserver.pages.parsing.NetworkPage; +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; + +/** + * InfoSystem for Bungee. + * + * @author Rsl1122 + */ +public class BungeeInfoSystem extends InfoSystem { + + public BungeeInfoSystem() { + super(new BungeeConnectionSystem()); + } + + @Override + protected void runLocally(InfoRequest infoRequest) throws WebException { + // runLocally is called when ConnectionSystem has no servers. + throw new NoServersException("No servers were available to process this request."); + } + + @Override + public void updateNetworkPage() throws WebException { + try { + String html = new NetworkPage().toHtml(); + ResponseCache.cacheResponse(PageId.SERVER.of(ServerInfo.getServerUUID()), () -> new AnalysisPageResponse(html)); + } catch (ParseException e) { + throw new WebFailException("Exception during Network Page Parsing", e); + } + } +} \ No newline at end of file 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 5ce3e35b7f..041a15e8b1 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 @@ -56,13 +56,13 @@ public void generateAnalysisPage(UUID serverUUID) throws WebException { } public void sendRequest(InfoRequest infoRequest) throws WebException { - if (!connectionSystem.isMainServerAvailable()) { + if (!connectionSystem.isServerAvailable()) { runLocally(infoRequest); } connectionSystem.sendInfoRequest(infoRequest); } - protected abstract void runLocally(InfoRequest infoRequest); + protected abstract void runLocally(InfoRequest infoRequest) throws WebException; @Override public void enable() throws EnableException { @@ -78,5 +78,5 @@ public ConnectionSystem getConnectionSystem() { return connectionSystem; } - public abstract void updateNetworkPage(); + public abstract void updateNetworkPage() throws WebException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index 5534a182b5..fb155ce3f8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -4,18 +4,25 @@ */ package com.djrapitops.plan.system.info.connection; +import com.djrapitops.plan.api.exceptions.connection.NoServersException; +import com.djrapitops.plan.api.exceptions.connection.UnsupportedTransferDatabaseException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.request.CacheRequest; +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.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.RunnableFactory; +import java.util.Map; import java.util.Optional; -import java.util.Set; +import java.util.UUID; /** * Connection system for Bukkit servers. @@ -27,18 +34,63 @@ public class BukkitConnectionSystem extends ConnectionSystem { private long latestServerMapRefresh = 0; private Server mainServer; - private Set servers; + private Map servers; public BukkitConnectionSystem() { } + private void refreshServerMap() { + if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.MINUTE.ms() * 2L) { + try { + Database database = Database.getActive(); + Optional bungeeInformation = database.fetch().getBungeeInformation(); + bungeeInformation.ifPresent(server -> mainServer = server); + servers = database.fetch().getBukkitServers(); + latestServerMapRefresh = MiscUtils.getTime(); + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + } + } + } + @Override - protected Server selectServerForRequest(InfoRequest infoRequest) { + protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException { + refreshServerMap(); + + if (mainServer == null && servers.isEmpty()) { + throw new NoServersException("No Servers available to process requests."); + } + + Server server = null; + if (infoRequest instanceof CacheRequest) { + server = mainServer; + } else if (infoRequest instanceof GenerateAnalysisPageRequest) { + UUID serverUUID = ((GenerateAnalysisPageRequest) infoRequest).getServerUUID(); + server = servers.get(serverUUID); + } else if (infoRequest instanceof GenerateInspectPageRequest) { + UUID serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); + server = servers.getOrDefault(serverUUID, ServerInfo.getServer()); + } + if (server == null) { + throw new NoServersException("Proper server is not available to process requests."); + } + return server; + } + + private UUID getServerWherePlayerIsOnline(GenerateInspectPageRequest infoRequest) { + UUID playerUUID = infoRequest.getPlayerUUID(); + try { + return Database.getActive().transfer().getServerPlayerIsOnline(playerUUID); + } catch (UnsupportedTransferDatabaseException e) { + /* Do nothing */ + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + } return null; } @Override - public boolean isMainServerAvailable() { + public boolean isServerAvailable() { return false; } @@ -49,18 +101,11 @@ public Optional getMainAddress() { @Override public void enable() { + refreshServerMap(); RunnableFactory.createNew("Server List Update Task", new AbsRunnable() { @Override public void run() { - try { - Database database = Database.getActive(); - Optional bungeeInformation = database.fetch().getBungeeInformation(); - bungeeInformation.ifPresent(server -> mainServer = server); - servers = database.fetch().getBukkitServers(); - latestServerMapRefresh = MiscUtils.getTime(); - } catch (DBException e) { - Log.toLog(this.getClass().getName(), e); - } + refreshServerMap(); } }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 30L, TimeAmount.MINUTE.ticks() * 5L); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java new file mode 100644 index 0000000000..2b60431547 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java @@ -0,0 +1,13 @@ +/* + * 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.info.connection; + +/** + * ConnectionSystem for Bungee. + * + * @author Rsl1122 + */ +public class BungeeConnectionSystem extends ConnectionSystem { +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index de6152e76a..bca322dd1f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -65,16 +65,22 @@ private void putRequest(Map requests, InfoRequest request) protected abstract Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException; public void sendInfoRequest(InfoRequest infoRequest) throws WebException { - Server server = selectServerForRequest(infoRequest); - - new ConnectionOut(server, ServerInfo.getServerUUID(), infoRequest).sendRequest(); + try { + Server server = selectServerForRequest(infoRequest); + + new ConnectionOut(server, ServerInfo.getServerUUID(), infoRequest).sendRequest(); + } catch (NoServersException e) { + // At this point ConnectionSystem will return false on isServerAvailable + // -> InfoSystem will try to run request locally. + InfoSystem.getInstance().sendRequest(infoRequest); + } } public ConnectionLog getConnectionLog() { return connectionLog; } - public abstract boolean isMainServerAvailable(); + public abstract boolean isServerAvailable(); public abstract Optional getMainAddress(); } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java index 3b04ebc29a..c355695f28 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java @@ -24,7 +24,7 @@ * * @author Rsl1122 */ -public class CacheAnalysisPageRequest implements InfoRequest { +public class CacheAnalysisPageRequest implements CacheRequest { private final UUID serverUUID; private final String html; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index 285253744e..3ff1a0ee09 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -24,7 +24,7 @@ * * @author Rsl1122 */ -public class CacheInspectPageRequest implements InfoRequest { +public class CacheInspectPageRequest implements CacheRequest { private final UUID player; private final String html; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java index a16fa52b2b..ef84db1836 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java @@ -22,9 +22,11 @@ /** * InfoRequest for caching Network page parts to ResponseCache of receiving server. * + * SHOULD NOT BE SENT TO BUKKIT + * * @author Rsl1122 */ -public class CacheNetworkPageContentRequest implements InfoRequest { +public class CacheNetworkPageContentRequest implements CacheRequest { private final UUID serverUUID; private final String html; @@ -69,7 +71,7 @@ public Response handleRequest(Map variables) throws WebException String html = entry.getValue(); NetworkPageContent response = (NetworkPageContent) - ResponseCache.loadResponse(PageId.NETWORK_CONTENT.of(serverUUID), NetworkPageContent::new); + ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new); response.addElement(serverName, html); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheRequest.java new file mode 100644 index 0000000000..be2215dbc0 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheRequest.java @@ -0,0 +1,13 @@ +/* + * 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.info.request; + +/** + * Interface for all InfoRequests that cache something into RequestCache. + * + * @author Rsl1122 + */ +public interface CacheRequest extends InfoRequest { +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index ca8c49347f..5273752eaf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -21,14 +21,18 @@ * * @author Rsl1122 */ -public class GenerateAnalysisPageRequest extends InfoRequestWithVariables { +public class GenerateAnalysisPageRequest extends InfoRequestWithVariables implements GenerateRequest { + + private final UUID serverUUID; public GenerateAnalysisPageRequest(UUID serverUUID) { Verify.nullCheck(serverUUID); + this.serverUUID = serverUUID; variables.put("server", serverUUID.toString()); } private GenerateAnalysisPageRequest() { + serverUUID = null; } @Override @@ -62,4 +66,8 @@ public String getHtml() { public static GenerateAnalysisPageRequest createHandler() { return new GenerateAnalysisPageRequest(); } + + public UUID getServerUUID() { + return serverUUID; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index a6e8c0a6fd..ca55159dc4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -25,13 +25,17 @@ * * @author Rsl1122 */ -public class GenerateInspectPageRequest extends InfoRequestWithVariables { +public class GenerateInspectPageRequest extends InfoRequestWithVariables implements GenerateRequest { + + private final UUID playerUUID; private GenerateInspectPageRequest() { + playerUUID = null; } public GenerateInspectPageRequest(UUID uuid) { Verify.nullCheck(uuid); + playerUUID = uuid; variables.put("player", uuid.toString()); } @@ -73,4 +77,8 @@ private String getHtml(UUID uuid) throws WebException { } } } + + public UUID getPlayerUUID() { + return playerUUID; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateRequest.java new file mode 100644 index 0000000000..4221ccf507 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateRequest.java @@ -0,0 +1,13 @@ +/* + * 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.info.request; + +/** + * Interface for all InfoRequests that generate something. + * + * @author Rsl1122 + */ +public interface GenerateRequest extends InfoRequest { +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java index 8835512fc0..4517b020f4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java @@ -21,6 +21,8 @@ public class ServerProperties { private final String ip; private final int maxPlayers; + private final OnlinePlayersWrapper onlinePlayers; + public ServerProperties(Server server) { id = server.getServerId(); ip = server.getIp(); @@ -30,6 +32,8 @@ public ServerProperties(Server server) { implVersion = server.getBukkitVersion(); maxPlayers = server.getMaxPlayers(); + + onlinePlayers = () -> server.getOnlinePlayers().size(); } /** @@ -46,6 +50,8 @@ public ServerProperties(ProxyServer server) { implVersion = server.getVersion(); maxPlayers = server.getConfig().getPlayerLimit(); + + onlinePlayers = server::getOnlineCount; } /** @@ -80,4 +86,12 @@ public int getMaxPlayers() { public String getServerId() { return id; } + + public int getOnlinePlayers() { + return onlinePlayers.getOnlinePlayers(); + } + + private interface OnlinePlayersWrapper { + int getOnlinePlayers(); + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java index 6f10690c70..9d11a84f6c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java @@ -4,8 +4,10 @@ */ package com.djrapitops.plan.system.processing.processors.info; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plugin.api.utility.log.Log; /** * Processor for updating the network page. @@ -20,6 +22,10 @@ public NetworkPageUpdateProcessor() { @Override public void process() { - InfoSystem.getInstance().updateNetworkPage(); + try { + InfoSystem.getInstance().updateNetworkPage(); + } catch (WebException e) { + Log.toLog(this.getClass().getName(), e); + } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java index 143168280b..0e1a642a80 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java @@ -38,6 +38,10 @@ public static boolean isNewVersionAvailable() { return getInstance().newVersionAvailable; } + public static String getCurrentVersion() { + return getInstance().currentVersion; + } + @Override public void enable() { checkForNewVersion(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java index 5f55943b13..3eff784fab 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java @@ -234,7 +234,7 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp())); - if (!InfoSystem.getInstance().getConnectionSystem().isMainServerAvailable()) { + if (!InfoSystem.getInstance().getConnectionSystem().isServerAvailable()) { addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java index 5ec571e7a2..21d8bbf792 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.system.webserver.pages.parsing; -import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; @@ -12,13 +11,16 @@ 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.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.info.BungeeInformationManager; +import com.djrapitops.plan.system.update.VersionCheckSystem; +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.parts.NetworkPageContent; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.file.FileUtil; -import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plan.utilities.html.graphs.line.OnlineActivityGraph; import com.djrapitops.plugin.api.TimeAmount; @@ -35,40 +37,35 @@ */ public class NetworkPage extends Page { - private final PlanBungee plugin; - - public NetworkPage(PlanBungee plugin) { - this.plugin = plugin; - } - @Override public String toHtml() throws ParseException { try { - UUID serverUUID = plugin.getServerUuid(); + UUID serverUUID = ServerInfo.getServerUUID(); long now = MiscUtils.getTime(); - Database db = plugin.getDB(); - List networkOnlineData = db.fetch().getNetworkOnlineData(); + Database database = Database.getActive(); + List networkOnlineData = database.fetch().getNetworkOnlineData(); - peakTimes(serverUUID, now, db); + peakTimes(serverUUID, now, database); - uniquePlayers(now, db); + uniquePlayers(now, database); addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); addValue("networkName", Settings.BUNGEE_NETWORK_NAME.toString()); - addValue("version", plugin.getVersion()); + addValue("version", VersionCheckSystem.getCurrentVersion()); addValue("playersOnlineSeries", new OnlineActivityGraph(networkOnlineData).toHighChartsSeries()); addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE)); - addValue("playersOnline", plugin.getProxy().getOnlineCount()); + addValue("playersOnline", ServerInfo.getServerProperties().getOnlinePlayers()); - addValue("playersTotal", db.count().getNetworkPlayerCount()); + addValue("playersTotal", database.count().getNetworkPlayerCount()); - List registerDates = db.fetch().getRegisterDates(); + List registerDates = database.fetch().getRegisterDates(); addValue("playersNewDay", AnalysisUtils.getNewPlayers(registerDates, TimeAmount.DAY.ms(), now)); addValue("playersNewWeek", AnalysisUtils.getNewPlayers(registerDates, TimeAmount.WEEK.ms(), now)); addValue("playersNewMonth", AnalysisUtils.getNewPlayers(registerDates, TimeAmount.MONTH.ms(), now)); - Map networkPageContents = ((BungeeInformationManager) plugin.getInfoManager()).getNetworkPageContent(); - addValue("tabContentServers", HtmlStructure.createNetworkPageContent(networkPageContents)); + NetworkPageContent networkPageContent = (NetworkPageContent) + ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new); + addValue("tabContentServers", networkPageContent.getContents()); return HtmlUtils.replacePlaceholders(FileUtil.getStringFromResource("web/network.html"), placeHolders); } catch (Exception e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java index f44ce33b15..0b43938b5f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/PageId.java @@ -30,7 +30,7 @@ public enum PageId { AUTH_PROMPT("PromptAuth"), // PLAYER_PLUGINS_TAB("playerPluginsTab:"), - NETWORK_CONTENT("networkContent:"); + NETWORK_CONTENT("networkContent"); private final String id; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 34aac9ba59..081064dee8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -37,6 +37,11 @@ public class Analysis { private final Plan plugin; private int taskId = -1; + public static Optional getRefreshDate() { + // TODO + return Optional.empty(); + } + /** * Class Constructor. * diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 7a85e4375f..6a6f2bdf79 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -4,15 +4,15 @@ */ package com.djrapitops.plan.utilities.html; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.utilities.FormatUtils; +import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.html.graphs.line.OnlineActivityGraph; import com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator; import com.djrapitops.plan.utilities.html.tables.SessionsTableCreator; @@ -107,20 +107,21 @@ public static String createNetworkPageContent(Map networkPageConte return b.toString(); } - public static String createServerContainer(Plan plugin) { - ServerProperties variable = ServerInfo.getServerProperties(); - int maxPlayers = variable.getMaxPlayers(); - int online = plugin.getServer().getOnlinePlayers().size(); - Optional analysisRefreshDate = ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisRefreshDate(); + public static String createServerContainer() { + ServerProperties properties = ServerInfo.getServerProperties(); + int maxPlayers = properties.getMaxPlayers(); + int online = properties.getOnlinePlayers(); + Optional analysisRefreshDate = Analysis.getRefreshDate(); String refresh = analysisRefreshDate.map(FormatUtils::formatTimeStamp).orElse("-"); - String serverName = ServerInfo.getServerName(); - String serverType = variable.getVersion(); - String address = "../server/" + serverName; + Server server = ServerInfo.getServer(); + String serverName = server.getName(); + String serverType = properties.getVersion(); + String address = "../server/" + serverName; - Database db = plugin.getDB(); - UUID serverUUID = plugin.getServerUuid(); + Database db = Database.getActive(); + UUID serverUUID = server.getUuid(); String id = serverUUID.toString().replace("-", ""); int playerCount = 0; From 334451372b8ec37af4f4b574e66fe24d28c2dd26 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 22 Jan 2018 17:54:08 +0200 Subject: [PATCH 042/166] More work on ConnectionSystem --- .../plan/command/commands/DevCommand.java | 7 ++-- .../connection/BukkitConnectionSystem.java | 7 ++-- .../system/info/connection/ConnectionLog.java | 35 +++++++++++++++++++ .../info/connection/ConnectionSystem.java | 3 +- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index e7f5eb3a2d..2b4da7b951 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -50,10 +50,9 @@ public boolean onCommand(ISender sender, String cmd, String[] args) { break; case "web": ConnectionSystem connectionSystem = ConnectionSystem.getInstance(); - Optional bungeeConnectionAddress = connectionSystem.getMainAddress(); - String accessAddress = plugin.getWebServer().getAccessAddress(); - sender.sendMessage((connectionSystem.isServerAvailable() && bungeeConnectionAddress.isPresent()) - ? "Bungee: " + bungeeConnectionAddress.get() : "Local: " + accessAddress); + String accessAddress = connectionSystem.getMainAddress(); + sender.sendMessage((connectionSystem.isServerAvailable()) + ? "Bungee: " + accessAddress : "Local: " + accessAddress); break; default: break; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index fb155ce3f8..891c6414f6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -91,12 +91,13 @@ private UUID getServerWherePlayerIsOnline(GenerateInspectPageRequest infoRequest @Override public boolean isServerAvailable() { - return false; + return ConnectionLog.hasConnectionSucceeded(mainServer); } @Override - public Optional getMainAddress() { - return Optional.empty(); + public String getMainAddress() { + return isServerAvailable() ? mainServer.getWebAddress() : ServerInfo.getServer().getWebAddress(); + } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java index aaaae70856..366811aab3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.system.info.request.InfoRequest; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.utilities.Verify; import java.util.HashMap; import java.util.Map; @@ -36,6 +37,40 @@ public static void logConnection(Server toServer, InfoRequest request, int respo log.put(toServer, requestMap); } + public static boolean isConnectionPlausible(Server server) { + if (server == null) { + return false; + } + + Map serverLog = getInstance().getLog().get(server); + if (Verify.isEmpty(serverLog)) { + return true; + } + + return hasConnectionSucceeded(serverLog); + } + + public static boolean hasConnectionSucceeded(Server server) { + if (server == null) { + return false; + } + Map serverLog = getInstance().getLog().get(server); + if (Verify.isEmpty(serverLog)) { + return false; + } + + return hasConnectionSucceeded(serverLog); + } + + private static boolean hasConnectionSucceeded(Map serverLog) { + for (Entry entry : serverLog.values()) { + if (entry.responseCode == 200) { + return true; + } + } + return false; + } + private static ConnectionLog getInstance() { return ConnectionSystem.getInstance().getConnectionLog(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index bca322dd1f..797d3b027f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -15,7 +15,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.Optional; import java.util.UUID; /** @@ -82,5 +81,5 @@ public ConnectionLog getConnectionLog() { public abstract boolean isServerAvailable(); - public abstract Optional getMainAddress(); + public abstract String getMainAddress(); } \ No newline at end of file From 137b0f310072054ca863ee39ce72da8afa13d8d9 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 23 Jan 2018 17:31:45 +0200 Subject: [PATCH 043/166] Removed endless loop from ConnectionSystem.sendInfoRequest --- .../plan/system/info/connection/ConnectionSystem.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 797d3b027f..bde165d986 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -64,15 +64,8 @@ private void putRequest(Map requests, InfoRequest request) protected abstract Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException; public void sendInfoRequest(InfoRequest infoRequest) throws WebException { - try { - Server server = selectServerForRequest(infoRequest); - - new ConnectionOut(server, ServerInfo.getServerUUID(), infoRequest).sendRequest(); - } catch (NoServersException e) { - // At this point ConnectionSystem will return false on isServerAvailable - // -> InfoSystem will try to run request locally. - InfoSystem.getInstance().sendRequest(infoRequest); - } + Server server = selectServerForRequest(infoRequest); + new ConnectionOut(server, ServerInfo.getServerUUID(), infoRequest).sendRequest(); } public ConnectionLog getConnectionLog() { From f50d8dc90c8e6fef6a0caa124d8ecbf85d07ce41 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 23 Jan 2018 18:16:09 +0200 Subject: [PATCH 044/166] CacheInspectPluginsTabRequest --- .../plan/data/plugin/HookHandler.java | 27 +++++- .../operation/TransferOperations.java | 6 +- .../CacheInspectPluginsTabRequest.java | 90 +++++++++++++++++++ .../GenerateInspectPluginsTabRequest.java | 72 +++++++++++++++ .../parts/InspectPagePluginsContent.java | 36 +++++++- .../info/BukkitInformationManager.java | 24 +---- .../InspectPluginsTabContentCreator.java | 53 ----------- 7 files changed, 228 insertions(+), 80 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java index d6e3c3e452..ed0f3b7d75 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java @@ -1,11 +1,11 @@ package com.djrapitops.plan.data.plugin; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.utility.log.Log; -import java.util.ArrayList; -import java.util.List; +import java.util.*; /** * Class responsible for hooking to other plugins and managing the %plugins% @@ -35,6 +35,10 @@ public HookHandler(Plan plugin) { } } + public static HookHandler getInstance() { + return null;// TODO + } + /** * Adds a new PluginData source to the list. *

    @@ -72,4 +76,23 @@ public void addPluginDataSource(PluginData dataSource) { public List getAdditionalDataSources() { return additionalDataSources; } + + public Map getInspectContainersFor(UUID uuid) { + List plugins = getAdditionalDataSources(); + Map containers = new HashMap<>(); + for (PluginData pluginData : plugins) { + InspectContainer inspectContainer = new InspectContainer(); + try { + InspectContainer container = pluginData.getPlayerData(uuid, inspectContainer); + if (container != null && !container.isEmpty()) { + containers.put(pluginData, container); + } + } catch (Exception e) { + String sourcePlugin = pluginData.getSourcePlugin(); + Log.error("PluginData caused exception: " + sourcePlugin); + Log.toLog(this.getClass().getName() + " " + sourcePlugin, e); + } + } + return containers; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index 84201fb987..c385f693a9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -11,7 +11,7 @@ /** * Operations for transferring data via Database to another server. - * + *

    * Receiving server has to be using the same database. * * @author Rsl1122 @@ -26,6 +26,8 @@ public interface TransferOperations { void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws DBException; + void storePlayerPluginsTab(UUID player, UUID serverUUID, String encodedHtml) throws DBException; + // Get Map getEncodedPlayerHtml() throws DBException; @@ -35,4 +37,6 @@ public interface TransferOperations { Map getEncodedServerHtml() throws DBException; UUID getServerPlayerIsOnline(UUID playerUUID) throws DBException; + + Map getEncodedPlayerPluginsTabs(UUID playerUUID) throws DBException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java new file mode 100644 index 0000000000..2f81dc2c60 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java @@ -0,0 +1,90 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +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.parts.InspectPagePluginsContent; +import com.djrapitops.plan.utilities.Base64Util; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.utilities.Verify; + +import java.util.Map; +import java.util.UUID; + +/** + * InfoRequest used to place HTML of player's Plugins Tab to ResponseCache. + * + * @author Rsl1122 + */ +public class CacheInspectPluginsTabRequest extends InfoRequestWithVariables implements CacheRequest { + + private static final String SPLIT = ";;SPLIT;;"; + private final UUID player; + private final String navAndHtml; + + private CacheInspectPluginsTabRequest() { + player = null; + navAndHtml = null; + } + + public CacheInspectPluginsTabRequest(UUID player, String nav, String html) { + Verify.nullCheck(player, nav); + variables.put("player", player.toString()); + this.player = player; + this.navAndHtml = nav + SPLIT + html; + } + + public static CacheInspectPluginsTabRequest createHandler() { + return new CacheInspectPluginsTabRequest(); + } + + @Override + public void placeDataToDatabase() throws WebException { + Verify.nullCheck(player, navAndHtml); + + String encodedHtml = Base64Util.encode(navAndHtml); + try { + Database.getActive().transfer().storePlayerPluginsTab(player, ServerInfo.getServerUUID(), encodedHtml); + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + } + + @Override + public Response handleRequest(Map variables) throws WebException { + // Available variables: sender, player + + String player = variables.get("player"); + NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied.")); + + UUID uuid = UUID.fromString(player); + + try { + Map pages = Database.getActive().transfer().getEncodedPlayerPluginsTabs(uuid); + + InspectPagePluginsContent pluginsTab = (InspectPagePluginsContent) + ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), InspectPagePluginsContent::new); + + for (Map.Entry entry : pages.entrySet()) { + UUID serverUUID = entry.getKey(); + String[] html = Base64Util.decode(entry.getValue()).split(SPLIT); + + pluginsTab.addTab(serverUUID, html[0], html[1]); + } + } catch (DBException e) { + throw new TransferDatabaseException(e); + } + return DefaultResponses.SUCCESS.get(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java new file mode 100644 index 0000000000..e6557a9956 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java @@ -0,0 +1,72 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +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.parts.InspectPagePluginsContent; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.utilities.Verify; + +import java.util.Map; +import java.util.UUID; + +/** + * InfoRequest for Generating Inspect page plugins tab on receiving WebServer. + * + * @author Rsl1122 + */ +public class GenerateInspectPluginsTabRequest extends InfoRequestWithVariables implements GenerateRequest { + + private final UUID playerUUID; + + private GenerateInspectPluginsTabRequest() { + playerUUID = null; + } + + public GenerateInspectPluginsTabRequest(UUID uuid) { + Verify.nullCheck(uuid); + playerUUID = uuid; + variables.put("player", uuid.toString()); + } + + public static GenerateInspectPluginsTabRequest createHandler() { + return new GenerateInspectPluginsTabRequest(); + } + + @Override + public void placeDataToDatabase() { + // No data required in a Generate request + } + + @Override + public Response handleRequest(Map variables) throws WebException { + // Available variables: sender, player + + String player = variables.get("player"); + NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied.")); + + UUID uuid = UUID.fromString(player); + String[] navAndhtml = getNavAndHtml(uuid); + + InfoSystem.getInstance().sendRequest(new CacheInspectPluginsTabRequest(uuid, navAndhtml[0], navAndhtml[1])); + + return DefaultResponses.SUCCESS.get(); + } + + private String[] getNavAndHtml(UUID uuid) { + return ((InspectPagePluginsContent) ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), + InspectPagePluginsContent::new)).getContents(); + } + + public UUID getPlayerUUID() { + return playerUUID; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java index 691711f6a9..bc976bed08 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java @@ -4,8 +4,14 @@ */ package com.djrapitops.plan.system.webserver.response.pages.parts; +import com.djrapitops.plan.data.element.InspectContainer; +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator; import com.djrapitops.plan.utilities.html.HtmlStructure; +import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator; import java.util.*; @@ -26,11 +32,37 @@ public InspectPagePluginsContent() { } public InspectPagePluginsContent(UUID serverUUID, String nav, String html) { - pluginsTab = new HashMap<>(); - + this(); addTab(serverUUID, nav, html); } + public static InspectPagePluginsContent generateForThisServer(UUID uuid) { + HookHandler hookHandler = HookHandler.getInstance(); + Map containers = hookHandler.getInspectContainersFor(uuid); + String serverName = ServerInfo.getServerName(); + String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName; + if (containers.isEmpty()) { + new InspectPagePluginsContent(uuid, "

  • " + actualServerName + "(No Data)
  • ", ""); + } + + String nav = "
  • " + actualServerName + "
  • "; + + StringBuilder tab = new StringBuilder(); + tab.append("
    "); + + List order = new ArrayList<>(containers.keySet()); + order.sort(new PluginDataNameComparator()); + + for (PluginData pluginData : order) { + InspectContainer container = containers.get(pluginData); + AnalysisPluginsTabContentCreator.appendThird(pluginData, container, tab); + } + + tab.append("
    "); + + return new InspectPagePluginsContent(ServerInfo.getServerUUID(), nav, tab.toString()); + } + public void addTab(UUID serverUUID, String nav, String html) { pluginsTab.put(serverUUID, new String[]{nav, html}); } 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 index fd65773d88..74a95f9fc6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -12,9 +12,6 @@ import com.djrapitops.plan.api.exceptions.connection.WebFailException; import com.djrapitops.plan.command.commands.AnalyzeCommand; import com.djrapitops.plan.data.AnalysisData; -import com.djrapitops.plan.data.element.InspectContainer; -import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.processing.processors.Processor; @@ -31,6 +28,7 @@ import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; +import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePluginsContent; 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; @@ -40,7 +38,6 @@ import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.html.HtmlStructure; -import com.djrapitops.plan.utilities.html.structure.InspectPluginsTabContentCreator; import com.djrapitops.plugin.api.utility.log.ErrorLogger; import com.djrapitops.plugin.api.utility.log.Log; @@ -162,24 +159,7 @@ public void cacheInspectPluginsTab(UUID uuid, Class origin) { cacheInspectPluginsTab(uuid, origin); } } else { - HookHandler hookHandler = plugin.getHookHandler(); - List plugins = hookHandler.getAdditionalDataSources(); - Map containers = new HashMap<>(); - for (PluginData pluginData : plugins) { - InspectContainer inspectContainer = new InspectContainer(); - try { - InspectContainer container = pluginData.getPlayerData(uuid, inspectContainer); - if (container != null && !container.isEmpty()) { - containers.put(pluginData, container); - } - } catch (Exception e) { - String sourcePlugin = pluginData.getSourcePlugin(); - Log.error("PluginData caused exception: " + sourcePlugin); - Log.toLog(this.getClass().getName() + " " + sourcePlugin, e); - } - } - - cacheInspectPluginsTab(uuid, InspectPluginsTabContentCreator.createContent(containers)); + cacheInspectPluginsTab(uuid, InspectPagePluginsContent.generateForThisServer(uuid).getContents()); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java deleted file mode 100644 index 46f9f383b9..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/InspectPluginsTabContentCreator.java +++ /dev/null @@ -1,53 +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.utilities.html.structure; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.element.InspectContainer; -import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.system.info.server.BukkitServerInfo; -import com.djrapitops.plan.system.info.server.ServerInfo; -import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * HTML utility class for parsing HTML for Inspect page plugins tabs. - * - * @author Rsl1122 - */ -public class InspectPluginsTabContentCreator { - - public static String[] createContent(Map containers) { - BukkitServerInfo serverInfoManager = Plan.getInstance().getServerInfoManager(); - String serverName = ServerInfo.getServerName(); - String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName; - - if (containers.isEmpty()) { - return new String[]{"
  • " + actualServerName + "(No Data)
  • ", - ""}; - } - - String nav = "
  • " + actualServerName + "
  • "; - - StringBuilder tab = new StringBuilder(); - tab.append("
    "); - - List order = new ArrayList<>(containers.keySet()); - order.sort(new PluginDataNameComparator()); - - for (PluginData pluginData : order) { - InspectContainer container = containers.get(pluginData); - AnalysisPluginsTabContentCreator.appendThird(pluginData, container, tab); - } - - tab.append("
    "); - - return new String[]{nav, tab.toString()}; - } - -} \ No newline at end of file From 457334403ecda400b054d9699dc2a4c1d1b08a0b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 23 Jan 2018 18:38:47 +0200 Subject: [PATCH 045/166] Transfer Operations for CacheInspectPluginsTab --- .../operation/TransferOperations.java | 2 +- .../sql/operation/SQLTransferOps.java | 23 +++++++++ .../databases/sql/tables/TransferTable.java | 48 +++++++++++++++++++ .../CacheInspectPluginsTabRequest.java | 3 +- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index c385f693a9..862b4c021f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -26,7 +26,7 @@ public interface TransferOperations { void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws DBException; - void storePlayerPluginsTab(UUID player, UUID serverUUID, String encodedHtml) throws DBException; + void storePlayerPluginsTab(UUID player, String encodedHtml) throws DBException; // Get diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java index e724aeb983..910ad05c92 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java @@ -76,4 +76,27 @@ public Map getEncodedServerHtml() throws DBException { throw SQLErrorUtil.getExceptionFor(e); } } + + @Override + public void storePlayerPluginsTab(UUID player, String encodedHtml) throws DBException { + try { + transferTable.storePlayerPluginsTab(player, encodedHtml); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public UUID getServerPlayerIsOnline(UUID playerUUID) { + return null; // TODO + } + + @Override + public Map getEncodedPlayerPluginsTabs(UUID playerUUID) throws DBException { + try { + return transferTable.getPlayerPluginsTabs(playerUUID); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java index 21db2abe51..09851e7912 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -12,6 +12,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plan.system.info.request.CacheAnalysisPageRequest; import com.djrapitops.plan.system.info.request.CacheInspectPageRequest; +import com.djrapitops.plan.system.info.request.CacheInspectPluginsTabRequest; import com.djrapitops.plan.system.info.request.CacheNetworkPageContentRequest; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; @@ -147,4 +148,51 @@ public Map getNetworkPageContent() throws SQLException { public Map getServerHtml() throws SQLException { return getHtmlPerUUIDForCacheRequest(CacheAnalysisPageRequest.class); } + + public void storePlayerPluginsTab(UUID player, String encodedHtml) throws SQLException { + execute(new ExecStatement(insertStatement) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, ServerInfo.getServerUUID().toString()); + statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms()); + statement.setString(3, CacheInspectPluginsTabRequest.class.getSimpleName().toLowerCase()); + statement.setString(4, player.toString()); + statement.setString(5, encodedHtml); + } + }); + } + + public Map getPlayerPluginsTabs(UUID playerUUID) throws SQLException { + String serverIDColumn = serverTable + "." + serverTable.getColumnID(); + String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid"; + String sql = "SELECT " + + columnContent + ", " + + serverUUIDColumn + + " FROM " + tableName + + " JOIN " + serverTable + " on " + serverIDColumn + "=" + columnSenderID + + " WHERE " + columnInfoType + "= ?" + + " AND " + columnExpiry + "> ?" + + " AND " + columnExtraVariables + "=?"; + + return query(new QueryStatement>(sql, 250) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, CacheInspectPluginsTabRequest.class.getSimpleName().toLowerCase()); + statement.setLong(2, MiscUtils.getTime()); + statement.setString(3, playerUUID.toString()); + } + + @Override + public Map processResults(ResultSet set) throws SQLException { + Map htmlPerUUID = new HashMap<>(); + while (set.next()) { + UUID serverUUID = UUID.fromString(set.getString("s_uuid")); + String html64 = set.getString(columnContent); + + htmlPerUUID.put(serverUUID, html64); + } + return htmlPerUUID; + } + }); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java index 2f81dc2c60..42a27f37a2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java @@ -9,7 +9,6 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.pages.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.PageId; @@ -55,7 +54,7 @@ public void placeDataToDatabase() throws WebException { String encodedHtml = Base64Util.encode(navAndHtml); try { - Database.getActive().transfer().storePlayerPluginsTab(player, ServerInfo.getServerUUID(), encodedHtml); + Database.getActive().transfer().storePlayerPluginsTab(player, encodedHtml); } catch (DBException e) { throw new TransferDatabaseException(e); } From 4e959c325b2763d54d6f1a8afd964caa70f1f39b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 11:02:16 +0200 Subject: [PATCH 046/166] Removal of re-implemented methods that were deprecated for this refactor --- .../main/java/com/djrapitops/plan/Plan.java | 10 - .../java/com/djrapitops/plan/api/PlanAPI.java | 2 + .../commands/manage/ManageClearCommand.java | 4 +- .../commands/manage/ManageRemoveCommand.java | 4 +- .../commands/manage/ManageRestoreCommand.java | 3 - .../plan/data/container/PlayerKill.java | 4 +- .../plan/system/cache/DataCache.java | 7 + .../plan/system/cache/SessionCache.java | 4 +- .../listeners/BukkitListenerSystem.java | 6 +- .../system/listeners/bukkit/ChatListener.java | 21 +- .../bukkit/GamemodeChangeListener.java | 3 +- .../bukkit/PlayerOnlineListener.java | 23 +- .../listeners/bukkit/WorldChangeListener.java | 9 +- .../info/InspectCacheRequestProcessor.java | 26 ++- .../processors/player/DeathProcessor.java | 4 +- .../player/EndSessionProcessor.java | 4 +- .../player/FirstLeaveProcessor.java | 5 +- .../processors/player/KillProcessor.java | 3 +- .../processors/player/NameProcessor.java | 2 +- .../processors/player/RegisterProcessor.java | 5 +- .../tasks/bukkit/NetworkPageRefreshTask.java | 5 +- .../response/pages/DebugPageResponse.java | 3 +- .../webapi/bukkit/InspectWebAPI.java | 5 +- .../RequestInspectPluginsTabBukkitWebAPI.java | 5 +- .../webapi/bungee/IsCachedWebAPI.java | 25 +- .../bungee/PostInspectPluginsTabWebAPI.java | 6 +- .../bungee/PostNetworkPageContentWebAPI.java | 6 +- .../info/BukkitInformationManager.java | 181 +-------------- .../info/BungeeInformationManager.java | 215 +----------------- .../plan/systems/info/InformationManager.java | 32 --- .../plan/utilities/analysis/Analysis.java | 6 +- .../plan/utilities/html/HtmlUtils.java | 28 --- .../structure/SessionTabStructureCreator.java | 4 +- .../html/tables/KillsTableCreator.java | 5 +- .../html/tables/SessionsTableCreator.java | 5 +- .../plan/utilities/uuid/UUIDUtility.java | 4 +- .../java/com/djrapitops/plan/api/API.java | 21 +- .../plan/system/database/DatabaseTest.java | 2 +- .../main/java/test/utilities/TestInit.java | 15 +- 39 files changed, 119 insertions(+), 603 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 72df1f1ca7..56aa8b6d92 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -27,7 +27,6 @@ import com.djrapitops.plan.settings.theme.PlanColorScheme; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.BukkitSystem; -import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; @@ -219,15 +218,6 @@ public void onReload() { } - /** - * Used to access Cache. - * - * @return Current instance of the DataCache - */ - public DataCache getDataCache() { - return getInfoManager().getDataCache(); - } - /** * Used to access active Database. * diff --git a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java index 851ed49bee..879315e144 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java @@ -23,6 +23,8 @@ static PlanAPI getInstance() { void addPluginDataSource(PluginData pluginData); + String getPlayerInspectPageLink(UUID uuid); + String getPlayerInspectPageLink(String playerName); String getPlayerName(UUID uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index a95e6543c1..b5c0d29307 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -7,7 +7,6 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; @@ -88,11 +87,10 @@ public void run() { database.remove().everything(); - DataCache dataCache = plugin.getDataCache(); long now = MiscUtils.getTime(); SessionCache.clear(); plugin.getServer().getOnlinePlayers().forEach( - player -> dataCache.cacheSession(player.getUniqueId(), + player -> SessionCache.getInstance().cacheSession(player.getUniqueId(), new Session(now, player.getWorld().getName(), player.getGameMode().name())) ); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString()); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 06c1709b80..636a9e3e99 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -5,7 +5,6 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; @@ -95,11 +94,10 @@ public void run() { database.remove().player(uuid); - DataCache dataCache = plugin.getDataCache(); Player player = getPlayer(uuid); if (player != null) { SessionCache.getActiveSessions().remove(uuid); - dataCache.cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name())); + SessionCache.getInstance().cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name())); } sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName())); } catch (DBException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index 2f0ea5e35b..9f023a2eec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -93,9 +93,6 @@ public void run() { sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse()); ManageUtils.clearAndCopy(database, backupDB); - if (database.getConfigName().equals(plugin.getDB().getConfigName())) { -// plugin.getDataCache().getCommandUseFromDb(); - } sender.sendMessage(Locale.get(Msg.MANAGE_INFO_COPY_SUCCESS).toString()); } catch (Exception e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java index 56b9c7836b..ffaf707666 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.data.container; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.Actions; +import com.djrapitops.plan.system.cache.DataCache; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Objects; @@ -60,7 +60,7 @@ public String getWeapon() { } public Action convertToAction() { - String name = Plan.getInstance().getDataCache().getName(victim); + String name = DataCache.getInstance().getName(victim); return new Action(time, Actions.KILLED, name + " with " + weapon); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java index 22f4d60084..a2d907d92a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java @@ -3,6 +3,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.log.Log; import java.util.*; @@ -41,6 +42,12 @@ public DataCache(PlanSystem system) { uuids = new HashMap<>(); } + public static DataCache getInstance() { + DataCache dataCache = CacheSystem.getInstance().getDataCache(); + NullCheck.check(dataCache, new IllegalStateException("Data Cache was not initialized.")); + return dataCache; + } + /** * Used to update PlayerName and DisplayName caches. * diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java index 84d34f1189..b84dab53d5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java @@ -82,7 +82,7 @@ public void endSession(UUID uuid, long time) { } } - public void refreshActiveSessionsState() { + public static void refreshActiveSessionsState() { for (Session session : activeSessions.values()) { session.getWorldTimes().updateState(MiscUtils.getTime()); } @@ -94,7 +94,7 @@ public void refreshActiveSessionsState() { * @param uuid UUID of the player. * @return Session or null if not cached. */ - public Optional getCachedSession(UUID uuid) { + public static Optional getCachedSession(UUID uuid) { Session session = activeSessions.get(uuid); if (session != null) { return Optional.of(session); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java index c2118f80f3..12191c9a93 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java @@ -15,10 +15,10 @@ public BukkitListenerSystem(Plan plugin) { @Override protected void registerListeners() { plugin.registerListener( - new PlayerOnlineListener(plugin), - new ChatListener(plugin), + new PlayerOnlineListener(), + new ChatListener(), new GamemodeChangeListener(plugin), - new WorldChangeListener(plugin), + new WorldChangeListener(), new CommandPreprocessListener(plugin), new DeathEventListener(plugin) ); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java index 7de1bf1b95..3de3b38ba9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/ChatListener.java @@ -1,7 +1,6 @@ package com.djrapitops.plan.system.listeners.bukkit; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.processing.processors.player.NameProcessor; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.entity.Player; @@ -19,19 +18,6 @@ */ public class ChatListener implements Listener { - private final Plan plugin; - private final DataCache dataCache; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public ChatListener(Plan plugin) { - this.plugin = plugin; - dataCache = plugin.getDataCache(); - } - /** * ChatEvent listener. * @@ -49,8 +35,9 @@ public void onChat(AsyncPlayerChatEvent event) { String name = p.getName(); String displayName = p.getDisplayName(); - if (dataCache.isFirstSession(uuid)) { - dataCache.firstSessionMessageSent(uuid); + SessionCache sessionCache = SessionCache.getInstance(); + if (sessionCache.isFirstSession(uuid)) { + sessionCache.firstSessionMessageSent(uuid); } new NameProcessor(uuid, name, displayName).queue(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java index dbfdb6c95d..6a94870d60 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java @@ -3,6 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.WorldAliasSettings; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.entity.Player; @@ -51,7 +52,7 @@ public void onGamemodeChange(PlayerGameModeChangeEvent event) { new WorldAliasSettings().addWorld(worldName); - Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); + Optional cachedSession = SessionCache.getInstance().getCachedSession(uuid); cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time)); } catch (Exception e) { Log.toLog(this.getClass(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index dd02bba3be..712bdb8d21 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -1,8 +1,7 @@ package com.djrapitops.plan.system.listeners.bukkit; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; import com.djrapitops.plan.system.processing.processors.player.*; @@ -31,19 +30,6 @@ public class PlayerOnlineListener implements Listener { private static boolean countKicks = true; - private final Plan plugin; - private final DataCache cache; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public PlayerOnlineListener(Plan plugin) { - this.plugin = plugin; - cache = plugin.getDataCache(); - } - public static void setCountKicks(boolean value) { countKicks = value; } @@ -108,7 +94,7 @@ public void onPlayerJoin(PlayerJoinEvent event) { int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline(); - cache.cacheSession(uuid, Session.start(time, world, gm)); + SessionCache.getInstance().cacheSession(uuid, Session.start(time, world, gm)); Processor.queueMany( new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline, @@ -141,8 +127,9 @@ public void onPlayerQuit(PlayerQuitEvent event) { new NetworkPageUpdateProcessor() ); - if (cache.isFirstSession(uuid)) { - int messagesSent = plugin.getDataCache().getFirstSessionMsgCount(uuid); + SessionCache sessionCache = SessionCache.getInstance(); + if (sessionCache.isFirstSession(uuid)) { + int messagesSent = sessionCache.getFirstSessionMsgCount(uuid); new FirstLeaveProcessor(uuid, time, messagesSent).queue(); } } catch (Exception e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java index 860465d83a..0dc9de33db 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.system.listeners.bukkit; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.settings.WorldAliasSettings; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.entity.Player; @@ -15,11 +15,6 @@ import java.util.UUID; public class WorldChangeListener implements Listener { - private final Plan plugin; - - public WorldChangeListener(Plan plugin) { - this.plugin = plugin; - } @EventHandler(priority = EventPriority.MONITOR) public void onWorldChange(PlayerChangedWorldEvent event) { @@ -33,7 +28,7 @@ public void onWorldChange(PlayerChangedWorldEvent event) { new WorldAliasSettings().addWorld(worldName); - Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); + Optional cachedSession = SessionCache.getCachedSession(uuid); cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time)); } catch (Exception e) { Log.toLog(this.getClass(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java index b0e28ef5e0..17b4af5ca9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java @@ -4,12 +4,14 @@ */ package com.djrapitops.plan.system.processing.processors.info; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.cache.SessionCache; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; +import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; @@ -33,19 +35,23 @@ public InspectCacheRequestProcessor(UUID uuid, ISender sender, String playerName @Override public void process() { - PlanPlugin plugin = PlanPlugin.getInstance(); - plugin.getInfoManager().cachePlayer(getUUID()); - DataCache dataCache = plugin.getInfoManager().getDataCache(); - if (dataCache != null) { - dataCache.refreshActiveSessionsState(); + SessionCache.getInstance().refreshActiveSessionsState(); + try { + InfoSystem.getInstance().generateAndCachePlayerPage(getUUID()); + sendInspectMsg(sender, playerName); + } catch (ConnectionFailException | UnsupportedTransferDatabaseException | UnauthorizedServerException + | NotFoundException | NoServersException e) { + // TODO Test if this is appropriate + sender.sendMessage("§c" + e.getMessage()); + } catch (WebException e) { + Log.toLog(this.getClass().getName(), e); } - sendInspectMsg(sender, playerName); } private void sendInspectMsg(ISender sender, String playerName) { sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT) + " " + playerName); // Link - String url = Plan.getInstance().getInfoManager().getLinkTo("/player/" + playerName); + String url = ConnectionSystem.getInstance().getMainAddress() + "/player/" + playerName; 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/system/processing/processors/player/DeathProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java index 91c0464dba..f15c7448b0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.SessionCache; import java.util.Optional; import java.util.UUID; @@ -26,7 +26,7 @@ public DeathProcessor(UUID uuid) { @Override public void process() { UUID uuid = getUUID(); - Optional cachedSession = Plan.getInstance().getDataCache().getCachedSession(uuid); + Optional cachedSession = SessionCache.getCachedSession(uuid); cachedSession.ifPresent(Session::died); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/EndSessionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/EndSessionProcessor.java index 55e7e2f677..0fd989ffe5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/EndSessionProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/EndSessionProcessor.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.cache.SessionCache; import java.util.UUID; @@ -25,6 +25,6 @@ public EndSessionProcessor(UUID uuid, long time) { @Override public void process() { UUID uuid = getUUID(); - Plan.getInstance().getDataCache().endSession(uuid, time); + SessionCache.getInstance().endSession(uuid, time); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java index f010de8378..9049bf7742 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/FirstLeaveProcessor.java @@ -4,10 +4,10 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.utility.log.Log; @@ -30,14 +30,13 @@ public FirstLeaveProcessor(UUID uuid, long time, int messagesSent) { @Override public void process() { - Plan plugin = Plan.getInstance(); UUID uuid = getUUID(); try { Database.getActive().save().action(uuid, leaveAction); } catch (DBException e) { Log.toLog(this.getClass().getName(), e); } finally { - plugin.getDataCache().endFirstSessionActionTracking(uuid); + SessionCache.getInstance().endFirstSessionActionTracking(uuid); } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java index ce24473825..94ee3983eb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java @@ -3,6 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.SessionCache; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -45,7 +46,7 @@ public void process() { Plan plugin = Plan.getInstance(); - Optional cachedSession = plugin.getDataCache().getCachedSession(uuid); + Optional cachedSession = SessionCache.getCachedSession(uuid); if (!cachedSession.isPresent()) { return; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java index 5c44579909..fa4b7f5635 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java @@ -36,7 +36,7 @@ public NameProcessor(UUID uuid, String playerName, String displayName) { public void process() { UUID uuid = getUUID(); Plan plugin = Plan.getInstance(); - DataCache dataCache = plugin.getDataCache(); + DataCache dataCache = DataCache.getInstance(); String cachedName = dataCache.getName(uuid); String cachedDisplayName = dataCache.getDisplayName(uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index a77728eb32..8dae1a0a99 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java @@ -4,10 +4,10 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; +import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plugin.api.utility.log.Log; @@ -39,7 +39,6 @@ public RegisterProcessor(UUID uuid, long registered, long time, String name, int @Override public void process() { UUID uuid = getUUID(); - Plan plugin = Plan.getInstance(); Database db = Database.getActive(); try { if (!db.check().isPlayerRegistered(uuid)) { @@ -51,7 +50,7 @@ public void process() { if (db.fetch().getActions(uuid).size() > 0) { return; } - plugin.getDataCache().markFirstSession(uuid); + SessionCache.getInstance().markFirstSession(uuid); db.save().action(uuid, new Action(time, Actions.FIRST_SESSION, "Online: " + playersOnline + " Players")); } catch (DBException e) { Log.toLog(this.getClass().getName(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java index 38f4c42617..6589bf4c12 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/bukkit/NetworkPageRefreshTask.java @@ -1,6 +1,7 @@ package com.djrapitops.plan.system.tasks.bukkit; -import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.connection.WebExceptionLogger; import com.djrapitops.plugin.task.AbsRunnable; public class NetworkPageRefreshTask extends AbsRunnable { @@ -11,6 +12,6 @@ public NetworkPageRefreshTask() { @Override public void run() { - PlanPlugin.getInstance().getInfoManager().updateNetworkPageContent(); + WebExceptionLogger.logIfOccurs(this.getClass(), () -> InfoSystem.getInstance().updateNetworkPage()); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 2077da47e5..8cb5d33f75 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -18,6 +18,7 @@ import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.Check; +import com.djrapitops.plugin.api.utility.log.ErrorLogger; import com.djrapitops.plugin.api.utility.log.Log; import java.io.File; @@ -208,7 +209,7 @@ private void appendLoggedErrors(StringBuilder content) { try { content.append("
    ### Logged Errors
    "); - TreeMap> errors = PlanPlugin.getInstance().getInfoManager().getErrors(); + TreeMap> errors = ErrorLogger.getLoggedErrors(PlanPlugin.getInstance()); if (!errors.isEmpty()) { List errorLines = new ArrayList<>(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java index 99c1c7f1da..4507dbe65f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java @@ -15,6 +15,7 @@ /** * @author Rsl1122 */ +@Deprecated public class InspectWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { @@ -24,9 +25,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } UUID uuid = UUID.fromString(uuidS); - plugin.getInfoManager().cachePlayer(uuid); - - return success(); + return fail("WebAPI deprecated"); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java index 86447cbe5d..741abac3b2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java @@ -8,7 +8,6 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plugin.api.Check; import java.util.Map; @@ -25,6 +24,7 @@ * * @author Rsl1122 */ +@Deprecated public class RequestInspectPluginsTabBukkitWebAPI extends WebAPI { @Override @@ -39,8 +39,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } UUID uuid = UUID.fromString(uuidS); - ((BukkitInformationManager) plugin.getInfoManager()).cacheInspectPluginsTab(uuid, this.getClass()); - return success(); + return fail("Deprecated"); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java index 1bbb2afa03..d8b3c317db 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java @@ -9,7 +9,6 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.info.InformationManager; import java.util.Map; import java.util.UUID; @@ -19,33 +18,13 @@ * * @author Rsl1122 */ +@Deprecated public class IsCachedWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { try { - String target = variables.get("target"); - InformationManager infoManager = plugin.getInfoManager(); - boolean cached = false; - switch (target) { - case "inspectPage": - if (infoManager.isCached(UUID.fromString(variables.get("uuid")))) { - cached = true; - } - break; - case "analysisPage": - if (infoManager.isAnalysisCached(UUID.fromString(variables.get("serverUUID")))) { - cached = true; - } - break; - default: - return badRequest("Faulty Target"); - } - if (cached) { - return success(); - } else { - return fail("Not Cached"); - } + return fail("Deprecated"); } catch (NullPointerException e) { return badRequest(e.toString()); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java index 3b3af604cc..8161fc5e2b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java @@ -8,7 +8,6 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.info.BungeeInformationManager; import java.util.Map; import java.util.UUID; @@ -23,6 +22,7 @@ * * @author Rsl1122 */ +@Deprecated public class PostInspectPluginsTabWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { @@ -43,9 +43,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } String[] content = new String[]{nav, html}; - ((BungeeInformationManager) plugin.getInfoManager()).cachePluginsTabContent(serverUUID, uuid, content); - - return success(); + return fail("Deprecated"); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java index 250aa896da..80e9962a5b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java @@ -4,12 +4,10 @@ */ 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.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plugin.api.Check; import java.util.Map; @@ -20,6 +18,7 @@ * * @author Rsl1122 */ +@Deprecated public class PostNetworkPageContentWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { @@ -33,8 +32,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { return badRequest("html not present"); } - ((BungeeInformationManager) plugin.getInfoManager()).cacheNetworkPageContent(serverUUID, html); - return success(); + 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 index 74a95f9fc6..a608480924 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -13,37 +13,29 @@ import com.djrapitops.plan.command.commands.AnalyzeCommand; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.processing.processors.Processor; 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.pages.parsing.InspectPage; -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.errors.ErrorResponse; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; -import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; -import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; -import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePluginsContent; 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.bukkit.RequestInspectPluginsTabBukkitWebAPI; -import com.djrapitops.plan.system.webserver.webapi.bungee.*; +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.plan.utilities.html.HtmlStructure; -import com.djrapitops.plugin.api.utility.log.ErrorLogger; import com.djrapitops.plugin.api.utility.log.Log; -import java.io.IOException; import java.sql.SQLException; -import java.util.*; +import java.util.HashSet; +import java.util.Optional; +import java.util.UUID; /** * Manages the Information going to the ResponseCache. @@ -56,18 +48,12 @@ public class BukkitInformationManager extends InformationManager { private final Plan plugin; - private final DataCache dataCache; private final Analysis analysis; - private final Map pluginsTabContents; private AnalysisData analysisData; - private String analysisPluginsTab; - private Long refreshDate; public BukkitInformationManager(Plan plugin) { this.plugin = plugin; - dataCache = new DataCache(plugin); analysis = new Analysis(plugin); - pluginsTabContents = new HashMap<>(); usingAnotherWebServer = false; } @@ -84,7 +70,6 @@ public void updateConnection() { @Override public void refreshAnalysis(UUID serverUUID) { if (Plan.getServerUUID().equals(serverUUID)) { - plugin.getDataCache().cacheSavedNames(); analysis.runAnalysis(this); } else if (usingAnotherWebServer) { try { @@ -99,128 +84,6 @@ public void refreshAnalysis(UUID serverUUID) { } - @Override - public void cachePlayer(UUID uuid) { - if (uuid == null) { - Log.debug("BukkitInformationManager.cachePlayer: UUID was null"); - return; - } - if (usingAnotherWebServer) { - try { - getWebAPI().getAPI(PostHtmlWebAPI.class).sendInspectHtml(webServerAddress, uuid, getPlayerHtml(uuid)); - } catch (WebFailException e) { - Log.error("Failed to request Inspect from Bungee."); - } catch (WebException e) { - attemptConnection(); - cachePlayer(uuid); - } catch (ParseException e) { - if (!(e.getCause() instanceof IllegalStateException)) { - Log.toLog(this.getClass().getName(), e); - } - } - } else { - ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> { - try { - return new InspectPageResponse(this, uuid); - } catch (ParseException e) { - if (e.getCause() instanceof IllegalStateException) { - return new NotFoundResponse( - "Player just registered, so the data was not yet in the database. " + - "Please wait until they log off or use /plan inspect " - ); - } - return new InternalErrorResponse(e, this.getClass().getName()); - } - }); - if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportPlayer(uuid); - } - } - new Processor(uuid) { - @Override - public void process() { - cacheInspectPluginsTab(object); - } - }.queue(); - } - - public void cacheInspectPluginsTab(UUID uuid) { - cacheInspectPluginsTab(uuid, this.getClass()); - } - - public void cacheInspectPluginsTab(UUID uuid, Class origin) { - if (usingAnotherWebServer && !origin.equals(RequestInspectPluginsTabBukkitWebAPI.class)) { - try { - getWebAPI().getAPI(RequestPluginsTabWebAPI.class).sendRequest(webServerAddress, uuid); - } catch (WebFailException e) { - Log.error("Failed send Player Plugins tab contents to BungeeCord."); - } catch (WebException e) { - attemptConnection(); - cacheInspectPluginsTab(uuid, origin); - } - } else { - cacheInspectPluginsTab(uuid, InspectPagePluginsContent.generateForThisServer(uuid).getContents()); - } - } - - public void cacheInspectPluginsTab(UUID uuid, String[] contents) { - if (usingAnotherWebServer) { - try { - getWebAPI().getAPI(PostInspectPluginsTabWebAPI.class).sendPluginsTab(webServerAddress, uuid, contents); - } catch (WebFailException e) { - Log.error("Failed send Player HTML to BungeeCord."); - } catch (WebException e) { - attemptConnection(); - cacheInspectPluginsTab(uuid, contents); - } - } else { - pluginsTabContents.put(uuid, contents); - Response inspectResponse = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); - if (inspectResponse != null && inspectResponse instanceof InspectPageResponse) { - ((InspectPageResponse) inspectResponse).setInspectPagePluginsTab(contents); - } - } - } - - @Override - public String[] getPluginsTabContent(UUID uuid) { - String[] calculating = HtmlStructure.createInspectPageTabContentCalculating(); - return pluginsTabContents.getOrDefault(uuid, calculating); - } - - @Override - public boolean isCached(UUID uuid) { - if (usingAnotherWebServer) { - try { - return getWebAPI().getAPI(IsCachedWebAPI.class).isInspectCached(webServerAddress, uuid); - } catch (WebFailException e) { - Log.error("Failed check Bungee Player Cache status."); - } catch (WebException e) { - attemptConnection(); - return isCached(uuid); - } - } - return super.isCached(uuid); - } - - @Override - public boolean isAnalysisCached(UUID serverUUID) { - if (Plan.getServerUUID().equals(serverUUID)) { - return analysisData != null; - } - if (usingAnotherWebServer) { - try { - return getWebAPI().getAPI(IsCachedWebAPI.class).isAnalysisCached(webServerAddress, serverUUID); - } catch (WebFailException e) { - Log.error("Failed check Bungee Analysis Cache status."); - } catch (WebException e) { - attemptConnection(); - return isAnalysisCached(serverUUID); - } - } - return ResponseCache.isCached(PageId.SERVER.of(serverUUID)); - } - private WebAPIManager getWebAPI() { return plugin.getWebServer().getWebAPI(); } @@ -248,16 +111,6 @@ public String getAnalysisHtml() { } } - @Override - public String getPlayerHtml(UUID uuid) throws ParseException { - return Theme.replaceColors(new InspectPage(uuid, plugin).toHtml()); - } - - @Override - public DataCache getDataCache() { - return dataCache; - } - public void cacheAnalysisData(AnalysisData analysisData) { this.analysisData = analysisData; refreshDate = MiscUtils.getTime(); @@ -266,7 +119,7 @@ public void cacheAnalysisData(AnalysisData analysisData) { if (usingAnotherWebServer) { try { getWebAPI().getAPI(AnalysisReadyWebAPI.class).sendRequest(webServerAddress, serverUUID); - updateNetworkPageContent(); +// updateNetworkPageContent(); return; } catch (WebFailException ignored) { Log.error("Failed to notify Bungee of Analysis Completion."); @@ -304,10 +157,6 @@ public AnalysisData getAnalysisData() { return analysisData; } - public Optional getAnalysisRefreshDate() { - return refreshDate != null ? Optional.of(refreshDate) : Optional.empty(); - } - @Override public boolean attemptConnection() { boolean webServerIsEnabled = WebServerSystem.isWebServerEnabled(); @@ -358,22 +207,4 @@ public void analysisReady(UUID serverUUID) { analysisNotification.getOrDefault(serverUUID, new HashSet<>()).clear(); } - @Override - public void updateNetworkPageContent() { - if (usingAnotherWebServer) { - try { - getWebAPI().getAPI(PostNetworkPageContentWebAPI.class).sendNetworkContent(webServerAddress, HtmlStructure.createServerContainer(plugin)); - } catch (WebFailException ignored) { - /* Do nothing */ - } catch (WebException ignored) { - attemptConnection(); - updateNetworkPageContent(); - } - } - } - - @Override - public TreeMap> getErrors() throws IOException { - return ErrorLogger.getLoggedErrors(plugin); - } } \ 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 index 0191f0e663..3236e8ef8b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BungeeInformationManager.java @@ -5,37 +5,23 @@ package com.djrapitops.plan.systems.info; import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.PlanPlugin; 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.system.cache.DataCache; import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.info.server.Server; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pages.parsing.NetworkPage; -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.errors.InternalErrorResponse; -import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; -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.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.bukkit.InspectWebAPI; -import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI; -import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI; -import com.djrapitops.plan.utilities.file.export.HtmlExport; -import com.djrapitops.plan.utilities.html.HtmlStructure; -import com.djrapitops.plugin.api.utility.log.ErrorLogger; import com.djrapitops.plugin.api.utility.log.Log; -import java.io.IOException; import java.sql.SQLException; -import java.util.*; +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; @@ -48,15 +34,11 @@ public class BungeeInformationManager extends InformationManager { private final PlanBungee plugin; - private final Map networkPageContent; - private final Map> pluginsTabContent; private final BungeeServerInfo serverInfoManager; private Map bukkitServers; public BungeeInformationManager(PlanBungee plugin) { usingAnotherWebServer = false; - pluginsTabContent = new HashMap<>(); - networkPageContent = new HashMap<>(); this.plugin = plugin; serverInfoManager = plugin.getServerInfoManager(); refreshBukkitServerMap(); @@ -126,90 +108,6 @@ private Server getOnlineServerInfo(UUID serverUUID) { return null; } - /** - * Caches the inspect page for a matching player. - *

    - * Attempt is made to use the server where the player is online. - *

    - * If there is no Bukkit server to handle the request it is not fulfilled. - * - * @param uuid UUID of a player. - */ - @Override - public void cachePlayer(UUID uuid) { - Server inspectServer = null; - try { - inspectServer = getInspectRequestProcessorServer(uuid); - - WebAPIManager apiManager = getWebAPI(); - - apiManager.getAPI(InspectWebAPI.class).sendRequest(inspectServer.getWebAddress(), uuid); - apiManager.getAPI(RequestPluginsTabWebAPI.class).sendRequestsToBukkitServers(plugin, uuid); - } catch (IllegalStateException ignored) { - /* Ignored */ - } catch (WebException e) { - plugin.getServerInfoManager().attemptConnection(inspectServer); - } - } - - /** - * Get Server of an online server that should process an inspect request. - *

    - * If the player is online, an attempt to use the server where the player resides is made. - *

    - * If the player is offline or in the lobby, any server can be used. - * - * @param uuid UUID of the player - * @return Server of the server that should handle the request. - * @throws IllegalStateException If no Bukkit servers are online. - */ - private Server getInspectRequestProcessorServer(UUID uuid) { - if (bukkitServers.isEmpty()) { - try { - refreshBukkitServerMap(); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } - if (bukkitServers.isEmpty()) { - throw new IllegalStateException("No Bukkit Servers."); - } - } - - Collection onlineServers = serverInfoManager.getOnlineBukkitServers(); - if (plugin.getProxy().getPlayer(uuid) != null) { - for (Server server : onlineServers) { - try { - getWebAPI().getAPI(IsOnlineWebAPI.class).sendRequest(server.getWebAddress(), uuid); - return server; - } catch (ConnectionFailException e) { - serverInfoManager.serverHasGoneOffline(server.getUuid()); - } catch (NotFoundException ignored) { - /*continue*/ - } catch (WebException e) { - Log.toLog(this.getClass().getName(), e); - } - } - } - - Optional bukkitServer = serverInfoManager.getOnlineBukkitServers().stream().findAny(); - if (bukkitServer.isPresent()) { - return bukkitServer.get(); - } - throw new IllegalStateException("No Bukkit servers online"); - } - - /** - * PlanBungee has no DataCache so this method should not be used. - *

    - * DataCache is meant for storing player data. - * - * @return null - */ - @Override - public DataCache getDataCache() { - return null; - } - /** * Attempts a connection to every Bukkit server in the database. * @@ -228,37 +126,6 @@ public boolean attemptConnection() { return true; } - /** - * Condition if analysis page for an UUID is cached. - *

    - * If serverUUID is that of Bungee, network page state is returned. - * - * @param serverUUID UUID of the server - * @return true/false - */ - @Override - public boolean isAnalysisCached(UUID serverUUID) { - return ResponseCache.isCached(PageId.SERVER.of(serverUUID)); - } - - /** - * Returns the Html players inspect page. - *

    - * If no Bukkit servers are online a 404 is returned instead. - * - * @param uuid UUID of the player - * @return Html string (Full page) - */ - @Override - public String getPlayerHtml(UUID uuid) { - Response response = ResponseCache.copyResponse(PageId.PLAYER.of(uuid), - () -> new NotFoundResponse("No Bukkit Servers were online to process this request")); - if (response instanceof InspectPageResponse) { - ((InspectPageResponse) response).setInspectPagePluginsTab(getPluginsTabContent(uuid)); - } - return response.getContent(); - } - /** * Get the Network page html. * @@ -273,54 +140,6 @@ public String getAnalysisHtml() { } } - /** - * Used to parse the Plugins tab html String out of all sent to Bungee. - * - * @param uuid UUID of the player - * @return Html string. - */ - @Override - public String[] getPluginsTabContent(UUID uuid) { - Map pluginsTab = pluginsTabContent.get(uuid); - if (pluginsTab == null) { - return HtmlStructure.createInspectPageTabContentCalculating(); - } - - List order = new ArrayList<>(pluginsTab.values()); - // Sort serverNames alphabetically - order.sort(new Comparator() { - @Override - public int compare(String[] o1, String[] o2) { - return o1[0].compareTo(o2[0]); - } - }); - - StringBuilder nav = new StringBuilder(); - StringBuilder tabs = new StringBuilder(); - for (String[] tab : order) { - nav.append(tab[0]); - tabs.append(tab[1]); - } - return new String[]{nav.toString(), tabs.toString()}; - } - - /** - * Places plugins tab content for a single player to the pluginsTabContent map. - * - * @param serverUUID UUID of the server - * @param uuid UUID of the player - * @param html Plugins tab html for the player on the server - */ - public void cachePluginsTabContent(UUID serverUUID, UUID uuid, String[] html) { - Map perServerPluginsTab = pluginsTabContent.getOrDefault(uuid, new HashMap<>()); - perServerPluginsTab.put(serverUUID, html); - pluginsTabContent.put(uuid, perServerPluginsTab); - Response inspectResponse = ResponseCache.loadResponse(PageId.PLAYER.of(uuid)); - if (inspectResponse != null && inspectResponse instanceof InspectPageResponse) { - ((InspectPageResponse) inspectResponse).setInspectPagePluginsTab(getPluginsTabContent(uuid)); - } - } - /** * Shortcut for getting WebAPIManager * @@ -340,19 +159,6 @@ public String getWebServerAddress() { return plugin.getWebServer().getAccessAddress(); } - public void cacheNetworkPageContent(UUID serverUUID, String html) { - networkPageContent.put(serverUUID, html); - updateNetworkPageContent(); - } - - public void removeNetworkPageContent(UUID serverUUID) { - networkPageContent.put(serverUUID, HtmlStructure.parseOfflineServerContainer(networkPageContent.get(serverUUID))); - } - - public Map getNetworkPageContent() { - return networkPageContent; - } - /** * Send notification of analysis being ready to all online bukkit servers via WebAPI. * @@ -370,23 +176,10 @@ public void analysisReady(UUID serverUUID) { } } - @Override - public void updateNetworkPageContent() { - UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); - ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(this)); - if (Settings.ANALYSIS_EXPORT.isTrue()) { - HtmlExport.exportServer(serverUUID); - } - } - public void sendConfigSettings() { Collection online = serverInfoManager.getOnlineBukkitServers(); online.stream().map(Server::getUuid) .forEach(serverInfoManager::sendConfigSettings); } - @Override - public TreeMap> getErrors() throws IOException { - return ErrorLogger.getLoggedErrors(plugin); - } } 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 index 0201cb2a16..272c16825b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -4,14 +4,8 @@ */ package com.djrapitops.plan.systems.info; -import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.cache.SessionCache; -import com.djrapitops.plan.system.webserver.response.cache.PageId; -import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; import com.djrapitops.plugin.command.ISender; -import java.io.IOException; import java.util.*; /** @@ -33,33 +27,12 @@ public InformationManager() { public abstract boolean attemptConnection(); - public abstract void cachePlayer(UUID uuid); - public String getLinkTo(String target) { return getWebServerAddress() + target; } public abstract void refreshAnalysis(UUID serverUUID); - public abstract DataCache getDataCache(); - - public SessionCache getSessionCache() { - return getDataCache(); - } - - public boolean isCached(UUID uuid) { - return ResponseCache.isCached(PageId.PLAYER.of(uuid)); - } - - public abstract String getPlayerHtml(UUID uuid) throws ParseException; - - /** - * Used for /server on Bukkit and /network on Bungee - * - * @return Is page cached. - */ - public abstract boolean isAnalysisCached(UUID serverUUID); - /** * Used for /server on Bukkit and /network on Bungee * @@ -73,8 +46,6 @@ public void addAnalysisNotification(ISender sender, UUID serverUUID) { analysisNotification.put(serverUUID, notify); } - public abstract String[] getPluginsTabContent(UUID uuid); - public boolean isUsingAnotherWebServer() { return usingAnotherWebServer; } @@ -87,7 +58,4 @@ public boolean isAuthRequired() { public abstract void analysisReady(UUID serverUUID); - public abstract void updateNetworkPageContent(); - - public abstract TreeMap> getErrors() throws IOException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 081064dee8..053583d7b9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -130,11 +130,10 @@ public boolean analyzeData(InformationManager infoManager, Database db) { Benchmark.stop("Analysis", "Create Empty dataset"); Benchmark.start("Fetch Phase"); ServerProfile profile = db.fetch().getServerProfile(Plan.getServerUUID()); - DataCache dataCache = plugin.getDataCache(); profile.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions())); serverProfile = profile; - updatePlayerNameCache(profile, dataCache); + updatePlayerNameCache(profile); long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase"); setBannedByPlugins(profile); @@ -166,7 +165,8 @@ public boolean analyzeData(InformationManager infoManager, Database db) { return true; } - private void updatePlayerNameCache(ServerProfile profile, DataCache dataCache) { + private void updatePlayerNameCache(ServerProfile profile) { + DataCache dataCache = DataCache.getInstance(); for (PlayerProfile player : profile.getPlayers()) { dataCache.updateNames(player.getUuid(), player.getName(), null); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java index b669c5b33c..449ac36e7b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java @@ -1,14 +1,11 @@ package com.djrapitops.plan.utilities.html; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.system.settings.Settings; import org.apache.commons.lang3.text.StrSubstitutor; import java.io.Serializable; import java.util.Map; -import java.util.UUID; /** * @author Rsl1122 @@ -51,18 +48,6 @@ public static String getIP() { return ip; } - public static String getProtocol() { - return PlanPlugin.getInstance().getWebServer().getProtocol(); - } - - public static String getRelativeInspectUrl(String playerName) { - return "../player/" + playerName.replace(" ", "%20").replace(".", "%2E"); - } - - public static String getRelativeInspectUrl(UUID uuid) { - return PlanAPI.getInstance().getPlayerInspectPageLink(Plan.getInstance().getDataCache().getName(uuid)); - } - /** * Attempts to remove XSS components. * @@ -95,17 +80,4 @@ public static String swapColorsToSpan(String string) { return string.replace("§r", "").replace("§l", "").replace("§m", "").replace("§n", "").replace("§o", "").replace("§k", ""); } - - public static String separateWithQuotes(String... strings) { - StringBuilder build = new StringBuilder(); - for (int i = 0; i < strings.length; i++) { - build.append("\""); - build.append(strings[i]); - build.append("\""); - if (i < strings.length - 1) { - build.append(", "); - } - } - return build.toString(); - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index 073e423e8a..2ce5ad852a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -4,12 +4,12 @@ */ package com.djrapitops.plan.utilities.html.structure; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; @@ -70,7 +70,7 @@ public static String[] createStructure(Map>> ses int playerKillCount = session.getPlayerKills().size(); - String name = Plan.getInstance().getDataCache().getName(uuid); + String name = DataCache.getInstance().getName(uuid); String link = PlanAPI.getInstance().getPlayerInspectPageLink(name); String dotSeparated2 = appendWorldPerc diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java index 07a108d2c6..0ce1758480 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java @@ -1,10 +1,10 @@ package com.djrapitops.plan.utilities.html.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.comparators.KillDataComparator; import com.djrapitops.plan.utilities.html.Html; @@ -38,6 +38,7 @@ public static String createTable(List playerKills) { Collections.reverse(playerKills); int i = 0; + DataCache dataCache = DataCache.getInstance(); for (PlayerKill kill : playerKills) { if (i >= 20) { break; @@ -45,7 +46,7 @@ public static String createTable(List playerKills) { long date = kill.getTime(); - String name = Plan.getInstance().getDataCache().getName(kill.getVictim()); + String name = dataCache.getName(kill.getVictim()); html.append(Html.TABLELINE_3_CUSTOMKEY_1.parse( String.valueOf(date), FormatUtils.formatTimeStamp(date), Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index 0895b23557..5ce1ef7ce6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.utilities.html.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; @@ -54,7 +53,7 @@ public static String[] createTable(Map> sessionsByUser, List Set recentLoginsNames = new HashSet<>(); - DataCache dataCache = Plan.getInstance().getDataCache(); + Map uuidBySessionStart = new HashMap<>(); for (Map.Entry entry : SessionCache.getActiveSessions().entrySet()) { @@ -65,6 +64,8 @@ public static String[] createTable(Map> sessionsByUser, List if (maxSessions <= 0) { maxSessions = 50; } + + DataCache dataCache = DataCache.getInstance(); for (Session session : allSessions) { if (i >= maxSessions) { break; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java index 6c44440ee6..14f248ea58 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/uuid/UUIDUtility.java @@ -5,9 +5,9 @@ */ package com.djrapitops.plan.utilities.uuid; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.FatalDBException; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.UUIDFetcher; @@ -51,7 +51,7 @@ public static UUID getUUIDOf(String playerName) { private static UUID getUUIDOf(String playerName, Database db) { UUID uuid = null; if (Check.isBukkitAvailable()) { - UUID uuidOf = Plan.getInstance().getDataCache().getUUIDof(playerName); + UUID uuidOf = DataCache.getInstance().getUUIDof(playerName); if (uuidOf != null) { return uuidOf; } 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 bd00d1fe42..d24a84184b 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 @@ -1,11 +1,16 @@ package main.java.com.djrapitops.plan.api; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.ParseException; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; 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.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.utilities.uuid.UUIDUtility; import com.djrapitops.plugin.api.utility.log.Log; @@ -117,7 +122,7 @@ public boolean isPlayersDataInspectCached(UUID uuid) { */ @Deprecated public boolean isPlayerHtmlCached(UUID uuid) { - return plugin.getInfoManager().isCached(uuid); + return ResponseCache.isCached(PageId.PLAYER.of(uuid)); } /** @@ -142,7 +147,11 @@ public void cacheUserDataToInspectCache(UUID uuid) { */ @Deprecated public void cachePlayerHtml(UUID uuid) { - plugin.getInfoManager().cachePlayer(uuid); + try { + InfoSystem.getInstance().generateAndCachePlayerPage(uuid); + } catch (WebException e) { + Log.toLog(this.getClass().getName(), e); + } } /** @@ -154,8 +163,8 @@ public void cachePlayerHtml(UUID uuid) { * @return player.html with all placeholders replaced. */ @Deprecated - public String getPlayerHtmlAsString(UUID uuid) throws ParseException { - return plugin.getInfoManager().getPlayerHtml(uuid); + public String getPlayerHtmlAsString(UUID uuid) { + return ResponseCache.loadResponse(PageId.PLAYER.of(uuid), DefaultResponses.NOT_FOUND::get).getContent(); } /** @@ -165,7 +174,7 @@ public String getPlayerHtmlAsString(UUID uuid) throws ParseException { */ @Deprecated public boolean isAnalysisCached() { - return plugin.getInfoManager().isAnalysisCached(Plan.getServerUUID()); + return ResponseCache.isCached(PageId.SERVER.of(ServerInfo.getServerUUID())); } /** diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java index 4224349457..3ac3ca6985 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java @@ -81,7 +81,7 @@ public void setUp() throws Exception { public void markFirstSession(UUID uuid) { } }; - when(plan.getDataCache()).thenReturn(dataCache); +// when(plan.getDataCache()).thenReturn(dataCache); db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20)); diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index 980a0bf825..28dd993cb6 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -2,7 +2,6 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.info.server.BukkitServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerProperties; @@ -125,13 +124,13 @@ public void save() { when(planMock.getVariable()).thenReturn(serverProperties); BukkitServerInfo bukkitServerInfo = PowerMockito.mock(BukkitServerInfo.class); - DataCache dataCache = new DataCache(planMock) { - @Override - public String getName(UUID uuid) { - return ""; - } - }; - when(planMock.getDataCache()).thenReturn(dataCache); +// DataCache dataCache = new DataCache(planMock) { +// @Override +// public String getName(UUID uuid) { +// return ""; +// } +// }; +// when(planMock.getDataCache()).thenReturn(dataCache); when(ServerInfo.getServerUUID()).thenReturn(serverUUID); when(planMock.getServerUuid()).thenReturn(serverUUID); From 4d76671bc8026804a7b21308e9163ed9686b3c7c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 11:48:23 +0200 Subject: [PATCH 047/166] GenerateAnalysisPageRequest now runs analysis properly. In addition: - Laid groundwork for running analysis of offline servers - Changed InfoRequest request address to /info/ from /api/ to reduce confusion. --- .../main/java/com/djrapitops/plan/Plan.java | 3 +- .../connection/InternalErrorException.java | 4 + .../system/info/connection/ConnectionOut.java | 2 +- .../request/GenerateAnalysisPageRequest.java | 28 +++- .../plan/system/info/request/InfoRequest.java | 2 +- .../system/webserver/ResponseHandler.java | 8 +- .../webserver/pages/parsing/AnalysisPage.java | 15 +- .../response/pages/AnalysisPageResponse.java | 9 ++ .../info/BukkitInformationManager.java | 5 +- .../plan/utilities/analysis/Analysis.java | 130 +++++------------- 10 files changed, 89 insertions(+), 117 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 56aa8b6d92..f49a10e6ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -89,8 +89,9 @@ public static Plan getInstance() { return (Plan) StaticHolder.getInstance(Plan.class); } + @Deprecated public static UUID getServerUUID() { - return getInstance().getServerUuid(); + return ServerInfo.getServerUUID(); } public UUID getServerUuid() { diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/InternalErrorException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/InternalErrorException.java index a0bbccf4a2..ddac58c62b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/InternalErrorException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/connection/InternalErrorException.java @@ -13,4 +13,8 @@ public class InternalErrorException extends WebFailException { public InternalErrorException() { super("Internal Error occurred on receiving server"); } + + public InternalErrorException(String message, Throwable cause) { + super(message, cause); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index 108248de70..a51ff1eafa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -67,7 +67,7 @@ public ConnectionOut(Server toServer, UUID serverUUID, InfoRequest infoRequest) public void sendRequest() throws WebException { String address = toServer.getWebAddress(); try { - URL url = new URL(address + "/api/" + this.getClass().getSimpleName().toLowerCase()); + URL url = new URL(address + "/info/" + this.getClass().getSimpleName().toLowerCase()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); if (address.startsWith("https")) { HttpsURLConnection httpsConn = (HttpsURLConnection) connection; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index 5273752eaf..c9cc337c64 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -5,12 +5,20 @@ package com.djrapitops.plan.system.info.request; import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.InternalErrorException; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.data.AnalysisData; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.pages.parsing.AnalysisPage; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plan.utilities.analysis.Analysis; +import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; import java.util.Map; @@ -51,16 +59,26 @@ public Response handleRequest(Map variables) throws WebException if (!ServerInfo.getServerUUID().equals(serverUUID)) { throw new BadRequestException("Requested Analysis page from wrong server."); } - String html = getHtml(); - InfoSystem.getInstance().sendRequest(new CacheAnalysisPageRequest(serverUUID, html)); + InfoSystem infoSystem = InfoSystem.getInstance(); + infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, AnalysisPageResponse.getRefreshingHtml())); + infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, analyseAndGetHtml())); return DefaultResponses.SUCCESS.get(); } - public String getHtml() { - // TODO Perform Analysis & get HTML - return null; + public String analyseAndGetHtml() throws InternalErrorException { + try { + UUID serverUUID = ServerInfo.getServerUUID(); + Database db = Database.getActive(); + DataCache dataCache = DataCache.getInstance(); + + AnalysisData analysisData = Analysis.runAnalysisFor(serverUUID, db, dataCache); + return new AnalysisPage(analysisData).toHtml(); + } catch (Exception e) { + Log.toLog(Analysis.class, e); + throw new InternalErrorException("Analysis failed due to exception", e); + } } public static GenerateAnalysisPageRequest createHandler() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java index 0e032d4418..08e24217ef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java @@ -10,7 +10,7 @@ import java.util.Map; /** - * //TODO Class Javadoc Comment + * Represents a request that Plan servers can send each other. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 9b77498009..5a33ea9bf6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -50,7 +50,7 @@ public void registerDefaultPages() { } public void registerWebAPIPages() { - registerPage("api", new InfoRequestPageHandler()); + registerPage("info", new InfoRequestPageHandler()); // TODO Remove redundant comment after implementing replacements // private void registerWebAPIs() { @@ -93,6 +93,12 @@ public Response getResponse(Request request) { return new BadRequestResponse(e.getMessage()); } catch (UnauthorizedServerException e) { return new UnauthorizedServerResponse(e.getMessage()); + } catch (InternalErrorException e) { + if (e.getCause() != null) { + return new InternalErrorResponse(request.getTarget(), e.getCause()); + } else { + return new InternalErrorResponse(request.getTarget(), e); + } } catch (Exception e) { Log.toLog(this.getClass().getName(), e); return new InternalErrorResponse(request.getTarget(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java index 567cf2d7e8..4c344250e8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java @@ -4,14 +4,10 @@ */ package com.djrapitops.plan.system.webserver.pages.parsing; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.HtmlUtils; -import com.djrapitops.plugin.api.Check; import java.io.IOException; @@ -23,11 +19,9 @@ public class AnalysisPage extends Page { private final AnalysisData data; - private final PlanPlugin plugin; - public AnalysisPage(AnalysisData analysisData, PlanPlugin plugin) { + public AnalysisPage(AnalysisData analysisData) { this.data = analysisData; - this.plugin = plugin; } @Override @@ -40,11 +34,4 @@ public String toHtml() throws ParseException { throw new ParseException(e); } } - - private int getPlayersOnline() { - if (Check.isBukkitAvailable()) { - return ((Plan) plugin).getServer().getOnlinePlayers().size(); - } - return ((PlanBungee) plugin).getProxy().getOnlineCount(); - } } \ No newline at end of file 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 c988598b81..696b0ac156 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 @@ -50,4 +50,13 @@ public AnalysisPageResponse(String html) { super.setHeader("HTTP/1.1 200 OK"); super.setContent(html); } + + public static String getRefreshingHtml() { + ErrorResponse refreshPage = new ErrorResponse(); + refreshPage.setTitle("Analysis is being refreshed.."); + refreshPage.setParagraph(" Analysis is being run, refresh the page after a few seconds.. (F5)"); + refreshPage.replacePlaceholders(); + return refreshPage.getContent(); + } + } 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 index a608480924..73c59f7f5a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -70,7 +70,7 @@ public void updateConnection() { @Override public void refreshAnalysis(UUID serverUUID) { if (Plan.getServerUUID().equals(serverUUID)) { - analysis.runAnalysis(this); + analysis.runAnalysis(); } else if (usingAnotherWebServer) { try { getWebAPI().getAPI(AnalyzeWebAPI.class).sendRequest(webServerAddress, serverUUID); @@ -97,7 +97,7 @@ private WebAPIManager getWebAPI() { @Override public String getAnalysisHtml() { if (analysisData == null) { - analysis.runAnalysis(this); + 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)"); @@ -134,6 +134,7 @@ private void cacheAnalysisHtml() { cacheAnalysisHtml(getAnalysisHtml()); } + @Deprecated public void cacheAnalysisHtml(String html) { if (usingAnotherWebServer) { try { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 053583d7b9..90ea28ed18 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -1,29 +1,26 @@ package com.djrapitops.plan.utilities.analysis; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.plugin.BanData; +import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.tasks.BukkitTaskSystem; import com.djrapitops.plan.system.tasks.TaskSystem; -import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; -import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; -import com.djrapitops.plan.systems.info.BukkitInformationManager; -import com.djrapitops.plan.systems.info.InformationManager; +import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.task.AbsRunnable; -import com.djrapitops.plugin.task.RunnableFactory; import java.util.*; import java.util.stream.Collectors; @@ -33,22 +30,27 @@ */ public class Analysis { + private static Long refreshDate; + private final UUID serverUUID; + private final Database database; + private static ServerProfile serverProfile; - private final Plan plugin; - private int taskId = -1; + private final DataCache dataCache; + private boolean analysingThisServer; + + private Analysis(UUID serverUUID, Database database, DataCache dataCache) { + this.serverUUID = serverUUID; + analysingThisServer = ServerInfo.getServerUUID().equals(serverUUID); + this.database = database; + this.dataCache = dataCache; + } public static Optional getRefreshDate() { - // TODO - return Optional.empty(); + return Optional.ofNullable(refreshDate); } - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public Analysis(Plan plugin) { - this.plugin = plugin; + public static AnalysisData runAnalysisFor(UUID serverUUID, Database database, DataCache dataCache) throws Exception { + return new Analysis(serverUUID, database, dataCache).runAnalysis(); } /** @@ -60,68 +62,19 @@ public static ServerProfile getServerProfile() { return serverProfile; } - /** - * Analyzes the data of all offline players on the server. - * - * @param infoManager InformationManager of the plugin. - */ - public void runAnalysis(InformationManager infoManager) { - if (isAnalysisBeingRun()) { - return; - } - + private AnalysisData runAnalysis() throws Exception { ((BukkitTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis(); Benchmark.start("Analysis"); log(Locale.get(Msg.ANALYSIS_START).toString()); - // Async task for Analysis - RunnableFactory.createNew(new AbsRunnable("AnalysisTask") { - @Override - public void run() { - try { - 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(); - ((BukkitInformationManager) plugin.getInfoManager()).cacheAnalysisHtml(analysisRefreshPage.getContent()); - taskId = this.getTaskId(); - analyze(infoManager, plugin.getDB()); - } catch (Exception e) { - Log.toLog(this.getClass().getName() + ":" + this.getTaskName(), e); - } finally { - taskId = -1; - this.cancel(); - } - - } - }).runTaskAsynchronously(); + return analyze(); } - /** - * Caches analyzed data of db to the provided cache analysisCache. - * - * @param infoManager InformationManager of the plugin. - * method. - * @param db Database which data will be analyzed. - * @return Whether or not analysis was successful. - */ - public boolean analyze(InformationManager infoManager, Database db) { + private AnalysisData analyze() throws Exception { log(Locale.get(Msg.ANALYSIS_FETCH).toString()); Benchmark.start("Fetch Phase"); Log.logDebug("Database", "Analysis Fetch"); Log.logDebug("Analysis", "Analysis Fetch Phase"); - - - return analyzeData(infoManager, db); - } - - /** - * Analyze data in the db about this server. - * - * @param infoManager InformationManager of the plugin. - * @return Success? - */ - public boolean analyzeData(InformationManager infoManager, Database db) { try { Benchmark.start("Create Empty dataset"); @@ -129,8 +82,10 @@ public boolean analyzeData(InformationManager infoManager, Database db) { Benchmark.stop("Analysis", "Create Empty dataset"); Benchmark.start("Fetch Phase"); - ServerProfile profile = db.fetch().getServerProfile(Plan.getServerUUID()); - profile.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions())); + ServerProfile profile = database.fetch().getServerProfile(serverUUID); + if (analysingThisServer) { + profile.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions())); + } serverProfile = profile; updatePlayerNameCache(profile); @@ -150,31 +105,27 @@ public boolean analyzeData(InformationManager infoManager, Database db) { log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString()); Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)"); analysisData.parsePluginsSection(analyzeAdditionalPluginData(profile.getUuids())); - ((BukkitInformationManager) infoManager).cacheAnalysisData(analysisData); - } catch (Exception e) { - Log.toLog(this.getClass().getName(), e); - ((BukkitInformationManager) plugin.getInfoManager()).cacheAnalysisHtml(new InternalErrorResponse(e, "Analysis").getContent()); - Log.logDebug("Analysis", "Error: " + e); - return false; + return analysisData; } finally { + refreshDate = MiscUtils.getTime(); long time = Benchmark.stop("Analysis", "Analysis"); Log.logDebug("Analysis"); Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(time, "")); serverProfile = null; } - return true; } private void updatePlayerNameCache(ServerProfile profile) { - DataCache dataCache = DataCache.getInstance(); for (PlayerProfile player : profile.getPlayers()) { dataCache.updateNames(player.getUuid(), player.getName(), null); } } private void setBannedByPlugins(ServerProfile profile) { - UUID serverUUID = Plan.getServerUUID(); - List banPlugins = plugin.getHookHandler().getAdditionalDataSources().stream() + if (!analysingThisServer) { + return; + } + List banPlugins = HookHandler.getInstance().getAdditionalDataSources().stream() .filter(p -> p instanceof BanData) .map(p -> (BanData) p) .collect(Collectors.toList()); @@ -200,13 +151,17 @@ private void log(String msg) { } private Map analyzeAdditionalPluginData(Set uuids) { + if (!analysingThisServer) { + return new HashMap<>(); + } Map containers = new HashMap<>(); Benchmark.start("Analysis", "3rd party Analysis"); - List sources = plugin.getHookHandler().getAdditionalDataSources(); + List sources = HookHandler.getInstance().getAdditionalDataSources(); Log.logDebug("Analysis", "Additional Sources: " + sources.size()); sources.parallelStream().forEach(source -> { + PlanPlugin plugin = PlanPlugin.getInstance(); StaticHolder.saveInstance(this.getClass(), plugin.getClass()); try { Benchmark.start("Analysis", "Source " + source.getSourcePlugin()); @@ -226,13 +181,4 @@ private Map analyzeAdditionalPluginData(Set Benchmark.stop("Analysis", "3rd party Analysis"); return containers; } - - /** - * Condition whether or not analysis is being run. - * - * @return true / false (state) - */ - public boolean isAnalysisBeingRun() { - return taskId != -1; - } } From 097958c4167f19a4fa0038c7d222f67f96e48026 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 12:35:00 +0200 Subject: [PATCH 048/166] Cleaned up some session related stuff while attempting to find a bug --- .../java/com/djrapitops/plan/ShutdownHook.java | 5 ++--- .../djrapitops/plan/data/PlayerProfile.java | 8 ++------ .../plan/data/container/Session.java | 12 ------------ .../plan/data/element/ActivityIndex.java | 18 ++++++++---------- .../listeners/bukkit/PlayerOnlineListener.java | 2 +- .../response/pages/PlayersPageResponse.java | 5 ++--- 6 files changed, 15 insertions(+), 35 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index 59cfc4b8c0..07954423e6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -85,10 +85,9 @@ private void saveActiveSessions(Database db, Map activeSessions, UUID uuid = entry.getKey(); Session session = entry.getValue(); long sessionEnd = session.getSessionEnd(); - if (sessionEnd != -1) { - continue; + if (sessionEnd == -1) { + session.endSession(now); } - session.endSession(now); try { Log.debug("Shutdown: Saving a session: " + session.getSessionStart()); db.save().session(uuid, session); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index e1bffd4641..e6887b00a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -80,15 +80,11 @@ public PlayerProfile(UUID uuid, String name, long registered) { } public static long getPlaytime(Stream s) { - return s.map(Session::getLength) - .mapToLong(i -> i) - .sum(); + return s.mapToLong(Session::getLength).sum(); } public static long getLongestSession(Stream s) { - OptionalLong longestSession = s.map(Session::getLength) - .mapToLong(i -> i) - .max(); + OptionalLong longestSession = s.mapToLong(Session::getLength).max(); if (longestSession.isPresent()) { return longestSession.getAsLong(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java index 8b265b7058..fb5a21349d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java @@ -67,18 +67,6 @@ public Session(int id, long sessionStart, long sessionEnd, int mobKills, int dea this.deaths = deaths; } - /** - * Starts a new Session. - * - * @param time Time the session started. - * @param world World the session started in. - * @param gm GameMode the session started in. - * @return a new Session object. - */ - public static Session start(long time, String world, String gm) { - return new Session(time, world, gm); - } - /** * Ends the session with given end point. *

    diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java index bbd773da82..833ee8c2d1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java @@ -17,8 +17,12 @@ public ActivityIndex(PlayerProfile player, long date) { value = calculate(player, date); } - private static long loadSetting(long value) { - return value < 0 ? 1 : value; + private long loadSetting(long value) { + return value <= 0 ? 1 : value; + } + + private int loadSetting(int value) { + return value <= 0 ? 1 : value; } public static String[] getGroups() { @@ -31,14 +35,8 @@ private double calculate(PlayerProfile player, long date) { long twoWeeksAgo = date - 2L * week; long threeWeeksAgo = date - 3L * week; - long activePlayThreshold = Settings.ACTIVE_PLAY_THRESHOLD.getNumber() * TimeAmount.MINUTE.ms(); - if (activePlayThreshold <= 0) { - activePlayThreshold = 1; - } - int activeLoginThreshold = Settings.ACTIVE_LOGIN_THRESHOLD.getNumber(); - if (activeLoginThreshold <= 0) { - activeLoginThreshold = 1; - } + long activePlayThreshold = loadSetting(Settings.ACTIVE_PLAY_THRESHOLD.getNumber() * TimeAmount.MINUTE.ms()); + int activeLoginThreshold = loadSetting(Settings.ACTIVE_LOGIN_THRESHOLD.getNumber()); List sessionsWeek = player.getSessions(weekAgo, date).collect(Collectors.toList()); List sessionsWeek2 = player.getSessions(twoWeeksAgo, weekAgo).collect(Collectors.toList()); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index 712bdb8d21..ea7b134c4d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -94,7 +94,7 @@ public void onPlayerJoin(PlayerJoinEvent event) { int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline(); - SessionCache.getInstance().cacheSession(uuid, Session.start(time, world, gm)); + SessionCache.getInstance().cacheSession(uuid, new Session(time, world, gm)); Processor.queueMany( new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java index 3e9750a0ac..e0e420dc53 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java @@ -35,7 +35,6 @@ public PlayersPageResponse() { super.setHeader("HTTP/1.1 200 OK"); try { PlanSystem system = PlanSystem.getInstance(); - PlanPlugin plugin = PlanPlugin.getInstance(); Database db = system.getDatabaseSystem().getActiveDatabase(); List names = new ArrayList<>(db.fetch().getPlayerNames().values()); @@ -101,8 +100,8 @@ private String buildPlayersTable(Database db) { List sessions = sessionsByUser.getOrDefault(uuid, new ArrayList<>()); int sessionCount = sessions.size(); - long playtime = sessionCount != 0 ? sessions.stream().map(Session::getLength) - .mapToLong(p -> p) + long playtime = sessionCount != 0 ? sessions.stream() + .mapToLong(Session::getLength) .sum() : 0L; long registered = userInfo.getRegistered(); long lastSeen = lastSeenForAllPlayers.getOrDefault(uuid, 0L); From 118cbe7ee7642afe8e8cc78a6573136a5a1583ab Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 13:00:25 +0200 Subject: [PATCH 049/166] Fixes BatchUpdateException: Subquery returns more than 1 row (#501): - Added LIMIT 1 to all subqueries used in tables. --- .../databases/sql/tables/ServerTable.java | 4 ++-- .../databases/sql/tables/UsersTable.java | 2 +- .../databases/sql/tables/WorldTable.java | 20 ++++++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java index 47230fe60a..9f2f27c9aa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java @@ -47,8 +47,8 @@ public class ServerTable extends Table { public ServerTable(SQLDB db) { super("plan_servers", db); - statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + ")"; - statementSelectServerNameID = "(" + Select.from(tableName, tableName + "." + columnServerName).where(columnServerID + "=?").toString() + ")"; + statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + " LIMIT 1)"; + statementSelectServerNameID = "(" + Select.from(tableName, tableName + "." + columnServerName).where(columnServerID + "=?").toString() + " LIMIT 1)"; insertStatement = Insert.values(tableName, columnServerUUID, columnServerName, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java index 80a1056d30..476e5e268b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java @@ -29,7 +29,7 @@ public class UsersTable extends UserIDTable { public UsersTable(SQLDB db) { super("plan_users", db); - statementSelectID = "(" + Select.from(tableName, tableName + "." + columnID).where(columnUUID + "=?").toString() + ")"; + statementSelectID = "(" + Select.from(tableName, tableName + "." + columnID).where(columnUUID + "=?").toString() + " LIMIT 1)"; insertStatement = Insert.values(tableName, columnUUID, columnRegistered, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java index 6ead4143c6..c913d0c8cc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java @@ -31,7 +31,7 @@ public class WorldTable extends Table { public WorldTable(SQLDB db) { super("plan_worlds", db); - statementSelectID = "(SELECT " + columnWorldId + " FROM " + tableName + " WHERE (" + columnWorldName + "=?))"; + statementSelectID = "(SELECT " + columnWorldId + " FROM " + tableName + " WHERE (" + columnWorldName + "=?) LIMIT 1)"; } @Override @@ -146,4 +146,22 @@ public Set processResults(ResultSet set) throws SQLException { } }); } + + public Map getWorldIds() throws SQLException { + String sql = "SELECT DISTINCT " + + columnWorldName + ", " + + columnWorldId + " FROM " + + tableName; + + return query(new QueryAllStatement>(sql, 200) { + @Override + public Map processResults(ResultSet set) throws SQLException { + Map worldIds = new HashMap<>(); + while (set.next()) { + + } + return worldIds; + } + }); + } } From d5fcb1edf0e6c6604ad73e5c901f1a358e9aece3 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 13:10:05 +0200 Subject: [PATCH 050/166] Fixed compile errors in DatabaseTest (Renamed to SQLiteTest) --- .../plan/system/database/MySQLTest.java | 29 ++++++ .../{DatabaseTest.java => SQLiteTest.java} | 96 ++++++++----------- .../main/java/test/utilities/DBTestSuite.java | 5 +- 3 files changed, 71 insertions(+), 59 deletions(-) create mode 100644 Plan/test/main/java/com/djrapitops/plan/system/database/MySQLTest.java rename Plan/test/main/java/com/djrapitops/plan/system/database/{DatabaseTest.java => SQLiteTest.java} (92%) diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/MySQLTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/MySQLTest.java new file mode 100644 index 0000000000..3fc3a38569 --- /dev/null +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/MySQLTest.java @@ -0,0 +1,29 @@ +/* + * 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.database; + +import com.djrapitops.plan.system.database.databases.sql.MySQLDB; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Tests MySQLDB. + * + * @author Rsl1122 + */ +public class MySQLTest { + + @Test + public void testMySQLGetConfigName() { + assertEquals("mysql", new MySQLDB().getConfigName()); + } + + @Test + public void testMySQLGetName() { + assertEquals("MySQL", new MySQLDB().getName()); + } + +} \ No newline at end of file diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java similarity index 92% rename from Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java rename to Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java index 3ac3ca6985..7210dc8963 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/DatabaseTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java @@ -13,9 +13,6 @@ import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.sql.MySQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; @@ -53,20 +50,19 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({JavaPlugin.class}) -public class DatabaseTest { +public class SQLiteTest { private final UUID uuid = MockUtils.getPlayerUUID(); private final List worlds = Arrays.asList("TestWorld", "TestWorld2"); private final UUID uuid2 = MockUtils.getPlayer2UUID(); private Plan plan; - private Database db; - private Database backup; + private SQLDB db; + private SQLDB backup; private int rows; @Rule public Timeout globalTimeout = Timeout.seconds(7); // 5 seconds max per method tested - @Before public void setUp() throws Exception { TestInit t = TestInit.init(); @@ -76,12 +72,6 @@ public void setUp() throws Exception { db.init(); when(plan.getDB()).thenReturn(db); - DataCache dataCache = new DataCache(plan) { - @Override - public void markFirstSession(UUID uuid) { - } - }; -// when(plan.getDataCache()).thenReturn(dataCache); db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20)); @@ -118,9 +108,9 @@ public void testInit() throws DBInitException { public void testNoExceptionWhenCommitEmpty() throws Exception { db.init(); - db.commit(((SQLDB) db).getConnection()); - db.commit(((SQLDB) db).getConnection()); - db.commit(((SQLDB) db).getConnection()); + db.commit(db.getConnection()); + db.commit(db.getConnection()); + db.commit(db.getConnection()); } @Test @@ -133,16 +123,6 @@ public void testSQLiteGetName() { assertEquals("SQLite", db.getName()); } - @Test - public void testMySQLGetConfigName() { - assertEquals("mysql", new MySQLDB().getConfigName()); - } - - @Test - public void testMySQLGetName() { - assertEquals("MySQL", new MySQLDB().getName()); - } - @Test(timeout = 3000) public void testSaveCommandUse() throws SQLException, DBInitException { CommandUseTable commandUseTable = db.getCommandUseTable(); @@ -173,7 +153,7 @@ public void testSaveCommandUse() throws SQLException, DBInitException { commitTest(); - Map commandUse = db.getCommandUse(); + Map commandUse = db.getCommandUseTable().getCommandUse(); assertEquals(expected, commandUse); for (int i = 0; i < 3; i++) { @@ -187,7 +167,7 @@ public void testSaveCommandUse() throws SQLException, DBInitException { expected.put("test", 3); expected.put("tp", 6); - commandUse = db.getCommandUse(); + commandUse = db.getCommandUseTable().getCommandUse(); assertEquals(expected, commandUse); } @@ -244,19 +224,19 @@ public void testTPSSaving() throws Exception { assertEquals(expected, tpsTable.getTPSData()); } - private void saveUserOne() { + private void saveUserOne() throws SQLException { saveUserOne(db); } - private void saveUserOne(Database database) { + private void saveUserOne(SQLDB database) throws SQLException { database.getUsersTable().registerUser(uuid, 123456789L, "Test"); } - private void saveUserTwo() { + private void saveUserTwo() throws SQLException { saveUserTwo(db); } - private void saveUserTwo(Database database) { + private void saveUserTwo(SQLDB database) throws SQLException { database.getUsersTable().registerUser(uuid2, 123456789L, "Test"); } @@ -277,25 +257,24 @@ public void testActionsTable() throws SQLException { @Test public void testIPTable() throws SQLException, DBInitException { saveUserOne(); - GeoInfoTable ipsTable = db.getIpsTable(); + GeoInfoTable geoInfoTable = db.getGeoInfoTable(); String expectedIP = "1.2.3.4"; String expectedGeoLoc = "TestLocation"; long time = MiscUtils.getTime(); GeoInfo expected = new GeoInfo(expectedIP, expectedGeoLoc, time); - ipsTable.saveGeoInfo(uuid, expected); - ipsTable.saveGeoInfo(uuid, expected); + geoInfoTable.saveGeoInfo(uuid, expected); + geoInfoTable.saveGeoInfo(uuid, expected); commitTest(); - List getInfo = ipsTable.getGeoInfo(uuid); + List getInfo = geoInfoTable.getGeoInfo(uuid); assertEquals(1, getInfo.size()); GeoInfo actual = getInfo.get(0); assertEquals(expected, actual); assertEquals(time, actual.getLastUsed()); - - Optional result = ipsTable.getGeolocation(expectedIP); + Optional result = geoInfoTable.getGeolocation(expectedIP); assertTrue(result.isPresent()); assertEquals(expectedGeoLoc, result.get()); } @@ -353,11 +332,11 @@ public void testWorldTable() throws SQLException, DBInitException { assertEquals(new HashSet<>(worlds), new HashSet<>(saved)); } - private void saveTwoWorlds() { + private void saveTwoWorlds() throws SQLException { saveTwoWorlds(db); } - private void saveTwoWorlds(Database database) { + private void saveTwoWorlds(SQLDB database) throws SQLException { database.getWorldTable().saveWorlds(worlds); } @@ -508,14 +487,16 @@ public void testUserInfoTableUpdateBannedOpped() throws SQLException, DBInitExce userInfoTable.registerUserInfo(uuid, 223456789L); assertTrue(userInfoTable.isRegistered(uuid)); - userInfoTable.updateOpStatus(uuid, true, true); + userInfoTable.updateOpStatus(uuid, true); + userInfoTable.updateBanStatus(uuid, true); commitTest(); UserInfo userInfo = userInfoTable.getUserInfo(uuid); assertTrue(userInfo.isBanned()); assertTrue(userInfo.isOpped()); - userInfoTable.updateOpStatus(uuid, false, true); + userInfoTable.updateOpStatus(uuid, false); + userInfoTable.updateBanStatus(uuid, true); commitTest(); userInfo = userInfoTable.getUserInfo(uuid); @@ -523,13 +504,14 @@ public void testUserInfoTableUpdateBannedOpped() throws SQLException, DBInitExce assertTrue(userInfo.isBanned()); assertFalse(userInfo.isOpped()); - userInfoTable.updateOpStatus(uuid, false, false); + userInfoTable.updateOpStatus(uuid, true); + userInfoTable.updateBanStatus(uuid, false); commitTest(); userInfo = userInfoTable.getUserInfo(uuid); assertFalse(userInfo.isBanned()); - assertFalse(userInfo.isOpped()); + assertTrue(userInfo.isOpped()); } @Test @@ -572,7 +554,7 @@ public void testRemovalSingleUser() throws SQLException, DBException { UsersTable usersTable = db.getUsersTable(); SessionsTable sessionsTable = db.getSessionsTable(); NicknamesTable nicknamesTable = db.getNicknamesTable(); - GeoInfoTable ipsTable = db.getIpsTable(); + GeoInfoTable geoInfoTable = db.getGeoInfoTable(); ActionsTable actionsTable = db.getActionsTable(); userInfoTable.registerUserInfo(uuid, 223456789L); @@ -585,7 +567,7 @@ public void testRemovalSingleUser() throws SQLException, DBException { sessionsTable.saveSession(uuid, session); nicknamesTable.saveUserName(uuid, "TestNick"); - ipsTable.saveGeoInfo(uuid, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); + geoInfoTable.saveGeoInfo(uuid, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); actionsTable.insertAction(uuid, new Action(1324L, Actions.FIRST_SESSION, "Add")); assertTrue(usersTable.isRegistered(uuid)); @@ -595,7 +577,7 @@ public void testRemovalSingleUser() throws SQLException, DBException { assertFalse(usersTable.isRegistered(uuid)); assertFalse(userInfoTable.isRegistered(uuid)); assertTrue(nicknamesTable.getNicknames(uuid).isEmpty()); - assertTrue(ipsTable.getGeoInfo(uuid).isEmpty()); + assertTrue(geoInfoTable.getGeoInfo(uuid).isEmpty()); assertTrue(sessionsTable.getSessions(uuid).isEmpty()); assertTrue(actionsTable.getActions(uuid).isEmpty()); } @@ -606,7 +588,7 @@ public void testRemovalEverything() throws SQLException, DBException { UsersTable usersTable = db.getUsersTable(); SessionsTable sessionsTable = db.getSessionsTable(); NicknamesTable nicknamesTable = db.getNicknamesTable(); - GeoInfoTable ipsTable = db.getIpsTable(); + GeoInfoTable geoInfoTable = db.getGeoInfoTable(); ActionsTable actionsTable = db.getActionsTable(); TPSTable tpsTable = db.getTpsTable(); SecurityTable securityTable = db.getSecurityTable(); @@ -620,23 +602,23 @@ public void testRemovalEverything() throws SQLException, DBException { assertFalse(userInfoTable.isRegistered(uuid)); assertTrue(nicknamesTable.getNicknames(uuid).isEmpty()); - assertTrue(ipsTable.getGeoInfo(uuid).isEmpty()); + assertTrue(geoInfoTable.getGeoInfo(uuid).isEmpty()); assertTrue(sessionsTable.getSessions(uuid).isEmpty()); assertTrue(actionsTable.getActions(uuid).isEmpty()); - assertTrue(db.getCommandUse().isEmpty()); + assertTrue(db.getCommandUseTable().getCommandUse().isEmpty()); assertTrue(db.getWorldTable().getWorlds().isEmpty()); assertTrue(tpsTable.getTPSData().isEmpty()); assertTrue(db.getServerTable().getBukkitServers().isEmpty()); assertTrue(securityTable.getUsers().isEmpty()); } - private void saveAllData(Database database) throws SQLException { + private void saveAllData(SQLDB database) throws SQLException { System.out.println("Saving all possible data to the Database.."); UserInfoTable userInfoTable = database.getUserInfoTable(); UsersTable usersTable = database.getUsersTable(); SessionsTable sessionsTable = database.getSessionsTable(); NicknamesTable nicknamesTable = database.getNicknamesTable(); - GeoInfoTable ipsTable = database.getIpsTable(); + GeoInfoTable geoInfoTable = database.getGeoInfoTable(); ActionsTable actionsTable = database.getActionsTable(); TPSTable tpsTable = database.getTpsTable(); SecurityTable securityTable = database.getSecurityTable(); @@ -654,7 +636,7 @@ private void saveAllData(Database database) throws SQLException { sessionsTable.saveSession(uuid, session); nicknamesTable.saveUserName(uuid, "TestNick"); - ipsTable.saveGeoInfo(uuid, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); + geoInfoTable.saveGeoInfo(uuid, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); actionsTable.insertAction(uuid, new Action(1324L, Actions.FIRST_SESSION, "Add")); assertTrue(usersTable.isRegistered(uuid)); @@ -721,7 +703,7 @@ public void testServerTableBungee() throws SQLException, DBInitException { } @Test - public void testSessionTableNPEWhenNoPlayers() { + public void testSessionTableNPEWhenNoPlayers() throws SQLException { Map lastSeen = db.getSessionsTable().getLastSeenForAllPlayers(); assertTrue(lastSeen.isEmpty()); } @@ -803,7 +785,7 @@ public void testBackupAndRestore() throws SQLException, DBInitException { assertFalse(ipsTable.getGeoInfo(uuid).isEmpty()); assertFalse(sessionsTable.getSessions(uuid).isEmpty()); assertFalse(actionsTable.getActions(uuid).isEmpty()); - assertFalse(backup.getCommandUse().isEmpty()); + assertFalse(backup.getCommandUseTable().getCommandUse().isEmpty()); assertFalse(backup.getWorldTable().getWorlds().isEmpty()); assertFalse(tpsTable.getTPSData().isEmpty()); assertFalse(backup.getServerTable().getBukkitServers().isEmpty()); @@ -873,7 +855,7 @@ public void testSaveSessionsWorldTimes() throws SQLException { } @Test - public void testRegisterProcessorRegisterException() { + public void testRegisterProcessorRegisterException() throws SQLException { assertFalse(db.getUsersTable().isRegistered(uuid)); assertFalse(db.getUserInfoTable().isRegistered(uuid)); for (int i = 0; i < 200; i++) { @@ -884,7 +866,7 @@ public void testRegisterProcessorRegisterException() { } @Test - public void testWorldTableGetWorldNamesNoException() { + public void testWorldTableGetWorldNamesNoException() throws SQLException { Set worldNames = db.getWorldTable().getWorldNames(); } } diff --git a/Plan/test/main/java/test/utilities/DBTestSuite.java b/Plan/test/main/java/test/utilities/DBTestSuite.java index 5175019aed..231efdd86c 100644 --- a/Plan/test/main/java/test/utilities/DBTestSuite.java +++ b/Plan/test/main/java/test/utilities/DBTestSuite.java @@ -4,7 +4,8 @@ */ package test.utilities; -import com.djrapitops.plan.system.database.DatabaseTest; +import com.djrapitops.plan.system.database.MySQLTest; +import com.djrapitops.plan.system.database.SQLiteTest; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; @@ -16,7 +17,7 @@ * @author Fuzzlemann */ @RunWith(Suite.class) -@Suite.SuiteClasses({DatabaseTest.class}) +@Suite.SuiteClasses({SQLiteTest.class, MySQLTest.class}) public class DBTestSuite { @BeforeClass public static void setUp() { From 9b0d42587bfffb9e414d56dccaea40132c8387dc Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 18:53:00 +0200 Subject: [PATCH 051/166] Fixed AnalyzeCommand --- .../plan/command/commands/AnalyzeCommand.java | 133 +++++++++--------- .../operation/TransferOperations.java | 3 +- .../sql/operation/SQLTransferOps.java | 9 +- .../databases/sql/tables/TransferTable.java | 65 +++++++++ .../connection/BukkitConnectionSystem.java | 33 +++-- .../connection/BungeeConnectionSystem.java | 93 ++++++++++++ .../info/connection/ConnectionSystem.java | 29 +++- .../GenerateInspectPluginsTabRequest.java | 2 +- .../plan/system/info/request/WideRequest.java | 13 ++ .../info/BukkitInformationManager.java | 7 - .../plan/utilities/analysis/Analysis.java | 4 + 11 files changed, 299 insertions(+), 92 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/WideRequest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 1aa0e623b1..db70f23300 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -1,12 +1,20 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; +import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest; import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.settings.Permissions; -import com.djrapitops.plan.systems.info.InformationManager; +import com.djrapitops.plan.system.webserver.WebServerSystem; +import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; @@ -14,12 +22,9 @@ import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.RunnableFactory; -import com.djrapitops.plugin.utilities.Verify; import org.bukkit.ChatColor; -import java.sql.SQLException; -import java.util.Collection; -import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.UUID; @@ -31,9 +36,6 @@ */ public class AnalyzeCommand extends SubCommand { - private final Plan plugin; - private final InformationManager infoManager; - /** * Subcommand Constructor. * @@ -45,34 +47,6 @@ public AnalyzeCommand(Plan plugin) { Permissions.ANALYZE.getPermission(), Locale.get(Msg.CMD_USG_ANALYZE).parse(), "[ServerName or ID]"); - this.plugin = plugin; - infoManager = plugin.getInfoManager(); - } - - public static void sendAnalysisMessage(Collection senders, UUID serverUUID) throws DBException { - if (Verify.isEmpty(senders)) { - return; - } - Plan plugin = Plan.getInstance(); - Optional serverName = plugin.getDB().fetch().getServerName(serverUUID); - serverName.ifPresent(name -> { - String target = "/server/" + name; - String url = plugin.getInfoManager().getLinkTo(target); - String message = Locale.get(Msg.CMD_INFO_LINK).toString(); - - for (ISender sender : senders) { - sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString()); - // Link - boolean console = !CommandUtils.isPlayer(sender); - if (console) { - sender.sendMessage(message + url); - } else { - sender.sendMessage(message); - sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url); - } - sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); - } - }); } @Override @@ -82,39 +56,52 @@ public String[] addHelp() { @Override public boolean onCommand(ISender sender, String commandLabel, String[] args) { + sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString()); - UUID serverUUID = Plan.getServerUUID(); - if (args.length >= 1 && plugin.getInfoManager().isUsingAnotherWebServer()) { - try { - List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); - Optional server = bukkitServers.stream().filter(info -> { - StringBuilder idBuilder = new StringBuilder(args[0]); - if (args.length > 1) { - for (int i = 1; i < args.length; i++) { - idBuilder.append(" ").append(args[i]); - } + new Processor(sender) { + @Override + public void process() { + try { + Server server = getServer(args).orElseGet(ServerInfo::getServer); + UUID serverUUID = server.getUuid(); + if (!ServerInfo.getServerUUID().equals(serverUUID) || !Analysis.isAnalysisBeingRun()) { + InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(serverUUID)); } - String serverIdentifier = idBuilder.toString(); - return Integer.toString(info.getId()).equals(serverIdentifier) || info.getName().equalsIgnoreCase(serverIdentifier); - }).findFirst(); - if (server.isPresent()) { - serverUUID = server.get().getUuid(); + sendWebUserNotificationIfNecessary(sender); + sendLink(server, sender); + } catch (DBException | WebException e) { + // TODO Exception handling + sender.sendMessage(ChatColor.RED + " Error occurred: " + e.toString()); + Log.toLog(this.getClass().getName(), e); } - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - return true; } - } + }.queue(); + return true; + } - updateCache(sender, serverUUID); + private void sendLink(Server server, ISender sender) { + String target = "/server/" + server.getName(); + String url = ConnectionSystem.getAddress() + target; + String message = Locale.get(Msg.CMD_INFO_LINK).toString(); + sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString()); + // Link + boolean console = !CommandUtils.isPlayer(sender); + if (console) { + sender.sendMessage(message + url); + } else { + sender.sendMessage(message); + sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url); + } + sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); + } - sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString()); - if (plugin.getInfoManager().isAuthRequired() && CommandUtils.isPlayer(sender)) { + private void sendWebUserNotificationIfNecessary(ISender sender) { + if (WebServerSystem.getInstance().getWebServer().isAuthRequired() && CommandUtils.isPlayer(sender)) { RunnableFactory.createNew(new AbsRunnable("WebUser exist check task") { @Override public void run() { try { - boolean senderHasWebUser = plugin.getDB().getSecurityTable().userExists(sender.getName()); + boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName()); if (!senderHasWebUser) { sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); } @@ -126,11 +113,31 @@ public void run() { } }).runTaskAsynchronously(); } - return true; } - private void updateCache(ISender sender, UUID serverUUID) { - infoManager.addAnalysisNotification(sender, serverUUID); - infoManager.refreshAnalysis(serverUUID); + private Optional getServer(String[] args) throws DBException { + if (args.length >= 1 && ConnectionSystem.getInstance().isServerAvailable()) { + Map bukkitServers = Database.getActive().fetch().getBukkitServers(); + String serverIdentifier = getGivenIdentifier(args); + for (Map.Entry entry : bukkitServers.entrySet()) { + Server server = entry.getValue(); + + if (Integer.toString(server.getId()).equals(serverIdentifier) + || server.getName().equalsIgnoreCase(serverIdentifier)) { + return Optional.of(server); + } + } + } + return Optional.empty(); + } + + private String getGivenIdentifier(String[] args) { + StringBuilder idBuilder = new StringBuilder(args[0]); + if (args.length > 1) { + for (int i = 1; i < args.length; i++) { + idBuilder.append(" ").append(args[i]); + } + } + return idBuilder.toString(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index 862b4c021f..5dce3280af 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import java.util.Map; +import java.util.Optional; import java.util.UUID; /** @@ -36,7 +37,7 @@ public interface TransferOperations { Map getEncodedServerHtml() throws DBException; - UUID getServerPlayerIsOnline(UUID playerUUID) throws DBException; + Optional getServerPlayerIsOnlineOn(UUID playerUUID) throws DBException; Map getEncodedPlayerPluginsTabs(UUID playerUUID) throws DBException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java index 910ad05c92..6669663280 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java @@ -10,6 +10,7 @@ import java.sql.SQLException; import java.util.Map; +import java.util.Optional; import java.util.UUID; /** @@ -87,8 +88,12 @@ public void storePlayerPluginsTab(UUID player, String encodedHtml) throws DBExce } @Override - public UUID getServerPlayerIsOnline(UUID playerUUID) { - return null; // TODO + public Optional getServerPlayerIsOnlineOn(UUID playerUUID) throws DBException { + try { + return transferTable.getServerPlayerIsOnline(playerUUID); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java index 09851e7912..e74d959332 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -23,6 +23,7 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.UUID; /** @@ -75,6 +76,31 @@ public void createTable() throws DBCreateTableException { ); } + public void clean() throws SQLException { + String sql = "DELETE FROM " + tableName + + " WHERE " + columnExpiry + " < ?" + + " AND " + columnInfoType + " != ?"; + + execute(new ExecStatement(sql) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setLong(1, MiscUtils.getTime() + TimeAmount.MINUTE.ms()); + statement.setString(2, "onlineStatus"); + } + }); + sql = "DELETE FROM " + tableName + + " WHERE " + columnSenderID + " = " + serverTable.statementSelectServerID + + " AND " + columnInfoType + " != ?"; + + execute(new ExecStatement(sql) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, ServerInfo.getServerUUID().toString()); + statement.setString(2, "onlineStatus"); + } + }); + } + public void storePlayerHtml(UUID player, String encodedHtml) throws SQLException { execute(new ExecStatement(insertStatement) { @Override @@ -195,4 +221,43 @@ public Map processResults(ResultSet set) throws SQLException { } }); } + + public Optional getServerPlayerIsOnline(UUID playerUUID) throws SQLException { + String serverIDColumn = serverTable + "." + serverTable.getColumnID(); + String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid"; + String sql = "SELECT " + + serverUUIDColumn + + " FROM " + tableName + + " JOIN " + serverTable + " on " + serverIDColumn + "=" + columnSenderID + + " WHERE " + columnExtraVariables + "=?" + + " ORDER BY " + columnExpiry + " LIMIT 1"; + + return query(new QueryStatement>(sql, 1) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, playerUUID.toString()); + } + + @Override + public Optional processResults(ResultSet set) throws SQLException { + if (set.next()) { + return Optional.of(UUID.fromString(set.getString(columnExtraVariables))); + } + return Optional.empty(); + } + }); + } + + public void storePlayerOnlineOnThisServer(UUID playerUUID) throws SQLException { + execute(new ExecStatement(insertStatement) { + @Override + public void prepare(PreparedStatement statement) throws SQLException { + statement.setString(1, ServerInfo.getServerUUID().toString()); + statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms()); + statement.setString(3, "onlineStatus"); + statement.setString(4, playerUUID.toString()); + statement.setString(5, null); + } + }); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index 891c6414f6..3494ea383c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -5,13 +5,9 @@ package com.djrapitops.plan.system.info.connection; import com.djrapitops.plan.api.exceptions.connection.NoServersException; -import com.djrapitops.plan.api.exceptions.connection.UnsupportedTransferDatabaseException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.info.request.CacheRequest; -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.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; @@ -20,6 +16,7 @@ import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.RunnableFactory; +import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.UUID; @@ -31,12 +28,14 @@ */ public class BukkitConnectionSystem extends ConnectionSystem { - private long latestServerMapRefresh = 0; + private long latestServerMapRefresh; private Server mainServer; private Map servers; public BukkitConnectionSystem() { + servers = new HashMap<>(); + latestServerMapRefresh = 0; } private void refreshServerMap() { @@ -68,8 +67,10 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer UUID serverUUID = ((GenerateAnalysisPageRequest) infoRequest).getServerUUID(); server = servers.get(serverUUID); } else if (infoRequest instanceof GenerateInspectPageRequest) { - UUID serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); - server = servers.getOrDefault(serverUUID, ServerInfo.getServer()); + Optional serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); + if (serverUUID.isPresent()) { + server = servers.getOrDefault(serverUUID.get(), ServerInfo.getServer()); + } } if (server == null) { throw new NoServersException("Proper server is not available to process requests."); @@ -77,16 +78,14 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer return server; } - private UUID getServerWherePlayerIsOnline(GenerateInspectPageRequest infoRequest) { - UUID playerUUID = infoRequest.getPlayerUUID(); - try { - return Database.getActive().transfer().getServerPlayerIsOnline(playerUUID); - } catch (UnsupportedTransferDatabaseException e) { - /* Do nothing */ - } catch (DBException e) { - Log.toLog(this.getClass().getName(), e); + @Override + public void sendWideInfoRequest(WideRequest infoRequest) throws NoServersException { + if (servers.isEmpty()) { + throw new NoServersException("No Servers Available to make process request."); + } + for (Server server : servers.values()) { + WebExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server)); } - return null; } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java index 2b60431547..1273d6de6c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java @@ -4,10 +4,103 @@ */ package com.djrapitops.plan.system.info.connection; +import com.djrapitops.plan.api.exceptions.connection.NoServersException; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.request.*; +import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.webserver.WebServerSystem; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.TimeAmount; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.task.AbsRunnable; +import com.djrapitops.plugin.task.RunnableFactory; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + /** * ConnectionSystem for Bungee. * * @author Rsl1122 */ public class BungeeConnectionSystem extends ConnectionSystem { + + private long latestServerMapRefresh; + private Map servers; + + public BungeeConnectionSystem() { + servers = new HashMap<>(); + latestServerMapRefresh = 0; + } + + private void refreshServerMap() { + if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.MINUTE.ms() * 2L) { + try { + servers = Database.getActive().fetch().getBukkitServers(); + latestServerMapRefresh = MiscUtils.getTime(); + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + } + } + } + + @Override + protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException { + Server server = null; + if (infoRequest instanceof CacheRequest) { + throw new NoServersException("Bungee should not send Cache requests."); + } else if (infoRequest instanceof GenerateAnalysisPageRequest) { + UUID serverUUID = ((GenerateAnalysisPageRequest) infoRequest).getServerUUID(); + server = servers.get(serverUUID); + } else if (infoRequest instanceof GenerateInspectPageRequest) { + Optional serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); + if (serverUUID.isPresent()) { + server = servers.getOrDefault(serverUUID.get(), ServerInfo.getServer()); + } + } + if (server == null) { + throw new NoServersException("Proper server is not available to process requests."); + } + return server; + } + + @Override + public void sendWideInfoRequest(WideRequest infoRequest) throws NoServersException { + if (servers.isEmpty()) { + throw new NoServersException("No Servers Available to make process request."); + } + for (Server server : servers.values()) { + WebExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server)); + } + } + + @Override + public boolean isServerAvailable() { + return true; + } + + @Override + public String getMainAddress() { + return WebServerSystem.getInstance().getWebServer().getAccessAddress(); + } + + @Override + public void enable() { + refreshServerMap(); + RunnableFactory.createNew("Server List Update Task", new AbsRunnable() { + @Override + public void run() { + refreshServerMap(); + } + }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 30L, TimeAmount.MINUTE.ticks() * 5L); + } + + @Override + public void disable() { + + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index bde165d986..d83bf9a638 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -5,16 +5,21 @@ package com.djrapitops.plan.system.info.connection; import com.djrapitops.plan.api.exceptions.connection.NoServersException; +import com.djrapitops.plan.api.exceptions.connection.UnsupportedTransferDatabaseException; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.utility.log.Log; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.UUID; /** @@ -63,9 +68,17 @@ private void putRequest(Map requests, InfoRequest request) protected abstract Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException; + public static String getAddress() { + return getInstance().getMainAddress(); + } + public void sendInfoRequest(InfoRequest infoRequest) throws WebException { Server server = selectServerForRequest(infoRequest); - new ConnectionOut(server, ServerInfo.getServerUUID(), infoRequest).sendRequest(); + sendInfoRequest(infoRequest, server); + } + + public void sendInfoRequest(InfoRequest infoRequest, Server toServer) throws WebException { + new ConnectionOut(toServer, ServerInfo.getServerUUID(), infoRequest).sendRequest(); } public ConnectionLog getConnectionLog() { @@ -75,4 +88,18 @@ public ConnectionLog getConnectionLog() { public abstract boolean isServerAvailable(); public abstract String getMainAddress(); + + public abstract void sendWideInfoRequest(WideRequest infoRequest) throws NoServersException; + + protected Optional getServerWherePlayerIsOnline(GenerateInspectPageRequest infoRequest) { + UUID playerUUID = infoRequest.getPlayerUUID(); + try { + return Database.getActive().transfer().getServerPlayerIsOnlineOn(playerUUID); + } catch (UnsupportedTransferDatabaseException e) { + /* Do nothing */ + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + } + return Optional.empty(); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java index e6557a9956..39a467af5c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java @@ -23,7 +23,7 @@ * * @author Rsl1122 */ -public class GenerateInspectPluginsTabRequest extends InfoRequestWithVariables implements GenerateRequest { +public class GenerateInspectPluginsTabRequest extends InfoRequestWithVariables implements GenerateRequest, WideRequest { private final UUID playerUUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/WideRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/WideRequest.java new file mode 100644 index 0000000000..769950995c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/WideRequest.java @@ -0,0 +1,13 @@ +/* + * 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.info.request; + +/** + * InfoRequest that should be relayed to all Bukkit servers. + * + * @author Rsl1122 + */ +public interface WideRequest extends InfoRequest { +} \ No newline at end of file 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 index 73c59f7f5a..97bcb829b2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/BukkitInformationManager.java @@ -10,7 +10,6 @@ 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.command.commands.AnalyzeCommand; import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.settings.Settings; @@ -32,7 +31,6 @@ import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; import java.util.HashSet; import java.util.Optional; import java.util.UUID; @@ -200,11 +198,6 @@ public String getWebServerAddress() { @Override public void analysisReady(UUID serverUUID) { - try { - AnalyzeCommand.sendAnalysisMessage(analysisNotification.get(serverUUID), serverUUID); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } analysisNotification.getOrDefault(serverUUID, new HashSet<>()).clear(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 90ea28ed18..9dfbedd806 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -181,4 +181,8 @@ private Map analyzeAdditionalPluginData(Set Benchmark.stop("Analysis", "3rd party Analysis"); return containers; } + + public static boolean isAnalysisBeingRun() { + return serverProfile != null; + } } From c786e7795a855d77794b608d0b0f61fc0b263621 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 19:14:50 +0200 Subject: [PATCH 052/166] 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 f49a10e6ee..a6f1e9017a 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.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 void onEnable() { 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 void onEnable() { } } serverInfoManager.updateServerInfo(); - infoManager.updateConnection(); Benchmark.stop("Enable", "WebServer Initialization"); @@ -270,11 +265,6 @@ public BukkitServerInfo getServerInfoManager() { 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 6384cef4ec..0b1cc6893c 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.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 void onEnable() { Benchmark.start("WebServer Initialization"); serverInfoManager = new BungeeServerInfo(this); - infoManager = new BungeeInformationManager(this); WebServerSystem.getInstance().enable(); serverInfoManager.loadServerInfo(); @@ -137,12 +132,6 @@ public BungeeServerInfo getServerInfoManager() { return serverInfoManager; } - @Override - @Deprecated - public InformationManager getInfoManager() { - return infoManager; - } - @Override public WebServer getWebServer() { return WebServerSystem.getInstance().getWebServer(); @@ -153,11 +142,6 @@ public InputStream getResource(String resource) { 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 157fcc0955..d5a2204e5d 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 @@ 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 @@ static PlanPlugin getInstance() { @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 3b8851fce2..b629010d22 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 @@ private void sendListMsg(ISender sender) { 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 2d63a7b958..2d7f88e7e8 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 @@ 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 @@ private void sendNetworkMsg(ISender sender) { 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 acc7f92e58..9110ac3781 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 @@ 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 041a15e8b1..f71c7b8f0e 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.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 void sendRequest(InfoRequest infoRequest) throws WebException { @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 762a45a248..581430d5c9 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 1624d758f9..33c711df78 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 572607797f..450e9d6cd1 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 0afe68c081..e99dfa97b0 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 3c343aea7e..40d3cc3e40 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.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 @@ private void processServerData() { } 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 @@ private void processUserData() throws DBException { 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 ed7546cbe0..c61bb1b88a 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 2c4c14af12..2f7186f3de 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 BootAnalysisTask() { 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 79cb344fad..c0c780a044 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 PeriodicAnalysisTask() { @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 b6b66734f4..9a4e436273 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 EnableConnectionTask() { @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 5c3b5ed2f7..294245e783 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 696b0ac156..6538d937f7 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 @@ */ 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 af3d13be77..0e4f0a50e2 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 @@ /** * @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 621b13f651..0abc9ccfbe 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 @@ /** * @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 9d92bd9e8c..b54d10ee09 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 @@ 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 @@ * * @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 97bcb829b2..0000000000 --- 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 3236e8ef8b..0000000000 --- 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 272c16825b..0000000000 --- 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 8f9be87e01..58a1c471c3 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.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 static void exportPlayer(UUID playerUUID) { @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 1f5591dfea..6c65caf4d9 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 @@ 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 @@ private void addFeatureBarChart(String id) { 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 d24a84184b..d434bcf1d2 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.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 boolean isAnalysisCached() { */ @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 void updateAnalysisCache() { */ @Deprecated public String getAnalysisHtmlAsString() { - return plugin.getInfoManager().getAnalysisHtml(); + return ResponseCache.loadResponse(PageId.SERVER.of(ServerInfo.getServerUUID()), AnalysisPageResponse::refreshNow).getContent(); } /** @@ -208,7 +215,7 @@ public String getAnalysisHtmlAsString() { */ @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 b6e1e5e9ee..f2841cc14d 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 @@ 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; From ab879234204b23b2bf167011717c21bd3e27a885 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 19:34:41 +0200 Subject: [PATCH 053/166] Cleaned up main plugin class (Plan) --- .../main/java/com/djrapitops/plan/Plan.java | 107 +----------------- .../java/com/djrapitops/plan/PlanBungee.java | 9 +- .../java/com/djrapitops/plan/PlanPlugin.java | 4 - .../plan/command/PlanBungeeCommand.java | 4 +- .../djrapitops/plan/command/PlanCommand.java | 4 +- .../plan/command/commands/AnalyzeCommand.java | 4 +- .../plan/command/commands/DevCommand.java | 39 +------ .../plan/command/commands/InfoCommand.java | 4 +- .../plan/command/commands/InspectCommand.java | 4 +- .../plan/command/commands/ListCommand.java | 4 +- .../command/commands/ListServersCommand.java | 4 +- .../plan/command/commands/ManageCommand.java | 4 +- .../plan/command/commands/NetworkCommand.java | 4 +- .../command/commands/QInspectCommand.java | 4 +- .../command/commands/RegisterCommand.java | 4 +- .../plan/command/commands/ReloadCommand.java | 4 +- .../plan/command/commands/SearchCommand.java | 4 +- .../plan/command/commands/WebUserCommand.java | 4 +- .../commands/manage/ManageBackupCommand.java | 4 +- .../commands/manage/ManageClearCommand.java | 4 +- .../commands/manage/ManageDisableCommand.java | 4 +- .../commands/manage/ManageHotswapCommand.java | 4 +- .../commands/manage/ManageImportCommand.java | 4 +- .../commands/manage/ManageMoveCommand.java | 4 +- .../commands/manage/ManageRemoveCommand.java | 4 +- .../commands/manage/ManageRestoreCommand.java | 4 +- .../commands/manage/ManageSetupCommand.java | 4 +- .../commands/webuser/WebCheckCommand.java | 4 +- .../commands/webuser/WebDeleteCommand.java | 4 +- .../commands/webuser/WebLevelCommand.java | 4 +- .../commands/webuser/WebListUsersCommand.java | 4 +- .../djrapitops/plan/data/AnalysisData.java | 4 +- .../djrapitops/plan/system/BukkitSystem.java | 2 + .../plan/system/database/DBSystem.java | 4 +- .../connection/BukkitConnectionSystem.java | 15 +++ .../bukkit/GamemodeChangeListener.java | 2 +- .../listeners/bukkit/WorldChangeListener.java | 2 +- .../info/InspectCacheRequestProcessor.java | 4 +- .../settings/ServerSpecificSettings.java | 3 +- .../plan/system/settings/Settings.java | 1 - .../settings/WorldAliasSettings.java | 3 +- .../system/settings/config/ConfigSystem.java | 6 +- .../{ => system}/settings/locale/Locale.java | 2 +- .../{ => system}/settings/locale/Message.java | 2 +- .../{ => system}/settings/locale/Msg.java | 2 +- .../settings/theme/PlanColorScheme.java | 2 +- .../{ => system}/settings/theme/Theme.java | 2 +- .../settings/theme/ThemeConfig.java | 2 +- .../{ => system}/settings/theme/ThemeVal.java | 2 +- .../plan/system/tasks/BukkitTaskSystem.java | 18 ++- .../system/tasks/bukkit/BootAnalysisTask.java | 4 +- .../plan/system/webserver/WebServer.java | 4 +- .../system/webserver/WebServerSystem.java | 16 ++- .../webserver/pages/parsing/InspectPage.java | 4 +- .../webserver/pages/parsing/NetworkPage.java | 4 +- .../webserver/response/CSSResponse.java | 2 +- .../response/JavaScriptResponse.java | 4 +- .../response/errors/ErrorResponse.java | 2 +- .../response/pages/DebugPageResponse.java | 3 +- .../response/pages/InspectPageResponse.java | 2 +- .../response/pages/PlayersPageResponse.java | 2 +- .../webapi/bukkit/ConfigurationWebAPI.java | 2 +- .../djrapitops/plan/utilities/MiscUtils.java | 4 +- .../plan/utilities/analysis/Analysis.java | 4 +- .../comparators/LocaleEntryComparator.java | 4 +- .../utilities/file/export/HtmlExport.java | 4 +- .../plan/utilities/html/HtmlUtils.java | 4 +- .../html/graphs/ActivityStackGraph.java | 4 +- .../html/graphs/pie/ActivityPie.java | 4 +- .../utilities/html/graphs/pie/WorldPie.java | 6 +- .../structure/ServerAccordionCreator.java | 4 +- .../structure/SessionTabStructureCreator.java | 4 +- .../html/tables/KillsTableCreator.java | 4 +- .../html/tables/SessionsTableCreator.java | 2 +- .../utilities/comparators/ComparatorTest.java | 4 +- .../main/java/test/utilities/TestInit.java | 5 +- 76 files changed, 177 insertions(+), 274 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/ServerSpecificSettings.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/WorldAliasSettings.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/locale/Locale.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/locale/Message.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/locale/Msg.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/theme/PlanColorScheme.java (95%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/theme/Theme.java (98%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/theme/ThemeConfig.java (97%) rename Plan/src/main/java/com/djrapitops/plan/{ => system}/settings/theme/ThemeVal.java (98%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index a6f1e9017a..a45871d161 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -19,30 +19,19 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.command.PlanCommand; import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.settings.theme.PlanColorScheme; -import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.BukkitSystem; -import com.djrapitops.plan.system.cache.GeolocationCache; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; -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.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.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.system.settings.theme.PlanColorScheme; import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; import com.djrapitops.plugin.StaticHolder; @@ -51,11 +40,8 @@ import com.djrapitops.plugin.api.utility.log.DebugLog; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.settings.ColorScheme; -import com.djrapitops.plugin.task.RunnableFactory; import org.bukkit.configuration.file.FileConfiguration; -import java.io.IOException; -import java.net.UnknownHostException; import java.util.UUID; /** @@ -73,10 +59,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { private HookHandler hookHandler; // Manages 3rd party data sources - private BukkitServerInfo serverInfoManager; - - private ServerProperties serverProperties; - /** * Used to get the plugin-instance singleton. * @@ -104,60 +86,9 @@ public UUID getServerUuid() { public void onEnable() { super.onEnable(); try { - FileSystem.getInstance().enable(); - ConfigSystem.getInstance().enable(); - - Log.setDebugMode(Settings.DEBUG.toString()); - - VersionCheckSystem.getInstance().enable(); - Benchmark.start("Enable"); - - 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); - } - - new Locale().loadLocale(); - - Theme.getInstance().enable(); - - Benchmark.start("Reading server variables"); - serverProperties = new ServerProperties(getServer()); - Benchmark.stop("Enable", "Reading server variables"); - - DBSystem.getInstance().enable(); - - Benchmark.start("WebServer Initialization"); - - serverInfoManager = new BukkitServerInfo(this); - WebServerSystem.getInstance().enable(); - if (!WebServerSystem.isWebServerEnabled()) { - 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?"); - - } - } - serverInfoManager.updateServerInfo(); - - Benchmark.stop("Enable", "WebServer Initialization"); - - TaskSystem.getInstance().enable(); - - boolean usingBungeeWebServer = infoManager.isUsingAnotherWebServer(); - boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); - - if (!usingAlternativeIP && serverProperties.getIp().isEmpty()) { - Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString()); - } - if (usingBungeeWebServer && usingAlternativeIP) { - Log.info("Make sure that the alternative IP points to the Bukkit Server: " + Settings.ALTERNATIVE_IP.toString()); - } + system = new BukkitSystem(this); + system.enable(); registerCommand("plan", new PlanCommand(this)); @@ -174,11 +105,6 @@ public void onEnable() { Benchmark.stop("Enable", "Enable"); Log.logDebug("Enable"); Log.info(Locale.get(Msg.ENABLED).toString()); - StaticHolder.saveInstance(ShutdownHook.class, this.getClass()); - new ShutdownHook(this); - if (Settings.ANALYSIS_EXPORT.isTrue()) { - RunnableFactory.createNew(new HtmlExport(this)).runTaskAsynchronously(); - } } catch (Exception e) { Log.error("Plugin Failed to Initialize Correctly."); Log.toLog(this.getClass().getName(), e); @@ -242,29 +168,6 @@ public HookHandler getHookHandler() { return hookHandler; } - /** - * Used to get the object storing server variables that are constant after - * boot. - * - * @return ServerProperties - * @see ServerProperties - */ - @Deprecated - public ServerProperties getVariable() { - return serverProperties; - } - - /** - * Used to get the object storing server info - * - * @return BukkitServerInfo - * @see BukkitServerInfo - */ - @Deprecated - public BukkitServerInfo getServerInfoManager() { - return serverInfoManager; - } - 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 0b1cc6893c..bd8cbee791 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -5,10 +5,6 @@ package com.djrapitops.plan; import com.djrapitops.plan.command.PlanBungeeCommand; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; -import com.djrapitops.plan.settings.theme.PlanColorScheme; -import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.BungeeSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; @@ -17,6 +13,10 @@ import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.system.settings.theme.PlanColorScheme; +import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.WebServer; @@ -147,7 +147,6 @@ public ColorScheme getColorScheme() { return PlanColorScheme.create(); } - @Override public ServerProperties getVariable() { return variableHolder; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index d5a2204e5d..f1bafd915c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -5,7 +5,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.plugin.IPlugin; import com.djrapitops.plugin.api.Check; @@ -37,9 +36,6 @@ static PlanPlugin getInstance() { @Deprecated Database getDB(); - @Deprecated - ServerProperties getVariable(); - @Deprecated UUID getServerUuid(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java index a89a4aa3e2..1ee1528788 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.command.commands.*; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.defaultcmds.StatusCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java index a68bfb5dbe..8e7ba2efec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.commands.*; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; import com.djrapitops.plugin.command.defaultcmds.StatusCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index db70f23300..dc3aeb4283 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -3,8 +3,6 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem; @@ -13,6 +11,8 @@ import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index 2b4da7b951..5aa5af2c08 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -5,20 +5,14 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.connection.WebException; -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.webserver.webapi.WebAPI; -import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; -import java.util.Optional; -import java.util.UUID; - /** * Command used for testing functions that are too difficult to unit test. * @@ -44,9 +38,7 @@ public boolean onCommand(ISender sender, String cmd, String[] args) { if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { break; } - if (!webapi(args[1] + "connection", args.length >= 3)) { - sender.sendMessage("[Plan] No such API / Exception occurred."); - } + sender.sendMessage("[Plan] No implementation."); break; case "web": ConnectionSystem connectionSystem = ConnectionSystem.getInstance(); @@ -59,29 +51,4 @@ public boolean onCommand(ISender sender, String cmd, String[] args) { } return true; } - - private boolean webapi(String method, boolean connectToBungee) { - WebAPI api = plugin.getWebServer().getWebAPI().getAPI(method); - if (api == null) { - return false; - } - try { - String address = plugin.getWebServer().getAccessAddress(); - if (connectToBungee) { - Optional bungeeConnectionAddress = plugin.getServerInfoManager().getBungeeConnectionAddress(); - if (bungeeConnectionAddress.isPresent()) { - address = bungeeConnectionAddress.get(); - } - } - if (api instanceof InspectWebAPI) { - ((InspectWebAPI) api).sendRequest(address, UUID.randomUUID()); - } else { - api.sendRequest(address); - } - return true; - } catch (WebException e) { - e.printStackTrace(); - } - return false; - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java index 8546feeb06..e1c5f4bf61 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 449122e01e..a0556bb31b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -3,11 +3,11 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.FatalDBException; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.processors.info.InspectCacheRequestProcessor; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.uuid.UUIDUtility; 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 b629010d22..4b345e5d30 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,9 +1,9 @@ package com.djrapitops.plan.command.commands; -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.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java index dfc47621c2..d80c79e2a9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java @@ -1,9 +1,9 @@ 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.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java index 192130f077..1726cc496c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.command.commands.manage.*; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; 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 2d7f88e7e8..fe23026221 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 @@ -1,10 +1,10 @@ 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.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java index ad4a8ca521..323b6c5696 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java @@ -4,10 +4,10 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.element.ActivityIndex; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index d0e5ed92a5..0821154007 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.PassEncryptUtil; import com.djrapitops.plugin.api.Check; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java index 89a99979e3..1dc3a23867 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ReloadCommand.java @@ -1,9 +1,9 @@ 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.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java index c48ea78e2d..c0538e04b7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java index 74c203b35a..3c3915338f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java @@ -7,9 +7,9 @@ import com.djrapitops.plan.command.commands.webuser.WebDeleteCommand; import com.djrapitops.plan.command.commands.webuser.WebLevelCommand; import com.djrapitops.plan.command.commands.webuser.WebListUsersCommand; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.TreeCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java index 0463ca3eaf..0b485b18ca 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBInitException; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index b5c0d29307..b577c69459 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -5,11 +5,11 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.api.exceptions.database.FatalDBException; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java index 3fcd989f26..cf00f566f3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands.manage; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.listeners.bukkit.PlayerOnlineListener; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; 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/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index e66e160f98..ec7484d82e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -1,12 +1,12 @@ 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.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; 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 9110ac3781..28ea80b7cc 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 @@ -1,10 +1,10 @@ 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.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; 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/command/commands/manage/ManageMoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java index f3f93c5de9..4d0bc2a9e7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java @@ -1,10 +1,10 @@ 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.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 636a9e3e99..9a517a5fc9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -3,11 +3,11 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.uuid.UUIDUtility; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java index 9f023a2eec..4245811578 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRestoreCommand.java @@ -1,11 +1,11 @@ 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.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index b964eeefb9..849d7e65b7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -3,10 +3,10 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.connection.ForbiddenException; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.webserver.webapi.bungee.RequestSetupWebAPI; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java index 387bcb7c31..b15f42188e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java index 3029b142a5..3a9d0602de 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java @@ -1,10 +1,10 @@ package com.djrapitops.plan.command.commands.webuser; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java index 0bf6f26e0d..033f436acf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebLevelCommand.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.command.commands.webuser; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java index f067343b21..f86d42e219 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Permissions; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.comparators.WebUserComparator; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java index d7671546eb..baad80760d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java @@ -8,9 +8,9 @@ import com.djrapitops.plan.data.element.HealthNotes; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index 30072f0784..bdda879db6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -13,6 +13,7 @@ import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; import com.djrapitops.plan.system.tasks.BukkitTaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; +import com.djrapitops.plugin.StaticHolder; /** * Represents PlanSystem for Plan. @@ -31,6 +32,7 @@ public BukkitSystem(Plan plugin) { serverInfo = new BukkitServerInfo(plugin); + StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass()); new ShutdownHook().register(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index cc0de459f5..ed4e927986 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -7,11 +7,11 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBInitException; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; 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.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index 3494ea383c..71e675d032 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -10,6 +10,10 @@ import com.djrapitops.plan.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -108,6 +112,17 @@ public void run() { refreshServerMap(); } }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 30L, TimeAmount.MINUTE.ticks() * 5L); + + boolean usingBungeeWebServer = ConnectionSystem.getInstance().isServerAvailable(); + boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); + + if (!usingAlternativeIP && ServerInfo.getServerProperties().getIp().isEmpty()) { + Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString()); + } + if (usingBungeeWebServer && usingAlternativeIP) { + String webServerAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); + Log.info("Make sure that this address points to the Bukkit Server: " + webServerAddress); + } } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java index 6a94870d60..39956f151d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java @@ -2,8 +2,8 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.WorldAliasSettings; import com.djrapitops.plan.system.cache.SessionCache; +import com.djrapitops.plan.system.settings.WorldAliasSettings; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.entity.Player; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java index 0dc9de33db..18a038218b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/WorldChangeListener.java @@ -1,8 +1,8 @@ package com.djrapitops.plan.system.listeners.bukkit; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.settings.WorldAliasSettings; import com.djrapitops.plan.system.cache.SessionCache; +import com.djrapitops.plan.system.settings.WorldAliasSettings; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.entity.Player; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java index 17b4af5ca9..ed0be671f6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java @@ -5,12 +5,12 @@ package com.djrapitops.plan.system.processing.processors.info; import com.djrapitops.plan.api.exceptions.connection.*; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/ServerSpecificSettings.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/ServerSpecificSettings.java index ce62a2f25b..a46b7b0749 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/ServerSpecificSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/ServerSpecificSettings.java @@ -2,10 +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.settings; +package com.djrapitops.plan.system.settings; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index 6c9362d395..c69dcd7e5a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.settings; -import com.djrapitops.plan.settings.ServerSpecificSettings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.config.Config; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java index bb7f3e3986..80703f0bf6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/WorldAliasSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java @@ -2,9 +2,8 @@ * 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.settings; +package com.djrapitops.plan.system.settings; -import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.config.ConfigNode; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index 347b33441a..9f02cb10fb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -5,11 +5,12 @@ package com.djrapitops.plan.system.settings.config; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; @@ -52,6 +53,7 @@ public void enable() throws EnableException { try { copyDefaults(); config.save(); + Log.setDebugMode(Settings.DEBUG.toString()); } catch (IOException e) { throw new EnableException("Failed to save default config.", e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Locale.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Locale.java index e79fd1a937..8791808412 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Locale.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Locale.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.settings.locale; +package com.djrapitops.plan.system.settings.locale; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.file.FileSystem; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Message.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Message.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/settings/locale/Message.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Message.java index 4d60107f32..563ebfe6e7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Message.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Message.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.settings.locale; +package com.djrapitops.plan.system.settings.locale; import com.djrapitops.plugin.utilities.Verify; import org.apache.commons.lang3.text.StrSubstitutor; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Msg.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Msg.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/settings/locale/Msg.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Msg.java index 41d04c4373..cf6c6c19af 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/locale/Msg.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Msg.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.settings.locale; +package com.djrapitops.plan.system.settings.locale; import java.util.Arrays; import java.util.Map; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/PlanColorScheme.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/PlanColorScheme.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/settings/theme/PlanColorScheme.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/theme/PlanColorScheme.java index b2d103b51f..f28f6a8dd4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/PlanColorScheme.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/PlanColorScheme.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.settings.theme; +package com.djrapitops.plan.system.settings.theme; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java index 5b1cc3081c..ea89ac54fb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/Theme.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.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.settings.theme; +package com.djrapitops.plan.system.settings.theme; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.SubSystem; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java index f017478bf0..67e0d8b6f1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeConfig.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.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.settings.theme; +package com.djrapitops.plan.system.settings.theme; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.utilities.file.FileUtil; diff --git a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeVal.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeVal.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeVal.java rename to Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeVal.java index 42f475838d..907e3cc8e0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/settings/theme/ThemeVal.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeVal.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.settings.theme; +package com.djrapitops.plan.system.settings.theme; /** * Enum class used for getting the Html colors that match the config settings. diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index abc8f889c8..839907a529 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -5,15 +5,17 @@ package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.tasks.bukkit.*; +import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.ITask; +import com.djrapitops.plugin.task.RunnableFactory; /** * TaskSystem responsible for registering tasks for Bukkit. @@ -24,11 +26,14 @@ public class BukkitTaskSystem extends TaskSystem { private ITask bootAnalysisTask; + private final Plan plugin; + public BukkitTaskSystem(Plan plugin) { tpsCountTimer = Check.isPaperAvailable() ? new PaperTPSCountTimer(plugin) : new BukkitTPSCountTimer(plugin); + this.plugin = plugin; } @Override @@ -39,7 +44,6 @@ public void enable() { private void registerTasks() { Benchmark.start("Task Registration"); - // Analysis refresh settings int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber(); boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0; @@ -54,12 +58,18 @@ private void registerTasks() { if (analysisRefreshTaskIsEnabled) { registerTask(new PeriodicAnalysisTask()).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod); } + if (Settings.ANALYSIS_EXPORT.isTrue()) { + RunnableFactory.createNew(new HtmlExport(plugin)).runTaskAsynchronously(); + } Benchmark.stop("Enable", "Task Registration"); } public void cancelBootAnalysis() { try { - bootAnalysisTask.cancel(); + if (bootAnalysisTask != null) { + bootAnalysisTask.cancel(); + bootAnalysisTask = null; + } } catch (Exception ignored) { /* Ignored */ } 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 2f7186f3de..a3f13e6ab1 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,11 +1,11 @@ package com.djrapitops.plan.system.tasks.bukkit; -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.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index 71197d95a7..fc64703157 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -1,11 +1,11 @@ package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Check; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java index fd781cd844..7d22df88cd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java @@ -7,8 +7,11 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.PlanSystem; 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.plugin.api.Benchmark; import com.djrapitops.plugin.api.Check; +import com.djrapitops.plugin.api.utility.log.Log; /** * WebServer subsystem for managing WebServer initialization. @@ -34,10 +37,19 @@ public static boolean isWebServerEnabled() { @Override public void enable() throws EnableException { + Benchmark.start("WebServer Initialization"); webServer.initServer(); - if (Check.isBungeeAvailable() && !webServer.isEnabled()) { - throw new EnableException("WebServer did not initialize!"); + 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"); ResponseHandler responseHandler = webServer.getResponseHandler(); responseHandler.registerWebAPIPages(); responseHandler.registerDefaultPages(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java index 3eff784fab..19914b6877 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java @@ -11,12 +11,12 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java index 21d8bbf792..2f88f48e94 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java @@ -8,11 +8,11 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; -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.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.response.cache.PageId; import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java index a58e24e9fd..f381dff85f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/CSSResponse.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.webserver.response; -import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.Theme; /** * @author Rsl1122 diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java index e9e15ad0dc..884df375a3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/JavaScriptResponse.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.system.webserver.response; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import org.apache.commons.lang3.text.StrSubstitutor; import java.util.HashMap; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java index e6357e6c91..47bfdb8fe9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.webserver.response.errors; -import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.file.FileUtil; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 8cb5d33f75..a1f7637364 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -11,6 +11,7 @@ import com.djrapitops.plan.system.info.connection.ConnectionLog; import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerProperties; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plan.utilities.FormatUtils; @@ -99,7 +100,7 @@ private void appendConnectionLog(StringBuilder content) { private void appendServerInformation(StringBuilder content) { PlanPlugin plugin = PlanPlugin.getInstance(); - ServerProperties variable = plugin.getVariable(); + ServerProperties variable = ServerInfo.getServerProperties(); content.append("

    ### Server Information
    ") .append("**Plan Version:** ").append(plugin.getVersion()).append("
    "); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java index ddaa591b18..f91eba4904 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.webserver.response.pages; -import com.djrapitops.plan.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.Theme; 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; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java index e0e420dc53..fe454d71c7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java @@ -6,10 +6,10 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.data.element.TableContainer; -import com.djrapitops.plan.settings.theme.Theme; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plan.utilities.FormatUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index bf2028abed..80648ed64e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.settings.ServerSpecificSettings; +import com.djrapitops.plan.system.settings.ServerSpecificSettings; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.webserver.response.Response; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index bdfea7f512..2e08101a9e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -3,11 +3,11 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.api.exceptions.database.DBException; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 9dfbedd806..077b5f2bef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -8,13 +8,13 @@ import com.djrapitops.plan.data.plugin.BanData; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.tasks.BukkitTaskSystem; import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/LocaleEntryComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/LocaleEntryComparator.java index c9614867c0..eb16cf4e0c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/LocaleEntryComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/LocaleEntryComparator.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.utilities.comparators; -import com.djrapitops.plan.settings.locale.Message; -import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.locale.Message; +import com.djrapitops.plan.system.settings.locale.Msg; import java.util.Comparator; import java.util.Map; 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 58a1c471c3..445fab3cb6 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 @@ -7,10 +7,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBException; 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.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; 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; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java index 449ac36e7b..9112bef4aa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.utilities.html; -import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import org.apache.commons.lang3.text.StrSubstitutor; @@ -43,7 +43,7 @@ public static String getIP() { if (Settings.SHOW_ALTERNATIVE_IP.isTrue()) { ip = Settings.ALTERNATIVE_IP.toString().replace("%port%", String.valueOf(port)); } else { - ip = PlanPlugin.getInstance().getVariable().getIp() + ":" + port; + ip = ServerInfo.getServerProperties().getIp() + ":" + port; } return ip; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java index 3da25c3686..fdc0949932 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.utilities.html.graphs; import com.djrapitops.plan.data.element.ActivityIndex; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; import java.util.Map; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java index 7c6e41a189..28fafff136 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java @@ -5,8 +5,8 @@ package com.djrapitops.plan.utilities.html.graphs.pie; import com.djrapitops.plan.data.element.ActivityIndex; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import java.util.*; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java index ac6e9c76f5..79e5d0b840 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/WorldPie.java @@ -2,10 +2,10 @@ import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.WorldAliasSettings; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.WorldAliasSettings; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.comparators.PieSliceComparator; import java.util.*; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java index 2c09a0dc37..96a5634375 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java @@ -7,8 +7,8 @@ import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index 2ce5ad852a..2b0ecb6769 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -7,10 +7,10 @@ import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.theme.Theme; -import com.djrapitops.plan.settings.theme.ThemeVal; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.theme.Theme; +import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.AnalysisUtils; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java index 0ce1758480..7a8b208bcf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.PlayerKill; -import com.djrapitops.plan.settings.locale.Locale; -import com.djrapitops.plan.settings.locale.Msg; import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.comparators.KillDataComparator; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index 5ce1ef7ce6..411145da5c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -7,10 +7,10 @@ import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.settings.WorldAliasSettings; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.WorldAliasSettings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.comparators.SessionStartComparator; import com.djrapitops.plan.utilities.html.Html; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java index 3808ab93a9..50bb909470 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java @@ -4,8 +4,8 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.settings.locale.Message; -import com.djrapitops.plan.settings.locale.Msg; +import com.djrapitops.plan.system.settings.locale.Message; +import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.PassEncryptUtil; import com.djrapitops.plan.utilities.analysis.Point; import com.google.common.collect.Ordering; diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index 28dd993cb6..d8f4fef0e7 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -1,11 +1,11 @@ package test.utilities; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.settings.locale.Locale; 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.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.StaticHolder; @@ -121,7 +121,7 @@ public void save() { ServerProperties serverProperties = new ServerProperties(mockServer); - when(planMock.getVariable()).thenReturn(serverProperties); +// when(planMock.getVariable()).thenReturn(serverProperties); BukkitServerInfo bukkitServerInfo = PowerMockito.mock(BukkitServerInfo.class); // DataCache dataCache = new DataCache(planMock) { @@ -134,7 +134,6 @@ public void save() { when(ServerInfo.getServerUUID()).thenReturn(serverUUID); when(planMock.getServerUuid()).thenReturn(serverUUID); - when(planMock.getServerInfoManager()).thenReturn(bukkitServerInfo); ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK); when(planMock.getColorScheme()).thenReturn(cs); initLocale(null); From 0d56a731252a29c9653f03ba4dc06088f189e18b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 20:12:13 +0200 Subject: [PATCH 054/166] Fixed rest of Compile issues --- .../main/java/com/djrapitops/plan/Plan.java | 12 -- .../java/com/djrapitops/plan/PlanBungee.java | 54 +----- .../java/com/djrapitops/plan/PlanPlugin.java | 4 - .../command/commands/ListServersCommand.java | 9 +- .../command/commands/RegisterCommand.java | 8 +- .../plan/command/commands/WebUserCommand.java | 4 +- .../commands/manage/ManageSetupCommand.java | 7 +- .../commands/webuser/WebCheckCommand.java | 14 +- .../commands/webuser/WebDeleteCommand.java | 14 +- .../commands/webuser/WebListUsersCommand.java | 3 +- .../djrapitops/plan/data/PlayerProfile.java | 10 +- .../databases/operation/FetchOperations.java | 4 + .../databases/operation/SaveOperations.java | 3 + .../databases/sql/operation/SQLFetchOps.java | 27 +++ .../databases/sql/operation/SQLSaveOps.java | 10 ++ .../databases/sql/tables/ActionsTable.java | 4 +- .../databases/sql/tables/CommandUseTable.java | 8 +- .../databases/sql/tables/NicknamesTable.java | 6 +- .../databases/sql/tables/ServerTable.java | 13 +- .../databases/sql/tables/SessionsTable.java | 16 +- .../databases/sql/tables/TPSTable.java | 8 +- .../databases/sql/tables/UserInfoTable.java | 11 +- .../databases/sql/tables/WorldTable.java | 4 +- .../databases/sql/tables/WorldTimesTable.java | 4 +- .../sql/tables/move/BatchOperationTable.java | 3 +- .../tables/move/Version8TransferTable.java | 4 +- .../plan/system/info/InfoSystem.java | 10 +- .../system/info/server/BungeeServerInfo.java | 161 +++--------------- .../processors/player/NameProcessor.java | 3 +- .../plan/system/tasks/BungeeTaskSystem.java | 8 + .../webserver/pages/ServerPageHandler.java | 8 +- .../webserver/pages/parsing/InspectPage.java | 4 +- .../response/pages/DebugPageResponse.java | 41 +---- .../plan/system/webserver/webapi/WebAPI.java | 3 +- .../bungee/RequestPluginsTabWebAPI.java | 24 --- .../webapi/bungee/RequestSetupWebAPI.java | 32 +--- .../utilities/analysis/AnalysisUtils.java | 3 +- .../utilities/file/export/SpecificExport.java | 3 +- .../html/tables/PlayersTableCreator.java | 4 +- .../plan/data/cache/GeolocationCacheTest.java | 3 +- .../plan/data/cache/ResponseCacheTest.java | 20 +-- .../plan/system/database/SQLiteTest.java | 13 +- .../plan/system/webserver/WebServerTest.java | 4 +- .../plan/utilities/export/HastebinTest.java | 2 +- .../main/java/test/utilities/TestInit.java | 3 - 45 files changed, 199 insertions(+), 414 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index a45871d161..88d3bd4a88 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -24,7 +24,6 @@ import com.djrapitops.plan.system.BukkitSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.importing.ImporterManager; import com.djrapitops.plan.system.processing.importing.importers.OfflinePlayerImporter; import com.djrapitops.plan.system.settings.locale.Locale; @@ -42,8 +41,6 @@ import com.djrapitops.plugin.settings.ColorScheme; import org.bukkit.configuration.file.FileConfiguration; -import java.util.UUID; - /** * Main class for Bukkit that manages the plugin. *

    @@ -68,15 +65,6 @@ public static Plan getInstance() { return (Plan) StaticHolder.getInstance(Plan.class); } - @Deprecated - public static UUID getServerUUID() { - return ServerInfo.getServerUUID(); - } - - public UUID getServerUuid() { - return ServerInfo.getServerUUID(); - } - /** * OnEnable method. *

    diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index bd8cbee791..d063b03a53 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -8,20 +8,13 @@ import com.djrapitops.plan.system.BungeeSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.info.server.ServerProperties; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.theme.PlanColorScheme; -import com.djrapitops.plan.system.settings.theme.Theme; -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.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; @@ -29,10 +22,8 @@ import com.djrapitops.plugin.api.utility.log.DebugLog; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.settings.ColorScheme; -import com.djrapitops.plugin.task.RunnableFactory; import java.io.InputStream; -import java.util.UUID; /** * Bungee Main class. @@ -53,28 +44,14 @@ public static PlanBungee getInstance() { return (PlanBungee) StaticHolder.getInstance(PlanBungee.class); } - public static UUID getServerUUID() { - return getInstance().getServerUuid(); - } - @Override public void onEnable() { super.onEnable(); try { - FileSystem.getInstance().enable(); - ConfigSystem.getInstance().enable(); - - Log.setDebugMode(Settings.DEBUG.toString()); - - VersionCheckSystem.getInstance().enable(); - - variableHolder = new ServerProperties(getProxy()); - - new Locale().loadLocale(); - - Theme.getInstance().enable(); - DBSystem.getInstance().enable(); + system = new BungeeSystem(this); + system.enable(); + // TODO BungeeServerInfo & move there. String ip = variableHolder.getIp(); if ("0.0.0.0".equals(ip)) { Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); @@ -82,20 +59,7 @@ public void onEnable() { return; } - Benchmark.start("WebServer Initialization"); - - serverInfoManager = new BungeeServerInfo(this); - - WebServerSystem.getInstance().enable(); - serverInfoManager.loadServerInfo(); - - TaskSystem.getInstance().enable(); - - Log.logDebug("Enable", "WebServer Initialization"); Log.info(Locale.get(Msg.ENABLED).toString()); - if (Settings.ANALYSIS_EXPORT.isTrue()) { - RunnableFactory.createNew(new HtmlExport(this)).runTaskAsynchronously(); - } } catch (Exception e) { Log.error("Plugin Failed to Initialize Correctly."); Log.toLog(this.getClass().getName(), e); @@ -128,11 +92,8 @@ public Database getDB() { return DBSystem.getInstance().getActiveDatabase(); } - public BungeeServerInfo getServerInfoManager() { - return serverInfoManager; - } - @Override + @Deprecated public WebServer getWebServer() { return WebServerSystem.getInstance().getWebServer(); } @@ -147,18 +108,17 @@ public ColorScheme getColorScheme() { return PlanColorScheme.create(); } + @Deprecated public ServerProperties getVariable() { return variableHolder; } - public UUID getServerUuid() { - return serverInfoManager.getServerUUID(); - } - + @Deprecated public boolean isSetupAllowed() { return setupAllowed; } + @Deprecated public void setSetupAllowed(boolean setupAllowed) { this.setupAllowed = setupAllowed; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index f1bafd915c..3659b6a167 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -12,7 +12,6 @@ import java.io.File; import java.io.InputStream; -import java.util.UUID; /** * Abstraction interface for both Plan and PlanBungee. @@ -36,9 +35,6 @@ static PlanPlugin getInstance() { @Deprecated Database getDB(); - @Deprecated - UUID getServerUuid(); - @Deprecated WebServer getWebServer(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java index d80c79e2a9..3bb90dc94a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ListServersCommand.java @@ -1,6 +1,8 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -10,7 +12,6 @@ import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.settings.ColorScheme; -import java.sql.SQLException; import java.util.Map; /** @@ -45,13 +46,13 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { String tCol = colorScheme.getTertiaryColor(); try { sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString() + mCol + " Servers"); - Map serverNames = plugin.getDB().getServerTable().getServerNamesByID(); + Map serverNames = Database.getActive().fetch().getServerNamesByID(); for (Map.Entry entry : serverNames.entrySet()) { sender.sendMessage(" " + tCol + entry.getKey() + sCol + " : " + entry.getValue()); } sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); - } catch (SQLException e) { - sender.sendMessage("§cSQLException occurred."); + } catch (DBException e) { + sender.sendMessage("§cDatabase Exception occurred."); Log.toLog(this.getClass().getName(), e); } return true; diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index 0821154007..74f32c9c52 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -121,12 +121,12 @@ public void run() { final String userName = webUser.getName(); final String successMsg = "§aAdded a new user (" + userName + ") successfully!"; try { - SecurityTable securityTable = plugin.getDB().getSecurityTable(); - boolean userExists = securityTable.userExists(userName); + Database database = Database.getActive(); + boolean userExists = database.check().doesWebUserExists(userName); if (!Condition.isTrue(!userExists, existsMsg, sender)) { return; } - securityTable.addNewUser(webUser); + database.save().webUser(webUser); sender.sendMessage(successMsg); Log.info("Registered new user: " + userName + " Perm level: " + webUser.getPermLevel()); } catch (Exception e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java index 3c3915338f..5119c40d17 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java @@ -50,8 +50,8 @@ public void addCommands() { add( new WebLevelCommand(plugin), new WebListUsersCommand(plugin), - new WebCheckCommand(plugin), - new WebDeleteCommand(plugin) + new WebCheckCommand(), + new WebDeleteCommand() ); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 849d7e65b7..c024a40e91 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -3,11 +3,11 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.connection.ForbiddenException; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; -import com.djrapitops.plan.system.webserver.webapi.bungee.RequestSetupWebAPI; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; @@ -66,8 +66,9 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { try { Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.set(false); Settings.BUNGEE_COPY_CONFIG.set(true); -// plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class).sendRequest(address); - plugin.getWebServer().getWebAPI().getAPI(RequestSetupWebAPI.class).sendRequest(address); + + InfoSystem.getInstance().requestSetUp(address); + sender.sendMessage("§eConnection successful, Plan may restart in a few seconds, if it doesn't something has gone wrong."); } catch (ForbiddenException e) { sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it."); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java index b15f42188e..73c0c38bcc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebCheckCommand.java @@ -1,8 +1,7 @@ package com.djrapitops.plan.command.commands.webuser; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -23,15 +22,12 @@ */ public class WebCheckCommand extends SubCommand { - private final PlanPlugin plugin; - - public WebCheckCommand(PlanPlugin plugin) { + public WebCheckCommand() { super("check", CommandType.PLAYER_OR_ARGS, Permissions.MANAGE_WEB.getPerm(), Locale.get(Msg.CMD_USG_WEB_CHECK).toString(), ""); - this.plugin = plugin; } @Override @@ -39,17 +35,17 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " ", sender)) { return true; } - SecurityTable table = plugin.getDB().getSecurityTable(); + Database database = Database.getActive(); String user = args[0]; RunnableFactory.createNew(new AbsRunnable("Webuser Check Task: " + user) { @Override public void run() { try { - if (!Condition.isTrue(table.userExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) { + if (!Condition.isTrue(database.check().doesWebUserExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) { return; } - WebUser info = table.getWebUser(user); + WebUser info = database.fetch().getWebUser(user); sender.sendMessage(info.getName() + ": Permission level: " + info.getPermLevel()); } catch (Exception ex) { Log.toLog(this.getClass().getName(), ex); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java index 3a9d0602de..bc5ff8dc1f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebDeleteCommand.java @@ -1,7 +1,6 @@ package com.djrapitops.plan.command.commands.webuser; -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.system.database.databases.sql.tables.SecurityTable; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -22,15 +21,12 @@ */ public class WebDeleteCommand extends SubCommand { - private final PlanPlugin plugin; - - public WebDeleteCommand(PlanPlugin plugin) { + public WebDeleteCommand() { super("delete, remove", CommandType.PLAYER_OR_ARGS, Permissions.MANAGE_WEB.getPerm(), Locale.get(Msg.CMD_USG_WEB_DELETE).toString(), ""); - this.plugin = plugin; } @Override @@ -38,17 +34,17 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " ", sender)) { return true; } - SecurityTable table = plugin.getDB().getSecurityTable(); + Database database = Database.getActive(); String user = args[0]; RunnableFactory.createNew(new AbsRunnable("Webuser Delete Task: " + user) { @Override public void run() { try { - if (!Condition.isTrue(table.userExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) { + if (!Condition.isTrue(database.check().doesWebUserExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) { return; } - table.removeUser(user); + database.remove().webUser(user); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_SUCCESS).parse()); } catch (Exception ex) { Log.toLog(this.getClass().getName(), ex); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java index f86d42e219..a640678287 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/webuser/WebListUsersCommand.java @@ -2,6 +2,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -39,7 +40,7 @@ public void run() { try { ColorScheme cs = plugin.getColorScheme(); String mCol = cs.getMainColor(); - List users = plugin.getDB().getSecurityTable().getUsers(); + List users = Database.getActive().fetch().getWebUsers(); users.sort(new WebUserComparator()); sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).parse() + mCol + " WebUsers (" + users.size() + ")"); for (WebUser user : users) { diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index e6887b00a5..6a41170914 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -4,13 +4,13 @@ */ package com.djrapitops.plan.data; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.WorldTimes; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.comparators.ActionComparator; import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; @@ -335,7 +335,7 @@ public void setSessions(UUID serverUUID, List sessions) { } public void addActiveSession(Session activeSession) { - UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); + UUID serverUUID = ServerInfo.getServerUUID(); List sessions = getSessions(serverUUID); sessions.add(activeSession); this.sessions.put(serverUUID, sessions); @@ -478,7 +478,7 @@ public long getFirstPlayed() { @Override public long getLastPlayed() { - return getLastSeen(PlanPlugin.getInstance().getServerUuid()); + return getLastSeen(ServerInfo.getServerUUID()); } @Override @@ -498,7 +498,7 @@ public Map serialize() { @Override public boolean isOp() { - return oppedOnServers.contains(PlanPlugin.getInstance().getServerUuid()); + return oppedOnServers.contains(ServerInfo.getServerUUID()); } @Override @@ -507,7 +507,7 @@ public void setOp(boolean b) { } public void calculateWorldTimesPerServer() { - if (worldTimesMap.containsKey(PlanPlugin.getInstance().getServerUuid())) { + if (worldTimesMap.containsKey(ServerInfo.getServerUUID())) { return; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java index 5ea8cfa1e3..d768c2ca8a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/FetchOperations.java @@ -78,4 +78,8 @@ public interface FetchOperations { List getNicknames(UUID uuid) throws DBException; Map getBukkitServers() throws DBException; + + List getWebUsers() throws DBException; + + Map getServerNamesByID() throws DBException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java index 1a317efd6e..29c3ff5a83 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/SaveOperations.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.database.databases.operation; import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.info.server.Server; @@ -67,4 +68,6 @@ void insertSessions(Map>> ofServers, boolean conta void session(UUID uuid, Session session) throws DBException; void serverInfoForThisServer(Server server) throws DBException; + + void webUser(WebUser webUser) throws DBException; } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java index a9b32d2c62..adbb863586 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java @@ -361,4 +361,31 @@ public Optional getServerID(UUID serverUUID) throws DBException { throw SQLErrorUtil.getExceptionFor(e); } } + + @Override + public Map getBukkitServers() throws DBException { + try { + return serverTable.getBukkitServers(); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public List getWebUsers() throws DBException { + try { + return securityTable.getUsers(); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } + + @Override + public Map getServerNamesByID() throws DBException { + try { + return serverTable.getServerNamesByID(); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java index bbb572873a..45b93514ef 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLSaveOps.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.database.databases.sql.operation; import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.container.*; import com.djrapitops.plan.system.database.databases.operation.SaveOperations; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -214,4 +215,13 @@ public void serverInfoForThisServer(Server server) throws DBException { throw SQLErrorUtil.getExceptionFor(e); } } + + @Override + public void webUser(WebUser webUser) throws DBException { + try { + securityTable.addNewUser(webUser); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java index cfa90bc73b..c8b04d53ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; @@ -15,6 +14,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Select; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -86,7 +86,7 @@ public void insertAction(UUID uuid, Action action) throws SQLException { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, uuid.toString()); - statement.setString(2, Plan.getServerUUID().toString()); + statement.setString(2, ServerInfo.getServerUUID().toString()); statement.setInt(3, action.getDoneAction().getId()); statement.setLong(4, action.getDate()); statement.setString(5, action.getAdditionalInfo()); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java index 5303d4a49f..1f82493d09 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -9,6 +8,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Select; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.info.server.ServerInfo; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -62,7 +62,7 @@ public void createTable() throws DBCreateTableException { * @throws SQLException DB Error */ public Map getCommandUse() throws SQLException { - return getCommandUse(Plan.getServerUUID()); + return getCommandUse(ServerInfo.getServerUUID()); } /** @@ -110,7 +110,7 @@ public void commandUsed(String command) throws SQLException { boolean updated = execute(new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, Plan.getServerUUID().toString()); + statement.setString(1, ServerInfo.getServerUUID().toString()); statement.setString(2, command); } }); @@ -125,7 +125,7 @@ private void insertCommand(String command) throws SQLException { public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, command); statement.setInt(2, 1); - statement.setString(3, Plan.getServerUUID().toString()); + statement.setString(3, ServerInfo.getServerUUID().toString()); } }); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java index 76c4bc1e1c..5ad84c5a47 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -8,6 +7,7 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -104,7 +104,7 @@ public Map> processResults(ResultSet set) throws SQLException * @throws SQLException when an error at retrieval happens */ public List getNicknames(UUID uuid) throws SQLException { - return getNicknames(uuid, Plan.getServerUUID()); + return getNicknames(uuid, ServerInfo.getServerUUID()); } /** @@ -156,7 +156,7 @@ public void saveUserName(UUID uuid, String displayName) throws SQLException { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, uuid.toString()); - statement.setString(2, Plan.getServerUUID().toString()); + statement.setString(2, ServerInfo.getServerUUID().toString()); statement.setString(3, displayName); } }); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java index 9f2f27c9aa..15a41f0f11 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java @@ -280,24 +280,25 @@ public Optional processResults(ResultSet set) throws SQLException { }); } - public List getBukkitServers() throws SQLException { + public Map getBukkitServers() throws SQLException { String sql = Select.from(tableName, "*") .where(columnServerName + "!=?") .toString(); - return query(new QueryStatement>(sql, 100) { + return query(new QueryStatement>(sql, 100) { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, "BungeeCord"); } @Override - public List processResults(ResultSet set) throws SQLException { - List servers = new ArrayList<>(); + public Map processResults(ResultSet set) throws SQLException { + Map servers = new HashMap<>(); while (set.next()) { - servers.add(new Server( + UUID serverUUID = UUID.fromString(set.getString(columnServerUUID)); + servers.put(serverUUID, new Server( set.getInt(columnServerID), - UUID.fromString(set.getString(columnServerUUID)), + serverUUID, set.getString(columnServerName), set.getString(columnWebserverAddress), set.getInt(columnMaxPlayers))); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java index a454d192dd..b1c15cd2dc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -10,6 +9,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Select; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -105,7 +105,7 @@ public void prepare(PreparedStatement statement) throws SQLException { statement.setLong(3, session.getSessionEnd()); statement.setInt(4, session.getDeaths()); statement.setInt(5, session.getMobKills()); - statement.setString(6, Plan.getServerUUID().toString()); + statement.setString(6, ServerInfo.getServerUUID().toString()); } }); } @@ -204,7 +204,7 @@ public Map> getSessions(UUID uuid) throws SQLException { * @throws SQLException DB Error */ public long getPlaytime(UUID uuid) throws SQLException { - return getPlaytime(uuid, Plan.getServerUUID()); + return getPlaytime(uuid, ServerInfo.getServerUUID()); } /** @@ -216,7 +216,7 @@ public long getPlaytime(UUID uuid) throws SQLException { * @throws SQLException DB Error */ public long getPlaytime(UUID uuid, long afterDate) throws SQLException { - return getPlaytime(uuid, Plan.getServerUUID(), afterDate); + return getPlaytime(uuid, ServerInfo.getServerUUID(), afterDate); } /** @@ -321,7 +321,7 @@ public Map processResults(ResultSet set) throws SQLException { * @throws SQLException DB Error */ public long getPlaytimeOfServer() throws SQLException { - return getPlaytimeOfServer(Plan.getServerUUID()); + return getPlaytimeOfServer(ServerInfo.getServerUUID()); } /** @@ -343,7 +343,7 @@ public long getPlaytimeOfServer(UUID serverUUID) throws SQLException { * @throws SQLException DB Error */ public long getPlaytimeOfServer(long afterDate) throws SQLException { - return getPlaytimeOfServer(Plan.getServerUUID(), afterDate); + return getPlaytimeOfServer(ServerInfo.getServerUUID(), afterDate); } /** @@ -398,7 +398,7 @@ public int getSessionCount(UUID uuid) throws SQLException { * @throws SQLException DB Error */ public int getSessionCount(UUID uuid, long afterDate) throws SQLException { - return getSessionCount(uuid, Plan.getServerUUID(), afterDate); + return getSessionCount(uuid, ServerInfo.getServerUUID(), afterDate); } /** @@ -453,7 +453,7 @@ public String getColumnID() { } public Map> getSessionInfoOfServer() throws SQLException { - return getSessionInfoOfServer(Plan.getServerUUID()); + return getSessionInfoOfServer(ServerInfo.getServerUUID()); } public Map> getSessionInfoOfServer(UUID serverUUID) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java index 28281bcf17..aed83bb46d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -11,6 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.utilities.Verify; @@ -77,7 +77,7 @@ public void createTable() throws DBCreateTableException { * @return @throws SQLException */ public List getTPSData() throws SQLException { - return getTPSData(PlanPlugin.getInstance().getServerUuid()); + return getTPSData(ServerInfo.getServerUUID()); } public List getTPSData(UUID serverUUID) throws SQLException { @@ -113,7 +113,7 @@ public void insertTPS(TPS tps) throws SQLException { execute(new ExecStatement(insertStatement) { @Override public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, PlanPlugin.getInstance().getServerUuid().toString()); + statement.setString(1, ServerInfo.getServerUUID().toString()); statement.setLong(2, tps.getDate()); statement.setDouble(3, tps.getTicksPerSecond()); statement.setInt(4, tps.getPlayers()); @@ -163,7 +163,7 @@ public Optional getAllTimePeak() throws SQLException { } public Optional getPeakPlayerCount(long afterDate) throws SQLException { - return getPeakPlayerCount(PlanPlugin.getInstance().getServerUuid(), afterDate); + return getPeakPlayerCount(ServerInfo.getServerUUID(), afterDate); } public Optional getPeakPlayerCount(UUID serverUUID, long afterDate) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java index 9a1804aaec..d836baa9f5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java @@ -4,8 +4,6 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -16,6 +14,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; import com.djrapitops.plan.system.database.databases.sql.statements.Update; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -76,13 +75,13 @@ public void registerUserInfo(UUID uuid, long registered) throws SQLException { public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, uuid.toString()); statement.setLong(2, registered); - statement.setString(3, Plan.getServerUUID().toString()); + statement.setString(3, ServerInfo.getServerUUID().toString()); } }); } public boolean isRegistered(UUID uuid) throws SQLException { - return isRegistered(uuid, PlanPlugin.getInstance().getServerUuid()); + return isRegistered(uuid, ServerInfo.getServerUUID()); } public boolean isRegistered(UUID uuid, UUID serverUUID) throws SQLException { @@ -134,7 +133,7 @@ public void prepare(PreparedStatement statement) throws SQLException { } public UserInfo getUserInfo(UUID uuid) throws SQLException { - return getAllUserInfo(uuid).get(PlanPlugin.getInstance().getServerUuid()); + return getAllUserInfo(uuid).get(ServerInfo.getServerUUID()); } public Map getAllUserInfo(UUID uuid) throws SQLException { @@ -182,7 +181,7 @@ public Map processResults(ResultSet set) throws SQLException { * @return List of UserInfo objects. */ public List getServerUserInfo() throws SQLException { - return getServerUserInfo(Plan.getServerUUID()); + return getServerUserInfo(ServerInfo.getServerUUID()); } public List getServerUserInfo(UUID serverUUID) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java index c913d0c8cc..9de92e2b99 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -8,6 +7,7 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -108,7 +108,7 @@ public String getColumnWorldName() { } public Set getWorldNames() throws SQLException { - return getWorldNames(PlanPlugin.getInstance().getServerUuid()); + return getWorldNames(ServerInfo.getServerUUID()); } public Set getWorldNames(UUID serverUUID) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java index 98e93cbef9..e3a0140b90 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.GMTimes; @@ -11,6 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; import com.djrapitops.plan.system.database.databases.sql.statements.Sql; import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; @@ -152,7 +152,7 @@ public Object processResults(ResultSet set) throws SQLException { } public WorldTimes getWorldTimesOfServer() throws SQLException { - return getWorldTimesOfServer(Plan.getServerUUID()); + return getWorldTimesOfServer(ServerInfo.getServerUUID()); } public WorldTimes getWorldTimesOfServer(UUID serverUUID) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java index be4fa34f2a..2c1860a452 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/BatchOperationTable.java @@ -14,6 +14,7 @@ import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; @@ -140,7 +141,7 @@ public void copyServers(BatchOperationTable toDB) throws SQLException { } Log.debug("Batch Copy Servers"); ServerTable serverTable = db.getServerTable(); - List servers = serverTable.getBukkitServers(); + List servers = new ArrayList<>(serverTable.getBukkitServers().values()); serverTable.getBungeeInfo().ifPresent(servers::add); toDB.getDb().getServerTable().insertAllServers(servers); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java index ae7d382432..3bf1ba7486 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java @@ -4,10 +4,10 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables.move; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.Benchmark; import java.sql.SQLException; @@ -26,7 +26,7 @@ public class Version8TransferTable extends Table { public Version8TransferTable(SQLDB db) throws SQLException { super("", db); - Optional serverID = db.getServerTable().getServerID(Plan.getServerUUID()); + Optional serverID = db.getServerTable().getServerID(ServerInfo.getServerUUID()); if (!serverID.isPresent()) { throw new IllegalStateException("Server UUID was not registered, try rebooting the plugin."); } 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 f71c7b8f0e..1b7666f6b6 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 @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.system.info; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.PlanSystem; @@ -13,6 +12,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.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.log.Log; @@ -44,12 +44,12 @@ public void generateAndCachePlayerPage(UUID player) throws WebException { } public void generateAnalysisPageOfThisServer() throws WebException { - generateAnalysisPage(Plan.getServerUUID()); + generateAnalysisPage(ServerInfo.getServerUUID()); } public void generateAnalysisPage(UUID serverUUID) throws WebException { GenerateAnalysisPageRequest request = new GenerateAnalysisPageRequest(serverUUID); - if (Plan.getServerUUID().equals(serverUUID)) { + if (ServerInfo.getServerUUID().equals(serverUUID)) { runLocally(request); } else { sendRequest(request); @@ -86,4 +86,8 @@ public ConnectionSystem getConnectionSystem() { } public abstract void updateNetworkPage() throws WebException; + + public void requestSetUp(String address) { + // TODO + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java index 57c144e887..bfc1f08d87 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java @@ -6,18 +6,12 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.api.exceptions.EnableException; -import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable; -import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI; -import com.djrapitops.plugin.api.TimeAmount; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.task.AbsRunnable; -import com.djrapitops.plugin.task.RunnableFactory; +import com.djrapitops.plan.system.webserver.WebServerSystem; -import java.sql.SQLException; -import java.util.*; -import java.util.stream.Collectors; +import java.util.Optional; +import java.util.UUID; /** * Manages Server information on the Bungee instance. @@ -26,158 +20,47 @@ */ public class BungeeServerInfo extends ServerInfo { - private final PlanBungee plugin; - private final Database db; - private final Map bukkitServers; - private final Set onlineServers; - private Server server; - private ServerTable serverTable; - public BungeeServerInfo(PlanBungee plugin) { - this.plugin = plugin; - this.db = plugin.getDB(); - serverTable = db.getServerTable(); - - bukkitServers = new HashMap<>(); - onlineServers = new HashSet<>(); + serverProperties = new ServerProperties(plugin.getProxy()); } - public void loadServerInfo() throws EnableException { + public Server loadServerInfo() throws EnableException { try { - Optional bungeeInfo = db.getServerTable().getBungeeInfo(); + Database db = Database.getActive(); + Optional bungeeInfo = db.fetch().getBungeeInformation(); if (bungeeInfo.isPresent()) { server = bungeeInfo.get(); - String accessAddress = plugin.getWebServer().getAccessAddress(); + String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); if (!accessAddress.equals(server.getWebAddress())) { server.setWebAddress(accessAddress); - serverTable.saveCurrentServerInfo(server); + db.save().serverInfoForThisServer(server); } } else { - server = registerBungeeInfo(); + server = registerBungeeInfo(db); } - } catch (SQLException e) { + } catch (DBException e) { throw new EnableException("Failed to read Database for Server"); } + return null; } - private Server registerBungeeInfo() throws SQLException, EnableException { - ServerProperties variable = plugin.getVariable(); - UUID serverUUID = generateNewUUID(variable); - String accessAddress = plugin.getWebServer().getAccessAddress(); + private Server registerBungeeInfo(Database db) throws DBException, EnableException { + ServerProperties properties = ServerInfo.getServerProperties(); + UUID serverUUID = generateNewUUID(properties); + String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); - serverTable.saveCurrentServerInfo( - new Server(-1, serverUUID, "BungeeCord", accessAddress, variable.getMaxPlayers()) - ); + Server bungeeCord = new Server(-1, serverUUID, "BungeeCord", accessAddress, properties.getMaxPlayers()); + db.save().serverInfoForThisServer(bungeeCord); - Optional bungeeInfo = db.getServerTable().getBungeeInfo(); + Optional bungeeInfo = db.fetch().getBungeeInformation(); if (bungeeInfo.isPresent()) { return bungeeInfo.get(); } throw new EnableException("BungeeCord registration failed (DB)"); } - private UUID generateNewUUID(ServerProperties variableHolder) { - String seed = variableHolder.getName() + variableHolder.getIp() + variableHolder.getPort() + variableHolder.getVersion() + variableHolder.getImplVersion(); + private UUID generateNewUUID(ServerProperties properties) { + String seed = properties.getName() + properties.getIp() + properties.getPort() + properties.getVersion() + properties.getImplVersion(); return UUID.nameUUIDFromBytes(seed.getBytes()); } - - public UUID getServerUUID() { - return server.getUuid(); - } - - public boolean attemptConnection(Server server, String accessCode) { - if (server == null) { - Log.debug("Attempted a connection to a null Server"); - return false; - } - try { - String webAddress = server.getWebAddress(); - Log.debug("Attempting to connect to Bukkit server.. (" + webAddress + ")"); - plugin.getWebServer().getWebAPI().getAPI(ConfigurationWebAPI.class).sendRequest(webAddress, server.getUuid(), accessCode); - connectedToServer(server); - return true; - } catch (WebException e) { - Log.debug(e.toString()); - serverHasGoneOffline(server.getUuid()); - return false; - } - } - - public boolean attemptConnection(Server server) { - return attemptConnection(server, null); - } - - public void sendConfigSettings(UUID serverUUID) { - String webAddress = null; - try { - Server server = bukkitServers.get(serverUUID); - if (server == null) { - return; - } - webAddress = server.getWebAddress(); - Log.debug("Sending config settings to " + webAddress + ""); - plugin.getWebServer().getWebAPI().getAPI(ConfigurationWebAPI.class).sendRequest(webAddress, serverUUID); - } catch (WebException e) { - Log.info("Connection to Bukkit (" + webAddress + ") did not succeed."); - serverHasGoneOffline(serverUUID); - } - } - - public void connectedToServer(Server server) { - Log.info("Connection to Bukkit (" + server.getWebAddress() + ") OK"); - bukkitServers.put(server.getUuid(), server); - onlineServers.add(server.getUuid()); - } - - public boolean serverConnected(UUID serverUUID) { - if (plugin.getServerUuid().equals(serverUUID)) { - return false; - } - Log.info("Received a connection from a Bukkit server.."); - if (onlineServers.contains(serverUUID)) { - RunnableFactory.createNew("BukkitRebootedConnectionTask: " + serverUUID, new AbsRunnable() { - @Override - public void run() { - sendConfigSettings(serverUUID); - connectedToServer(bukkitServers.get(serverUUID)); - this.cancel(); - } - }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 3L); - return true; - } - try { - Optional serverInfo = db.getServerTable().getServerInfo(serverUUID); - if (serverInfo.isPresent()) { - Server server = serverInfo.get(); - Log.info("Server Info found from DB: " + server.getName()); - RunnableFactory.createNew("BukkitConnectionTask: " + server.getName(), new AbsRunnable() { - @Override - public void run() { - attemptConnection(server); - sendConfigSettings(serverUUID); - this.cancel(); - } - }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 3L); - return true; - } - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } - return false; - } - - public Collection getOnlineBukkitServers() { - return bukkitServers.entrySet().stream() - .filter(entry -> onlineServers.contains(entry.getKey())) - .map(Map.Entry::getValue) - .collect(Collectors.toSet()); - } - - public Collection getBukkitServers() { - return bukkitServers.values(); - } - - public void serverHasGoneOffline(UUID serverUUID) { - onlineServers.remove(serverUUID); - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java index fa4b7f5635..708595e228 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor; import com.djrapitops.plugin.api.utility.log.Log; @@ -59,7 +60,7 @@ public void process() { } private void cueNameChangeActionProcessor(UUID uuid, Database db) throws DBException { - List nicknames = db.fetch().getNicknamesOfPlayerOnServer(uuid, Plan.getServerUUID()); + List nicknames = db.fetch().getNicknamesOfPlayerOnServer(uuid, ServerInfo.getServerUUID()); if (nicknames.contains(displayName)) { return; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java index 9140ea0964..bd71063fdb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java @@ -5,9 +5,11 @@ package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.tasks.bukkit.NetworkPageRefreshTask; import com.djrapitops.plan.system.tasks.bungee.BungeeTPSCountTimer; import com.djrapitops.plan.system.tasks.bungee.EnableConnectionTask; +import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.api.TimeAmount; /** @@ -17,8 +19,11 @@ */ public class BungeeTaskSystem extends TaskSystem { + private final PlanBungee plugin; + public BungeeTaskSystem(PlanBungee plugin) { tpsCountTimer = new BungeeTPSCountTimer(plugin); + this.plugin = plugin; } @Override @@ -30,5 +35,8 @@ private void registerTasks() { registerTask(new EnableConnectionTask()).runTaskAsynchronously(); registerTask(tpsCountTimer).runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks()); registerTask(new NetworkPageRefreshTask()).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks()); + if (Settings.ANALYSIS_EXPORT.isTrue()) { + registerTask(new HtmlExport(plugin)).runTaskAsynchronously(); + } } } \ No newline at end of file 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 294245e783..6ae0579530 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 @@ -4,15 +4,17 @@ */ package com.djrapitops.plan.system.webserver.pages; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; 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.plugin.api.utility.log.Log; import java.util.List; import java.util.Optional; @@ -32,7 +34,7 @@ public Response getResponse(Request request, List target) { } private UUID getServerUUID(List target) { - UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); + UUID serverUUID = ServerInfo.getServerUUID(); if (!target.isEmpty()) { try { String serverName = target.get(0).replace("%20", " "); @@ -42,6 +44,8 @@ private UUID getServerUUID(List target) { } } catch (IllegalArgumentException ignore) { /*ignored*/ + } catch (DBException e) { + Log.toLog(this.getClass(), e); } } return serverUUID; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java index 19914b6877..f63ce00dc2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.system.webserver.pages.parsing; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Action; @@ -14,6 +13,7 @@ import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.settings.theme.ThemeVal; @@ -66,7 +66,7 @@ public String toHtml() throws ParseException { if (profile == null) { throw new IllegalStateException("Player profile was null!"); } - UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); + UUID serverUUID = ServerInfo.getServerUUID(); Map serverNames = db.fetch().getServerNames(); Benchmark.stop("Inspect Parse, Fetch"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index a1f7637364..4e6fa77eb9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -4,12 +4,10 @@ */ package com.djrapitops.plan.system.webserver.response.pages; -import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.info.connection.ConnectionLog; -import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerProperties; @@ -18,7 +16,6 @@ import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.ErrorLogger; import com.djrapitops.plugin.api.utility.log.Log; @@ -57,11 +54,6 @@ private String buildParagraph() { appendServerInformation(content); appendConnectionLog(content); - - if (Check.isBungeeAvailable()) { - appendBungeeConfiguration(content); - } - appendLoggedErrors(content); appendDebugLog(content); appendBenchmarks(content); @@ -75,7 +67,7 @@ private void appendConnectionLog(StringBuilder content) { Map> logEntries = ConnectionLog.getLogEntries(); content.append("

    ");
    -            content.append("Server name | Request Type | Sent | Response
    ") + content.append("Server Address | Request Type | Sent | Response
    ") .append("-- | -- | -- | --
    "); for (Map.Entry> entry : logEntries.entrySet()) { Server server = entry.getKey(); @@ -84,7 +76,7 @@ private void appendConnectionLog(StringBuilder content) { String infoRequest = requestEntry.getKey(); ConnectionLog.Entry logEntry = requestEntry.getValue(); - content.append(server.getName()).append(" | ") + content.append(server.getWebAddress()).append(" | ") .append(infoRequest).append(" | ") .append(logEntry.getResponseCode()).append(" | ") .append(FormatUtils.formatTimeStampSecond(logEntry.getTimeSent())).append("
    "); @@ -165,35 +157,6 @@ private void appendConfig(StringBuilder content) { } } - private void appendBungeeConfiguration(StringBuilder content) { - - PlanBungee plugin = PlanBungee.getInstance(); - BungeeServerInfo serverInfoManager = plugin.getServerInfoManager(); - Collection online = serverInfoManager.getOnlineBukkitServers(); - Collection bukkitServers = serverInfoManager.getBukkitServers(); - - if (!bukkitServers.isEmpty()) { - content.append("

    If your issue is about Bungee-Bukkit connection relations, please include the following debug information of available servers as well:

    "); - for (Server info : bukkitServers) { - String link = Html.LINK.parse(info.getWebAddress() + "/debug", info.getWebAddress() + "/debug"); - content.append("

    ").append(link).append("

    "); - } - } - - content.append("
    ### Bungee Configuration
    "); - - content.append("Server name | Online | Address | UUID
    ") - .append("-- | -- | -- | --
    "); - for (Server info : bukkitServers) { - content.append(info.getName()).append(" | ") - .append(online.contains(info) ? "Online" : "Offline").append(" | ") - .append(info.getWebAddress()).append(" | ") - .append(info.getUuid()).append("
    "); - } - - content.append("
    "); - } - private void appendBenchmarks(StringBuilder content) { content.append("
    ### Benchmarks
    ```
    "); try { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index 7261b40353..218aa20eee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.*; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; @@ -192,7 +193,7 @@ protected Response badRequest(String error) { private String parseVariables() { StringBuilder parameters = new StringBuilder(); - String serverUUID = PlanPlugin.getInstance().getServerUuid().toString(); + String serverUUID = ServerInfo.getServerUUID().toString(); parameters.append("sender=").append(serverUUID); for (Map.Entry entry : variables.entrySet()) { parameters.append(";&variable;").append(entry.getKey()).append("=").append(entry.getValue()); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java index a39a66120d..9fddbc5d3e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java @@ -6,16 +6,10 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.info.server.Server; -import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI; import com.djrapitops.plugin.api.Check; -import com.djrapitops.plugin.api.utility.log.Log; -import java.sql.SQLException; -import java.util.List; import java.util.Map; import java.util.UUID; @@ -58,23 +52,5 @@ public void sendRequest(String address, UUID uuid) throws WebException { } public void sendRequestsToBukkitServers(PlanPlugin plugin, UUID uuid) { - new Processor(uuid) { - @Override - public void process() { - try { - List bukkitServers = plugin.getDB().getServerTable().getBukkitServers(); - for (Server server : bukkitServers) { - String webAddress = server.getWebAddress(); - try { - plugin.getWebServer().getWebAPI().getAPI(RequestInspectPluginsTabBukkitWebAPI.class).sendRequest(webAddress, uuid); - } catch (WebException ignore) { - /* ignored */ - } - } - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } - } - }.queue(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java index 9d898a6510..d62d996330 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java @@ -4,49 +4,26 @@ */ package com.djrapitops.plan.system.webserver.webapi.bungee; - import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.utilities.Verify; import java.util.Map; -import java.util.UUID; /** * //TODO Class Javadoc Comment * * @author Rsl1122 */ +@Deprecated public class RequestSetupWebAPI extends WebAPI { @Override public Response onRequest(PlanPlugin plugin, Map variables) { - if (!Check.isBungeeAvailable()) { - return badRequest("Called a Bukkit server."); - } - - if (!((PlanBungee) plugin).isSetupAllowed()) { - return new ForbiddenResponse("Setup mode disabled, use /planbungee setup to enable"); - } - - String serverUUIDS = variables.get("sender"); - String webAddress = variables.get("webAddress"); - String accessCode = variables.get("accessKey"); - if (!Verify.notNull(serverUUIDS, webAddress, accessCode)) { - return badRequest("Variable was null"); - } - Server server = new Server(-1, UUID.fromString(serverUUIDS), "", webAddress, 0); - - ((PlanBungee) plugin).getServerInfoManager().attemptConnection(server, accessCode); - return success(); + return fail("Deprecated"); } @Override @@ -56,11 +33,6 @@ public void sendRequest(String address) throws WebException { } Plan plugin = Plan.getInstance(); - try { - addVariable("accessKey", plugin.getWebServer().getWebAPI().generateNewAccessKey()); - } catch (Exception e) { - Log.toLog(this.getClass().getName(), e); - } addVariable("webAddress", plugin.getWebServer().getAccessAddress()); super.sendRequest(address); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index f9e8c6c728..e2afd52e91 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -9,6 +9,7 @@ import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -142,7 +143,7 @@ public static void addMissingWorlds(WorldTimes worldTimes) { // Add 0 time for worlds not present. Set nonZeroWorlds = worldTimes.getWorldTimes().keySet(); PlanPlugin plugin = PlanPlugin.getInstance(); - for (String world : Database.getActive().fetch().getWorldNames(plugin.getServerUuid())) { + for (String world : Database.getActive().fetch().getWorldNames(ServerInfo.getServerUUID())) { if (nonZeroWorlds.contains(world)) { continue; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index 6076f990f8..9119838e60 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.utilities.file.export; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.PageId; @@ -104,7 +105,7 @@ protected void exportAvailableServerPage(UUID serverUUID, String serverName) thr File htmlLocation = null; if (usingBungee) { - if (serverUUID.equals(PlanPlugin.getInstance().getServerUuid())) { + if (serverUUID.equals(ServerInfo.getServerUUID())) { htmlLocation = new File(outputFolder, "network"); } else { htmlLocation = new File(getServerFolder(), serverName.replace(" ", "%20").replace(".", "%2E")); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java index 3ef3763fee..855a1e5303 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java @@ -1,12 +1,12 @@ package com.djrapitops.plan.utilities.html.tables; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; @@ -37,7 +37,7 @@ public static String createTable(List players) { StringBuilder html = new StringBuilder(); long now = MiscUtils.getTime(); - UUID serverUUID = PlanPlugin.getInstance().getServerUuid(); + UUID serverUUID = ServerInfo.getServerUUID(); int i = 0; int maxPlayers = Settings.MAX_PLAYERS.getNumber(); diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java index 95b58a9e73..2f15f4516e 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java @@ -1,5 +1,6 @@ package com.djrapitops.plan.data.cache; +import com.djrapitops.plan.system.cache.CacheSystem; import com.djrapitops.plan.system.cache.GeolocationCache; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; @@ -26,7 +27,7 @@ public class GeolocationCacheTest { @Before public void setUp() throws Exception { TestInit.init(); - GeolocationCache.clearCache(); + CacheSystem.getInstance().getGeolocationCache().clearCache(); ipsToCountries.put("8.8.8.8", "United States"); ipsToCountries.put("8.8.4.4", "United States"); diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java b/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java index 8a418248b2..5df25db015 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java @@ -1,7 +1,6 @@ package com.djrapitops.plan.data.cache; import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.response.cache.PageLoader; import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; import org.junit.Test; import test.utilities.RandomData; @@ -20,31 +19,20 @@ public String getResponse() { return RESPONSE_STRING; } }; - private final PageLoader LOADER = () -> RESPONSE; - - @Test - public void testCreateResponse() { - String expResponse = RESPONSE.getResponse(); - String response = LOADER.createResponse().getResponse(); - - assertEquals(expResponse, response); - } @Test public void testCache() { - Response expResponse = LOADER.createResponse(); - assertFalse(ResponseCache.isCached(IDENTIFIER)); - Response response = ResponseCache.loadResponse(IDENTIFIER, LOADER); + Response response = ResponseCache.loadResponse(IDENTIFIER, () -> RESPONSE); assertTrue(ResponseCache.isCached(IDENTIFIER)); - assertEquals(expResponse, response); + assertEquals(RESPONSE, response); } @Test public void testClearCache() { - ResponseCache.cacheResponse(IDENTIFIER, LOADER); + ResponseCache.cacheResponse(IDENTIFIER, () -> RESPONSE); assertTrue(ResponseCache.isCached(IDENTIFIER)); ResponseCache.clearCache(); @@ -53,7 +41,7 @@ public void testClearCache() { @Test public void testRemoveIf() { - ResponseCache.cacheResponse(IDENTIFIER, LOADER); + ResponseCache.cacheResponse(IDENTIFIER, () -> RESPONSE); assertTrue(ResponseCache.isCached(IDENTIFIER)); ResponseCache.removeIf(identifier -> identifier.equals(IDENTIFIER)); diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java b/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java index 7210dc8963..c82248c8dd 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java @@ -17,6 +17,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; @@ -294,7 +295,7 @@ public void testNicknamesTable() throws SQLException, DBInitException { assertEquals(expected, nicknames.get(0)); Map> allNicknames = nickTable.getAllNicknames(uuid); - assertEquals(nicknames, allNicknames.get(Plan.getServerUUID())); + assertEquals(nicknames, allNicknames.get(ServerInfo.getServerUUID())); } @Test @@ -417,7 +418,7 @@ public void testSessionSaving() throws SQLException, DBInitException { System.out.println(" " + entry.getValue()); } - List savedSessions = sessions.get(Plan.getServerUUID()); + List savedSessions = sessions.get(ServerInfo.getServerUUID()); assertNotNull(savedSessions); assertEquals(1, savedSessions.size()); @@ -449,7 +450,7 @@ public void testUserInfoTableRegisterUnRegistered() throws SQLException, DBInitE assertEquals(uuid, userInfo.getUuid()); assertEquals(123456789L, (long) usersTable.getRegisterDates().get(0)); assertEquals(123456789L, userInfo.getRegistered()); - assertEquals(1, userInfoTable.getServerUserCount(Plan.getServerUUID())); + assertEquals(1, userInfoTable.getServerUserCount(ServerInfo.getServerUUID())); assertEquals("Waiting for Update..", userInfo.getName()); assertFalse(userInfo.isBanned()); assertFalse(userInfo.isOpped()); @@ -698,7 +699,7 @@ public void testServerTableBungee() throws SQLException, DBInitException { testServerTableBungeeSave(); ServerTable serverTable = db.getServerTable(); - List bukkitServers = serverTable.getBukkitServers(); + Map bukkitServers = serverTable.getBukkitServers(); assertEquals(1, bukkitServers.size()); } @@ -821,7 +822,7 @@ public void testSaveAllWorldTimes() throws SQLException { List sessions = new ArrayList<>(); sessions.add(session); sessionMap.put(uuid, sessions); - map.put(Plan.getServerUUID(), sessionMap); + map.put(ServerInfo.getServerUUID(), sessionMap); worldTimesTable.saveWorldTimes(map); @@ -844,7 +845,7 @@ public void testSaveSessionsWorldTimes() throws SQLException { List sessions = new ArrayList<>(); sessions.add(session); sessionMap.put(uuid, sessions); - UUID serverUUID = Plan.getServerUUID(); + UUID serverUUID = ServerInfo.getServerUUID(); map.put(serverUUID, sessionMap); sessionsTable.insertSessions(map, true); diff --git a/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java b/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java index 5c4cb062e5..d5e7c4c54b 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java @@ -25,8 +25,8 @@ public class WebServerTest { public void setUp() throws Exception { TestInit testInit = TestInit.init(); Plan plugin = testInit.getPlanMock(); - webServer = new WebServer(plugin); - requestHandler = new RequestHandler(plugin, webServer); + webServer = new WebServer(); + requestHandler = new RequestHandler(webServer); } @Test diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java index 224a6f8e56..ad6d76af3e 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.utilities.export; -import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.utilities.file.export.Hastebin; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java index d8f4fef0e7..ac6a253f16 100644 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ b/Plan/test/main/java/test/utilities/TestInit.java @@ -2,7 +2,6 @@ import com.djrapitops.plan.Plan; 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.settings.Settings; import com.djrapitops.plan.system.settings.locale.Locale; @@ -132,8 +131,6 @@ public void save() { // }; // when(planMock.getDataCache()).thenReturn(dataCache); - when(ServerInfo.getServerUUID()).thenReturn(serverUUID); - when(planMock.getServerUuid()).thenReturn(serverUUID); ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK); when(planMock.getColorScheme()).thenReturn(cs); initLocale(null); From 2b412f6f7b50b777bafc9b37a8b0c1f5fa748c14 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 20:26:38 +0200 Subject: [PATCH 055/166] Fixed PlanPluginBridge compile issues --- Plan/dependency-reduced-pom.xml | 286 +++++++++--------- .../plan/system/info/InfoSystem.java | 2 +- .../djrapitops/pluginbridge/plan/Bridge.java | 4 +- .../plan/aac/AdvancedAntiCheatHook.java | 11 +- .../pluginbridge/plan/aac/HackerTable.java | 16 +- .../plan/aac/PlayerHackKickListener.java | 16 +- .../AdvancedAchievementsData.java | 8 +- .../AdvancedAchievementsHook.java | 4 +- .../plan/askyblock/ASkyBlockData.java | 6 +- .../plan/askyblock/ASkyBlockHook.java | 4 +- .../plan/banmanager/BanManagerData.java | 10 +- .../plan/essentials/EssentialsData.java | 10 +- .../plan/essentials/EssentialsHook.java | 4 +- .../factions/FactionAccordionCreator.java | 8 +- .../plan/factions/FactionsData.java | 16 +- .../plan/factions/FactionsHook.java | 4 +- .../griefprevention/GriefPreventionData.java | 6 +- .../griefprevention/GriefPreventionHook.java | 4 +- .../pluginbridge/plan/jobs/JobsData.java | 8 +- .../pluginbridge/plan/jobs/JobsHook.java | 4 +- .../plan/kingdoms/KingdomsData.java | 8 +- .../plan/litebans/LiteBansData.java | 15 +- .../litebans/LiteBansDatabaseQueries.java | 7 +- .../plan/litebans/LiteBansHook.java | 4 +- .../pluginbridge/plan/mcmmo/McMmoData.java | 19 +- .../pluginbridge/plan/mcmmo/McmmoHook.java | 4 +- .../PlayerVersionListener.java | 14 +- .../protocolsupport/ProtocolSupportData.java | 10 +- .../protocolsupport/ProtocolSupportHook.java | 11 +- .../plan/redprotect/RedProtectData.java | 4 +- .../plan/superbvote/SuperbVoteData.java | 6 +- .../plan/superbvote/SuperbVoteHook.java | 4 +- .../plan/towny/TownAccordionCreator.java | 12 +- .../pluginbridge/plan/towny/TownyData.java | 26 +- .../pluginbridge/plan/towny/TownyHook.java | 4 +- .../pluginbridge/plan/vault/VaultEcoData.java | 12 +- .../pluginbridge/plan/vault/VaultHook.java | 4 +- .../plan/vault/VaultPermData.java | 12 +- .../viaversion/PlayerVersionListener.java | 14 +- .../plan/viaversion/ProtocolTable.java | 16 +- .../plan/viaversion/ViaVersionData.java | 6 +- .../plan/viaversion/ViaVersionHook.java | 13 +- 42 files changed, 318 insertions(+), 338 deletions(-) diff --git a/Plan/dependency-reduced-pom.xml b/Plan/dependency-reduced-pom.xml index ffad708140..8176eeb324 100644 --- a/Plan/dependency-reduced-pom.xml +++ b/Plan/dependency-reduced-pom.xml @@ -3,22 +3,22 @@ 4.0.0 com.djrapitops Plan - 4.2.0-SNAPSHOT + 4.2.0-SNAPSHOT - ${basedir}/src - ${basedir}/test + ${basedir}/src/main/java + ${basedir}/test/main/java clean package install . ${basedir}/src/main/resources - **/*.keystore - **/*.css - **/*.yml - **/*.html - **/*.js - **/*.css + **/*.keystore + **/*.css + **/*.yml + **/*.html + **/*.js + **/*.css licence.yml @@ -65,6 +65,10 @@ + + maven-install-plugin + 2.5.2 + maven-jar-plugin 2.6 @@ -104,152 +108,152 @@ bungeecord-repo https://oss.sonatype.org/content/repositories/snapshots - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - paper-repo - https://repo.destroystokyo.com/repository/maven-public/ - + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + paper-repo + https://repo.destroystokyo.com/repository/maven-public/ + com.destroystokyo.paper - paper-api - 1.12.2-R0.1-SNAPSHOT + paper-api + 1.12.2-R0.1-SNAPSHOT provided - - - authlib - com.mojang - - - commons-lang - commons-lang - - - json-simple - com.googlecode.json-simple - - - jsr305 - com.google.code.findbugs - - - guava - com.google.guava - - - gson - com.google.code.gson - - - snakeyaml - org.yaml - - - bungeecord-chat - net.md-5 - - - slf4j-api - org.slf4j - - - asm-all - org.ow2.asm - - + + + authlib + com.mojang + + + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + jsr305 + com.google.code.findbugs + + + guava + com.google.guava + + + gson + com.google.code.gson + + + snakeyaml + org.yaml + + + bungeecord-chat + net.md-5 + + + slf4j-api + org.slf4j + + + asm-all + org.ow2.asm + + - org.spigotmc - spigot-api - 1.12-R0.1-SNAPSHOT + org.spigotmc + spigot-api + 1.12-R0.1-SNAPSHOT provided - commons-lang - commons-lang + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + guava + com.google.guava + + + gson + com.google.code.gson + + + snakeyaml + org.yaml + + + bungeecord-chat + net.md-5 + + + + + org.bukkit + bukkit + 1.12.2-R0.1-SNAPSHOT + provided + + + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + guava + com.google.guava + + + gson + com.google.code.gson + + + snakeyaml + org.yaml - - json-simple - com.googlecode.json-simple - - - guava - com.google.guava - - - gson - com.google.code.gson - - - snakeyaml - org.yaml - - - bungeecord-chat - net.md-5 - - - org.bukkit - bukkit - 1.12.2-R0.1-SNAPSHOT - provided - - - commons-lang - commons-lang - - - json-simple - com.googlecode.json-simple - - - guava - com.google.guava - - - gson - com.google.code.gson - - - snakeyaml - org.yaml - - - - + + net.md-5 + bungeecord-api + 1.12-SNAPSHOT + provided + + + bungeecord-config + net.md-5 + + + bungeecord-event + net.md-5 + + + bungeecord-protocol net.md-5 - bungeecord-api - 1.12-SNAPSHOT - provided - - - bungeecord-config - net.md-5 - - - bungeecord-event - net.md-5 - - - bungeecord-protocol - net.md-5 - - - bungeecord-chat - net.md-5 - - - guava - com.google.guava - - - + + + bungeecord-chat + net.md-5 + + + guava + com.google.guava + + + org.powermock powermock 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 1b7666f6b6..ac0ada2369 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 @@ -87,7 +87,7 @@ public ConnectionSystem getConnectionSystem() { public abstract void updateNetworkPage() throws WebException; - public void requestSetUp(String address) { + public void requestSetUp(String address) throws WebException { // TODO } } \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java index 240671826d..d1b3369ce3 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java @@ -1,5 +1,7 @@ package com.djrapitops.pluginbridge.plan; +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.pluginbridge.plan.aac.AdvancedAntiCheatHook; import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook; @@ -18,8 +20,6 @@ import com.djrapitops.pluginbridge.plan.towny.TownyHook; import com.djrapitops.pluginbridge.plan.vault.VaultHook; import com.djrapitops.pluginbridge.plan.viaversion.ViaVersionHook; -import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.settings.Settings; /** * Manages connection to other plugins. diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java index 22ca28af3d..dc71114ff8 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java @@ -4,12 +4,13 @@ */ package com.djrapitops.pluginbridge.plan.aac; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.pluginbridge.plan.Hook; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.database.databases.SQLDB; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.pluginbridge.plan.Hook; /** * Hook for AAC plugin. @@ -31,7 +32,7 @@ public void hook() throws NoClassDefFoundError { } Plan plugin = Plan.getInstance(); - HackerTable table = new HackerTable((SQLDB) plugin.getDB()); + HackerTable table = new HackerTable((SQLDB) Database.getActive()); try { table.createTable(); } catch (DBCreateTableException e) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java index 17aec20a80..1d1b8b4215 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java @@ -5,13 +5,13 @@ */ package com.djrapitops.pluginbridge.plan.aac; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.tables.Table; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.tables.Table; import me.konsolas.aac.api.HackType; import java.sql.PreparedStatement; @@ -33,7 +33,7 @@ public class HackerTable extends Table { private final String columnViolations; public HackerTable(SQLDB db) { - super("plan_aac_hack_table", db, db.isUsingMySQL()); + super("plan_aac_hack_table", db); columnUUID = "uuid"; columnDate = "date"; columnHackType = "hack_type"; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java index c07f96a4f3..6ff6f5c25c 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java @@ -5,12 +5,11 @@ */ package com.djrapitops.pluginbridge.plan.aac; - -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.systems.processing.Processor; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plugin.api.utility.log.Log; import me.konsolas.aac.api.AACAPIProvider; import me.konsolas.aac.api.HackType; import me.konsolas.aac.api.PlayerViolationCommandEvent; @@ -43,16 +42,15 @@ public void onKick(PlayerViolationCommandEvent event) { int violations = AACAPIProvider.getAPI().getViolationLevel(player, hackType); HackObject hackObject = new HackObject(uuid, time, hackType, violations); - Plan plan = Plan.getInstance(); - plan.addToProcessQueue(new Processor(uuid) { + new Processor(uuid) { @Override public void process() { try { - new HackerTable((SQLDB) plan.getDB()).insertHackRow(hackObject); + new HackerTable((SQLDB) Database.getActive()).insertHackRow(hackObject); } catch (SQLException e) { Log.toLog(this.getClass().getName(), e); } } - }); + }.queue(); } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsData.java index a7901bf99d..dc44dd0571 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsData.java @@ -4,8 +4,6 @@ */ package com.djrapitops.pluginbridge.plan.advancedachievements; -import com.djrapitops.plugin.api.TimeAmount; -import com.hm.achievement.api.AdvancedAchievementsAPI; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.ContainerSize; @@ -13,6 +11,8 @@ import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; +import com.djrapitops.plugin.api.TimeAmount; +import com.hm.achievement.api.AdvancedAchievementsAPI; import java.util.Collection; import java.util.Map; @@ -38,7 +38,7 @@ public AdvancedAchievementsData(AdvancedAchievementsAPI aaAPI) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { String text = getWithIcon("Achievements", "check-circle-o", "green"); inspectContainer.addValue(text, aaAPI.getPlayerTotalAchievements(uuid)); @@ -46,7 +46,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { if (MiscUtils.getTime() - lastRefresh > TimeAmount.MINUTE.ms() * 5L) { refreshTotalAchievements(); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsHook.java index 98729ff8e5..5e8a726c18 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/advancedachievements/AdvancedAchievementsHook.java @@ -1,11 +1,10 @@ package com.djrapitops.pluginbridge.plan.advancedachievements; +import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.pluginbridge.plan.Hook; import com.hm.achievement.AdvancedAchievements; import com.hm.achievement.api.AdvancedAchievementsAPI; import com.hm.achievement.api.AdvancedAchievementsBukkitAPI; -import com.djrapitops.plan.api.API; -import com.djrapitops.plan.data.plugin.HookHandler; import static org.bukkit.plugin.java.JavaPlugin.getPlugin; @@ -25,7 +24,6 @@ public class AdvancedAchievementsHook extends Hook { * * @param hookH HookHandler instance for registering the data sources. * @throws NoClassDefFoundError when the plugin class can not be found. - * @see API */ public AdvancedAchievementsHook(HookHandler hookH) { super("com.hm.achievement.AdvancedAchievements", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java index 4753777901..a2da361dbc 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockData.java @@ -4,11 +4,11 @@ */ package com.djrapitops.pluginbridge.plan.askyblock; -import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.wasteofplastic.askyblock.ASkyBlockAPI; import java.util.Collection; import java.util.UUID; @@ -30,7 +30,7 @@ public ASkyBlockData(ASkyBlockAPI api) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { if (api.hasIsland(uuid)) { String islandName = api.getIslandName(uuid); int level = api.getIslandLevel(uuid); @@ -47,7 +47,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) { int islandCount = api.getIslandCount(); String islandWorldName = api.getIslandWorld().getName(); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockHook.java index 27605cc3ad..784ec0dc05 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/askyblock/ASkyBlockHook.java @@ -1,9 +1,8 @@ package com.djrapitops.pluginbridge.plan.askyblock; +import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.pluginbridge.plan.Hook; import com.wasteofplastic.askyblock.ASkyBlockAPI; -import com.djrapitops.plan.api.API; -import com.djrapitops.plan.data.plugin.HookHandler; /** * A Class responsible for hooking to ASkyBlock and registering data sources. @@ -20,7 +19,6 @@ public class ASkyBlockHook extends Hook { * * @param hookH HookHandler instance for registering the data sources. * @throws NoClassDefFoundError when the plugin class can not be found. - * @see API */ public ASkyBlockHook(HookHandler hookH) throws NoClassDefFoundError { super("com.wasteofplastic.askyblock.ASkyBlock", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/banmanager/BanManagerData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/banmanager/BanManagerData.java index 886aeeb0ac..e0839c0af3 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/banmanager/BanManagerData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/banmanager/BanManagerData.java @@ -4,7 +4,7 @@ */ package com.djrapitops.pluginbridge.plan.banmanager; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.BanData; @@ -34,7 +34,7 @@ public BanManagerData() { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { boolean banned = BmAPI.isBanned(uuid); boolean muted = BmAPI.isMuted(uuid); @@ -43,7 +43,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain if (banned) { PlayerBanData currentBan = BmAPI.getCurrentBan(uuid); String bannedBy = currentBan.getActor().getName(); - String link = Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(bannedBy), bannedBy); + String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(bannedBy), bannedBy); long date = currentBan.getCreated(); long ends = currentBan.getExpires(); String reason = currentBan.getReason(); @@ -57,7 +57,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain if (muted) { PlayerMuteData currentMute = BmAPI.getCurrentMute(uuid); String mutedBy = currentMute.getActor().getName(); - String link = Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(mutedBy), mutedBy); + String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(mutedBy), mutedBy); long date = currentMute.getCreated(); long ends = currentMute.getExpires(); String reason = currentMute.getReason(); @@ -72,7 +72,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { return analysisContainer; } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsData.java index b134c4877b..6e9b343913 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsData.java @@ -4,14 +4,14 @@ */ package com.djrapitops.pluginbridge.plan.essentials; -import com.earth2me.essentials.Essentials; -import com.earth2me.essentials.User; -import com.earth2me.essentials.UserMap; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.User; +import com.earth2me.essentials.UserMap; import java.util.*; @@ -32,7 +32,7 @@ public EssentialsData(Essentials essentials) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { if (essentials.getUserMap().userExists(uuid)) { User user = essentials.getUser(uuid); @@ -48,7 +48,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) { UserMap userMap = essentials.getUserMap(); Map jailed = new HashMap<>(); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsHook.java index 8d15b8f4af..2c24b43113 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/essentials/EssentialsHook.java @@ -1,9 +1,8 @@ package com.djrapitops.pluginbridge.plan.essentials; +import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.pluginbridge.plan.Hook; import com.earth2me.essentials.Essentials; -import com.djrapitops.plan.api.API; -import com.djrapitops.plan.data.plugin.HookHandler; import static org.bukkit.plugin.java.JavaPlugin.getPlugin; @@ -22,7 +21,6 @@ public class EssentialsHook extends Hook { * * @param hookH HookHandler instance for registering the data sources. * @throws NoClassDefFoundError when the plugin class can not be found. - * @see API */ public EssentialsHook(HookHandler hookH) { super("com.earth2me.essentials.Essentials", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java index 5cfbe98cce..f9f378f3b4 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java @@ -4,15 +4,15 @@ */ package com.djrapitops.pluginbridge.plan.factions; -import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.MPlayer; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.html.HtmlStructure; +import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.MPlayer; import java.util.*; import java.util.stream.Collectors; @@ -49,7 +49,7 @@ public static String createAccordion(List factions) { if (mPlayer == null) { continue; } - UUID uuid = Plan.getInstance().getDataCache().getUUIDof(mPlayer.getName()); + UUID uuid = DataCache.getInstance().getUUIDof(mPlayer.getName()); if (uuid != null) { members.add(uuid); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java index 2bdbb4cc01..71d8ab741f 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java @@ -4,17 +4,17 @@ */ package com.djrapitops.pluginbridge.plan.factions; -import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.MPlayer; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.settings.Settings; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.html.Html; +import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MPlayer; import java.util.*; import java.util.stream.Collectors; @@ -33,7 +33,7 @@ public FactionsData() { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { MPlayer mPlayer = MPlayer.get(uuid); if (mPlayer.hasFaction()) { @@ -43,7 +43,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain double maxPower = mPlayer.getPowerMax(); String powerString = FormatUtils.cutDecimals(power) + " / " + FormatUtils.cutDecimals(maxPower); String factionLeader = faction.getLeader().getName(); - String factionLeaderLink = Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(factionLeader), factionLeader); + String factionLeaderLink = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(factionLeader), factionLeader); inspectContainer.addValue(getWithIcon("Faction", "flag", "deep-purple"), factionName); inspectContainer.addValue(getWithIcon("Power", "bolt", "purple"), powerString); @@ -54,7 +54,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) { List factions = getTopFactions(); analysisContainer.addValue(getWithIcon("Number of Factions", "flag", "deep-purple"), factions.size()); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsHook.java index a38866c753..e508a9294e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsHook.java @@ -1,8 +1,7 @@ package com.djrapitops.pluginbridge.plan.factions; -import com.djrapitops.pluginbridge.plan.Hook; -import com.djrapitops.plan.api.API; import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.pluginbridge.plan.Hook; /** * A Class responsible for hooking to Factions and registering 4 data sources. @@ -18,7 +17,6 @@ public class FactionsHook extends Hook { * API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API */ public FactionsHook(HookHandler hookH) { super("com.massivecraft.factions.Factions", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionData.java index 2b754abf9c..971672bdff 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionData.java @@ -4,13 +4,13 @@ */ package com.djrapitops.pluginbridge.plan.griefprevention; -import com.djrapitops.plugin.utilities.FormatUtils; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.utilities.analysis.MathUtils; +import com.djrapitops.plugin.utilities.FormatUtils; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.DataStore; import me.ryanhamshire.GriefPrevention.PlayerData; @@ -35,7 +35,7 @@ public GriefPreventionData(DataStore dataStore) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { Map claims = dataStore.getClaims().stream() .filter(Objects::nonNull) .filter(claim -> uuid.equals(claim.ownerID)) @@ -64,7 +64,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { Map area = new HashMap<>(); for (Claim claim : dataStore.getClaims()) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionHook.java index 4c0bcef0ba..dda5e3be26 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/GriefPreventionHook.java @@ -1,8 +1,7 @@ package com.djrapitops.pluginbridge.plan.griefprevention; -import com.djrapitops.pluginbridge.plan.Hook; -import com.djrapitops.plan.api.API; import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.pluginbridge.plan.Hook; import me.ryanhamshire.GriefPrevention.DataStore; import me.ryanhamshire.GriefPrevention.GriefPrevention; @@ -23,7 +22,6 @@ public class GriefPreventionHook extends Hook { * API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API * @throws NoClassDefFoundError when the plugin class can not be found. */ public GriefPreventionHook(HookHandler hookH) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsData.java index 87c7852ef6..aceb0dcfbd 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsData.java @@ -4,8 +4,6 @@ */ package com.djrapitops.pluginbridge.plan.jobs; -import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.dao.JobsDAOData; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; @@ -13,6 +11,8 @@ import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.dao.JobsDAOData; import java.util.*; import java.util.stream.Collectors; @@ -31,7 +31,7 @@ public JobsData() { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { List playersJobs = Jobs.getDBManager().getDB().getAllJobs(null, uuid); TableContainer jobTable = new TableContainer(getWithIcon("Job", "suitcase"), getWithIcon("Level", "plus")); @@ -47,7 +47,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { List allJobs = Jobs.getDBManager().getDB().getAllJobs() .values().stream() .flatMap(Collection::stream) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsHook.java index 4d559e104e..59681e9168 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/jobs/JobsHook.java @@ -1,8 +1,7 @@ package com.djrapitops.pluginbridge.plan.jobs; -import com.djrapitops.pluginbridge.plan.Hook; -import com.djrapitops.plan.api.API; import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.pluginbridge.plan.Hook; /** * A Class responsible for hooking to Jobs and registering data sources. @@ -18,7 +17,6 @@ public class JobsHook extends Hook { * API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API */ public JobsHook(HookHandler hookH) { super("com.gamingmesh.jobs.Jobs", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomsData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomsData.java index 6f6794cd03..34fb3180d0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomsData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomsData.java @@ -4,7 +4,7 @@ */ package com.djrapitops.pluginbridge.plan.kingdoms; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.ContainerSize; @@ -33,7 +33,7 @@ public KingdomsData() { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { OfflineKingdomPlayer kingdomPlayer = GameManagement.getPlayerManager().getOfflineKingdomPlayer(uuid); String kingdomName = kingdomPlayer.getKingdomName(); @@ -43,7 +43,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain OfflineKingdom kingdom = GameManagement.getKingdomManager().getOfflineKingdom(kingdomName); if (kingdom != null) { String king = kingdom.getKingName(); - String link = Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(king), king); + String link = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(king), king); inspectContainer.addValue(getWithIcon("Kingdom", "shield", "amber"), kingdomName); inspectContainer.addValue(getWithIcon("King", "user", "amber"), link); } @@ -53,7 +53,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { Map kingdoms = GameManagement.getKingdomManager().getKingdomList(); analysisContainer.addValue(getWithIcon("Number of Kingdoms", "shield", "amber"), kingdoms.size()); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java index d71e603dcb..680d18207f 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java @@ -4,16 +4,17 @@ */ package com.djrapitops.pluginbridge.plan.litebans; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.BanData; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.html.Html; +import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; import java.util.*; @@ -36,7 +37,7 @@ public LiteBansData(LiteBansDatabaseQueries db) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { String by = getWithIcon("Banned By", "gavel"); String reason = getWithIcon("Reason", "balance-scale"); @@ -54,7 +55,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain String expires = expiry <= 0 ? "Never" : FormatUtils.formatTimeStampSecond(expiry); banTable.addRow( expires, - Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(ban.getBannedBy()), ban.getBannedBy()), + Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(ban.getBannedBy()), ban.getBannedBy()), ban.getReason() ); } @@ -80,13 +81,13 @@ public AnalysisContainer getServerData(Collection collection, AnalysisCont List bans = db.getBans(); for (BanObject ban : bans) { UUID uuid = ban.getUuid(); - String name = Plan.getInstance().getDataCache().getName(uuid); + String name = DataCache.getInstance().getName(uuid); long expiry = ban.getExpiry(); String expires = expiry <= 0 ? "Never" : FormatUtils.formatTimeStampSecond(expiry); banTable.addRow( - Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(name), name), - Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(ban.getBannedBy()), ban.getBannedBy()), + Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), + Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(ban.getBannedBy()), ban.getBannedBy()), ban.getReason(), expires ); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java index 7aead16430..fffa1be1a5 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java @@ -1,8 +1,7 @@ package com.djrapitops.pluginbridge.plan.litebans; +import com.djrapitops.plan.system.database.databases.sql.tables.Table; import litebans.api.Database; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.tables.Table; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -21,7 +20,7 @@ public class LiteBansDatabaseQueries extends Table { private final Database database; public LiteBansDatabaseQueries() { - super("litebans", null, false); + super("litebans", null); database = Database.get(); } @@ -71,7 +70,7 @@ public List getBans(UUID playerUUID) throws SQLException { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() { throw new IllegalStateException("Not Supposed to be called."); } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java index 5ed3e559e3..d3211c9041 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansHook.java @@ -1,9 +1,8 @@ package com.djrapitops.pluginbridge.plan.litebans; +import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.pluginbridge.plan.Hook; import litebans.api.Database; -import com.djrapitops.plan.api.API; -import com.djrapitops.plan.data.plugin.HookHandler; /** * A Class responsible for hooking to LiteBans and registering data @@ -21,7 +20,6 @@ public class LiteBansHook extends Hook { * * @param hookH HookHandler instance for registering the data sources. * @throws NoClassDefFoundError when the plugin class can not be found. - * @see API */ @SuppressWarnings("ResultOfMethodCallIgnored") public LiteBansHook(HookHandler hookH) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McMmoData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McMmoData.java index dcb15c9349..c777dfc4d8 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McMmoData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McMmoData.java @@ -4,12 +4,6 @@ */ package com.djrapitops.pluginbridge.plan.mcmmo; -import com.gmail.nossr50.database.DatabaseManager; -import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.datatypes.player.PlayerProfile; -import com.gmail.nossr50.datatypes.skills.SkillType; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.player.UserManager; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; @@ -18,6 +12,12 @@ import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plan.utilities.html.Html; +import com.gmail.nossr50.database.DatabaseManager; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.util.player.UserManager; import org.apache.commons.lang3.StringUtils; import java.io.Serializable; @@ -40,7 +40,7 @@ public McMmoData() { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { DatabaseManager db = mcMMO.getDatabaseManager(); PlayerProfile profile = db.loadPlayerProfile(uuid); @@ -50,8 +50,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain TableContainer skillTable = new TableContainer(skillS, levelS); skillTable.setColor("indigo"); - List skills = new ArrayList<>(); - skills.addAll(Arrays.stream(SkillType.values()).distinct().collect(Collectors.toList())); + List skills = Arrays.stream(SkillType.values()).distinct().collect(Collectors.toList()); for (SkillType skill : skills) { skillTable.addRow(StringUtils.capitalize(skill.getName().toLowerCase()), profile.getSkillLevel(skill)); } @@ -60,7 +59,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { String skillS = Html.FONT_AWESOME_ICON.parse("star") + " Skill"; String tLevel = Html.FONT_AWESOME_ICON.parse("plus") + " Total Level"; String aLevel = Html.FONT_AWESOME_ICON.parse("plus") + " Average Level"; diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoHook.java index cd80c672d7..0b5dcb9c91 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/mcmmo/McmmoHook.java @@ -1,8 +1,7 @@ package com.djrapitops.pluginbridge.plan.mcmmo; -import com.djrapitops.pluginbridge.plan.Hook; -import com.djrapitops.plan.api.API; import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.pluginbridge.plan.Hook; /** * A Class responsible for hooking to MCMMO and registering data sources. @@ -18,7 +17,6 @@ public class McmmoHook extends Hook { * API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API */ public McmmoHook(HookHandler hookH) { super("com.gmail.nossr50.mcMMO", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java index c2ad590770..e4450638ea 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java @@ -5,12 +5,12 @@ */ package com.djrapitops.pluginbridge.plan.protocolsupport; - +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.systems.processing.Processor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -40,15 +40,15 @@ public void onJoin(PlayerJoinEvent event) { ProtocolVersion protocolVersion = ProtocolSupportAPI.getProtocolVersion(player); int playerVersion = protocolVersion.getId(); Plan plan = Plan.getInstance(); - plan.addToProcessQueue(new Processor(uuid) { + new Processor(uuid) { @Override public void process() { try { - new ProtocolTable((SQLDB) plan.getDB()).saveProtocolVersion(uuid, playerVersion); + new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion); } catch (SQLException e) { Log.toLog(this.getClass().getName(), e); } } - }); + }.queue(); } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java index 1af61894f3..6d64bb3d42 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportData.java @@ -4,14 +4,14 @@ */ package com.djrapitops.pluginbridge.plan.protocolsupport; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.pluginbridge.plan.viaversion.Protocol; -import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.pluginbridge.plan.viaversion.Protocol; +import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable; import java.sql.SQLException; import java.util.Collection; @@ -37,7 +37,7 @@ public ProtocolSupportData(ProtocolTable table) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { try { int protocolVersion = table.getProtocolVersion(uuid); @@ -51,7 +51,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { Map versions; try { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java index 5f529583b8..95bc1242f7 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java @@ -4,13 +4,14 @@ */ package com.djrapitops.pluginbridge.plan.protocolsupport; +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.pluginbridge.plan.Hook; import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.database.databases.SQLDB; /** * Hook for ProtocolSupport plugin. @@ -31,7 +32,7 @@ public void hook() throws NoClassDefFoundError { return; } Plan plan = Plan.getInstance(); - ProtocolTable table = new ProtocolTable((SQLDB) plan.getDB()); + ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive()); try { table.createTable(); } catch (DBCreateTableException e) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java index 139743ead1..b3bc1cde3b 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java @@ -31,7 +31,7 @@ public RedProtectData() { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { Set regions = RedProtectAPI.getPlayerRegions(uuid.toString()); inspectContainer.addValue(getWithIcon("Regions", "map-marker", "red"), regions.size()); @@ -50,7 +50,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { Set regions = RedProtectAPI.getAllRegions(); analysisContainer.addValue(getWithIcon("All Regions", "map-marker", "red"), regions.size()); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteData.java index a826c78b71..9028fcb35e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteData.java @@ -4,11 +4,11 @@ */ package com.djrapitops.pluginbridge.plan.superbvote; -import io.minimum.minecraft.superbvote.storage.VoteStorage; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import io.minimum.minecraft.superbvote.storage.VoteStorage; import java.util.Collection; import java.util.HashMap; @@ -31,7 +31,7 @@ public SuperbVoteData(VoteStorage store) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { int votes = store.getVotes(uuid); inspectContainer.addValue(getWithIcon("Votes", "check", "teal"), votes); @@ -40,7 +40,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection uuids, AnalysisContainer analysisContainer) { Map votes = new HashMap<>(); long total = 0; for (UUID uuid : uuids) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteHook.java index 53d5b59600..a0453d0cd7 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/superbvote/SuperbVoteHook.java @@ -1,10 +1,9 @@ package com.djrapitops.pluginbridge.plan.superbvote; +import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.pluginbridge.plan.Hook; import io.minimum.minecraft.superbvote.SuperbVote; import io.minimum.minecraft.superbvote.storage.VoteStorage; -import com.djrapitops.plan.api.API; -import com.djrapitops.plan.data.plugin.HookHandler; import static org.bukkit.plugin.java.JavaPlugin.getPlugin; @@ -24,7 +23,6 @@ public class SuperbVoteHook extends Hook { * * @param hookH HookHandler instance for registering the data sources. * @throws NoClassDefFoundError when the plugin class can not be found. - * @see API */ public SuperbVoteHook(HookHandler hookH) { super("io.minimum.minecraft.superbvote.SuperbVote", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java index 399e4199ad..c20065ac77 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java @@ -4,16 +4,16 @@ */ package com.djrapitops.pluginbridge.plan.towny; -import com.palmergames.bukkit.towny.exceptions.TownyException; -import com.palmergames.bukkit.towny.object.Coord; -import com.palmergames.bukkit.towny.object.Resident; -import com.palmergames.bukkit.towny.object.Town; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.utilities.analysis.Analysis; import com.djrapitops.plan.utilities.html.HtmlStructure; +import com.palmergames.bukkit.towny.exceptions.TownyException; +import com.palmergames.bukkit.towny.object.Coord; +import com.palmergames.bukkit.towny.object.Resident; +import com.palmergames.bukkit.towny.object.Town; import java.util.*; import java.util.stream.Collectors; @@ -49,7 +49,7 @@ public static String createAccordion(List towns) { Set members = new HashSet<>(); for (Resident resident : residents) { - UUID uuid = Plan.getInstance().getDataCache().getUUIDof(resident.getName()); + UUID uuid = DataCache.getInstance().getUUIDof(resident.getName()); if (uuid != null) { members.add(uuid); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyData.java index 00215b3904..10d5fb37f0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyData.java @@ -4,19 +4,20 @@ */ package com.djrapitops.pluginbridge.plan.towny; +import com.djrapitops.plan.api.PlanAPI; +import com.djrapitops.plan.data.element.AnalysisContainer; +import com.djrapitops.plan.data.element.InspectContainer; +import com.djrapitops.plan.data.plugin.ContainerSize; +import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plugin.utilities.Verify; import com.palmergames.bukkit.towny.exceptions.TownyException; import com.palmergames.bukkit.towny.object.Coord; import com.palmergames.bukkit.towny.object.Resident; import com.palmergames.bukkit.towny.object.Town; import com.palmergames.bukkit.towny.object.TownyUniverse; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.element.AnalysisContainer; -import com.djrapitops.plan.data.element.InspectContainer; -import com.djrapitops.plan.data.plugin.ContainerSize; -import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.settings.Settings; -import com.djrapitops.plan.utilities.html.Html; import java.util.*; import java.util.stream.Collectors; @@ -37,7 +38,7 @@ public TownyData() { @Override public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { - String playerName = Plan.getInstance().getDataCache().getName(uuid); + String playerName = DataCache.getInstance().getName(uuid); Resident resident = TownyUniverse.getDataSource().getResident(playerName); @@ -45,7 +46,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain Town town = resident.getTown(); String townName = town.getName(); String mayorName = town.getMayor().getName(); - String townMayor = Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(mayorName), mayorName); + String townMayor = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(mayorName), mayorName); inspectContainer.addValue(getWithIcon("Town", "bank", "brown"), townName); inspectContainer.addValue(getWithIcon("Town Mayor", "user", "brown"), townMayor); @@ -67,7 +68,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { List towns = getTopTowns(); analysisContainer.addValue(getWithIcon("Number of Towns", "bank", "brown"), towns.size()); @@ -78,10 +79,11 @@ public AnalysisContainer getServerData(Collection collection, AnalysisCont for (Town town : towns) { String townName = town.getName(); String mayor = town.getMayor().getName(); - UUID mayorUUID = Plan.getInstance().getDataCache().getUUIDof(mayor); + DataCache dataCache = DataCache.getInstance(); + UUID mayorUUID = dataCache.getUUIDof(mayor); town.getResidents().stream() .map(Resident::getName) - .map(name -> Plan.getInstance().getDataCache().getUUIDof(name)) + .map(dataCache::getUUIDof) .filter(Verify::notNull) .forEach(uuid -> userTowns.put(uuid, uuid.equals(mayorUUID) ? "" + townName + "" : townName)); } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyHook.java index 7c66869ddd..4c00abcb2d 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownyHook.java @@ -1,8 +1,7 @@ package com.djrapitops.pluginbridge.plan.towny; -import com.djrapitops.pluginbridge.plan.Hook; -import com.djrapitops.plan.api.API; import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.pluginbridge.plan.Hook; /** * A Class responsible for hooking to Towny and registering 2 data sources. @@ -18,7 +17,6 @@ public class TownyHook extends Hook { * API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API * @throws NoClassDefFoundError when the plugin class can not be found. */ public TownyHook(HookHandler hookH) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultEcoData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultEcoData.java index 1412b65839..e268abfd3b 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultEcoData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultEcoData.java @@ -4,17 +4,17 @@ */ package com.djrapitops.pluginbridge.plan.vault; -import com.djrapitops.plugin.utilities.Verify; -import com.djrapitops.pluginbridge.plan.FakeOfflinePlayer; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.utilities.FormatUtils; import com.djrapitops.plan.utilities.analysis.Analysis; +import com.djrapitops.plugin.utilities.Verify; +import com.djrapitops.pluginbridge.plan.FakeOfflinePlayer; import net.milkbowl.vault.economy.Economy; import org.bukkit.OfflinePlayer; @@ -38,8 +38,8 @@ public VaultEcoData(Economy econ) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { - String name = Plan.getInstance().getDataCache().getName(uuid); + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { + String name = DataCache.getInstance().getName(uuid); if (name == null) { return inspectContainer; } @@ -50,7 +50,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { ServerProfile serverProfile = Analysis.getServerProfile(); List profiles = collection.stream() diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java index 27288a6468..1152df7ff4 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultHook.java @@ -1,8 +1,7 @@ package com.djrapitops.pluginbridge.plan.vault; -import com.djrapitops.pluginbridge.plan.Hook; -import com.djrapitops.plan.api.API; import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.pluginbridge.plan.Hook; import net.milkbowl.vault.economy.Economy; import static org.bukkit.Bukkit.getServer; @@ -22,7 +21,6 @@ public class VaultHook extends Hook { * * @param hookH HookHandler instance for registering the data sources. * @throws NoClassDefFoundError when the plugin class can not be found. - * @see API */ public VaultHook(HookHandler hookH) throws NoClassDefFoundError { super("net.milkbowl.vault.Vault", hookH); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultPermData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultPermData.java index 0956416876..56ecbb6453 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultPermData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/vault/VaultPermData.java @@ -4,16 +4,16 @@ */ package com.djrapitops.pluginbridge.plan.vault; -import com.djrapitops.plugin.utilities.Verify; -import com.djrapitops.pluginbridge.plan.FakeOfflinePlayer; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.utilities.analysis.Analysis; +import com.djrapitops.plugin.utilities.Verify; +import com.djrapitops.pluginbridge.plan.FakeOfflinePlayer; import net.milkbowl.vault.permission.Permission; import org.apache.commons.lang3.StringUtils; import org.bukkit.OfflinePlayer; @@ -38,8 +38,8 @@ public VaultPermData(Permission permSys) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { - String name = Plan.getInstance().getDataCache().getName(uuid); + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { + String name = DataCache.getInstance().getName(uuid); if (name == null) { return inspectContainer; } @@ -50,7 +50,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { ServerProfile serverProfile = Analysis.getServerProfile(); List profiles = collection.stream() diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java index b266584199..cefea553b1 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java @@ -5,11 +5,10 @@ */ package com.djrapitops.pluginbridge.plan.viaversion; - +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.systems.processing.Processor; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -37,17 +36,16 @@ public PlayerVersionListener(ViaAPI viaAPI) { public void onJoin(PlayerJoinEvent event) { UUID uuid = event.getPlayer().getUniqueId(); int playerVersion = viaAPI.getPlayerVersion(uuid); - Plan plan = Plan.getInstance(); - plan.addToProcessQueue(new Processor(uuid) { + new Processor(uuid) { @Override public void process() { try { - new ProtocolTable((SQLDB) plan.getDB()).saveProtocolVersion(uuid, playerVersion); + new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion); } catch (SQLException e) { Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e); } } - }); + }.queue(); } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java index 43541b64d1..6d810f4a3a 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java @@ -5,13 +5,13 @@ */ package com.djrapitops.pluginbridge.plan.viaversion; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; -import com.djrapitops.plan.database.databases.SQLDB; -import com.djrapitops.plan.database.processing.ExecStatement; -import com.djrapitops.plan.database.processing.QueryAllStatement; -import com.djrapitops.plan.database.processing.QueryStatement; -import com.djrapitops.plan.database.sql.Select; -import com.djrapitops.plan.database.tables.Table; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; +import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; +import com.djrapitops.plan.system.database.databases.sql.statements.Select; +import com.djrapitops.plan.system.database.databases.sql.tables.Table; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -32,7 +32,7 @@ public class ProtocolTable extends Table { private final String columnProtocolVersion; public ProtocolTable(SQLDB db) { - super("plan_version_protocol", db, db.isUsingMySQL()); + super("plan_version_protocol", db); columnUUID = "uuid"; columnProtocolVersion = "protocol_version"; } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionData.java index 7b92319b6f..d98c22171f 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionData.java @@ -4,12 +4,12 @@ */ package com.djrapitops.pluginbridge.plan.viaversion; -import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.ContainerSize; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plugin.api.utility.log.Log; import java.sql.SQLException; import java.util.Collection; @@ -35,7 +35,7 @@ public ViaVersionData(ProtocolTable table) { } @Override - public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) throws Exception { + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { try { int protocolVersion = table.getProtocolVersion(uuid); @@ -49,7 +49,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain } @Override - public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { Map versions; try { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java index de6cd776dd..8fb7612ba4 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java @@ -1,12 +1,12 @@ package com.djrapitops.pluginbridge.plan.viaversion; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.pluginbridge.plan.Hook; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.API; -import com.djrapitops.plan.api.exceptions.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; import com.djrapitops.plan.data.plugin.HookHandler; -import com.djrapitops.plan.database.databases.SQLDB; +import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.pluginbridge.plan.Hook; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.ViaAPI; @@ -26,7 +26,6 @@ public class ViaVersionHook extends Hook { * API#addPluginDataSource uses the same method from HookHandler. * * @param hookH HookHandler instance for registering the data sources. - * @see API */ public ViaVersionHook(HookHandler hookH) { super("us.myles.ViaVersion.ViaVersionPlugin", hookH); @@ -38,7 +37,7 @@ public void hook() throws NoClassDefFoundError { } Plan plan = Plan.getInstance(); ViaAPI api = Via.getAPI(); - ProtocolTable table = new ProtocolTable((SQLDB) plan.getDB()); + ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive()); try { table.createTable(); } catch (DBCreateTableException e) { From a60f77f06f89636eec927b62d2e1ff112bdf41eb Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 24 Jan 2018 21:59:53 +0200 Subject: [PATCH 056/166] 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 --- .../main/java/com/djrapitops/plan/Plan.java | 2 +- .../java/com/djrapitops/plan/PlanPlugin.java | 4 +- .../com/djrapitops/plan/api/BukkitAPI.java | 69 +++++++++++++++++++ .../java/com/djrapitops/plan/api/PlanAPI.java | 3 +- .../plan/data/plugin/HookHandler.java | 32 ++++++--- .../djrapitops/plan/system/BukkitSystem.java | 7 ++ .../djrapitops/plan/system/BungeeSystem.java | 4 +- .../djrapitops/plan/system/PlanSystem.java | 15 ++++ .../plan/system/cache/CacheSystem.java | 14 +--- .../plan/system/cache/DataCache.java | 15 +++- .../plan/system/cache/GeolocationCache.java | 23 ++++++- .../plan/system/database/DBSystem.java | 2 +- .../database/databases/sql/MySQLDB.java | 10 --- .../system/database/databases/sql/SQLDB.java | 8 ++- .../database/databases/sql/SQLiteDB.java | 7 -- .../databases/sql/tables/TransferTable.java | 2 +- .../plan/system/info/BukkitInfoSystem.java | 3 + .../plan/system/info/InfoSystem.java | 13 +++- .../connection/BukkitConnectionSystem.java | 2 +- .../connection/BungeeConnectionSystem.java | 2 +- .../system/info/connection/ConnectionOut.java | 2 +- .../info/connection/ConnectionSystem.java | 2 + .../system/settings/config/ConfigSystem.java | 4 +- .../plan/system/webserver/RequestHandler.java | 3 +- .../system/webserver/ResponseHandler.java | 7 +- .../plan/system/webserver/WebServer.java | 23 +++++-- .../system/webserver/WebServerSystem.java | 15 +--- 27 files changed, 208 insertions(+), 85 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 88d3bd4a88..fad8fb4736 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -81,7 +81,7 @@ public void onEnable() { registerCommand("plan", new PlanCommand(this)); Benchmark.start("Hook to 3rd party plugins"); - hookHandler = new HookHandler(this); + hookHandler = new HookHandler(); Benchmark.stop("Enable", "Hook to 3rd party plugins"); ImporterManager.registerImporter(new OfflinePlayerImporter()); diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 3659b6a167..cfe50bd5ea 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -24,9 +24,9 @@ static PlanPlugin getInstance() { boolean bungeeAvailable = Check.isBungeeAvailable(); if (bukkitAvailable && bungeeAvailable) { // TODO Test Plugin - } else if (bungeeAvailable) { - return Plan.getInstance(); } else if (bukkitAvailable) { + return Plan.getInstance(); + } else if (bungeeAvailable) { return PlanBungee.getInstance(); } throw new IllegalAccessError("Plugin instance not available"); diff --git a/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java new file mode 100644 index 0000000000..2bb305721d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java @@ -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 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(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java index 879315e144..9793049cdc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/PlanAPI.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.api; import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; import java.util.Map; @@ -18,7 +19,7 @@ public interface PlanAPI { static PlanAPI getInstance() { - throw new IllegalAccessError("Not yet implemented"); // TODO + return PlanSystem.getInstance().getPlanAPI(); } void addPluginDataSource(PluginData pluginData); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java index ed0f3b7d75..1d30e0d7d5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java @@ -2,8 +2,12 @@ import com.djrapitops.plan.Plan; 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.api.utility.log.Log; +import com.djrapitops.pluginbridge.plan.Bridge; import java.util.*; @@ -14,29 +18,35 @@ * @author Rsl1122 * @since 2.6.0 */ -public class HookHandler { +public class HookHandler implements SubSystem { private final List additionalDataSources; - private final PluginsConfigSection configHandler; + private PluginsConfigSection configHandler; - /** - * Class constructor, hooks to plugins. - * - * @param plugin Current instance of plan. - */ - public HookHandler(Plan plugin) { + public HookHandler() { 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(); try { -// Bridge.hook(this); + Bridge.hook(this); } catch (Exception e) { Log.toLog(this.getClass().getName(), e); Log.error("Plan Plugin Bridge not included in the plugin jar."); } } - public static HookHandler getInstance() { - return null;// TODO + @Override + public void disable() { + } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index bdda879db6..9563b43854 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -6,8 +6,11 @@ import com.djrapitops.plan.Plan; 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.file.FileSystem; +import com.djrapitops.plan.system.info.BukkitInfoSystem; import com.djrapitops.plan.system.info.server.BukkitServerInfo; import com.djrapitops.plan.system.listeners.BukkitListenerSystem; import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; @@ -30,8 +33,12 @@ public BukkitSystem(Plan plugin) { listenerSystem = new BukkitListenerSystem(plugin); taskSystem = new BukkitTaskSystem(plugin); + infoSystem = new BukkitInfoSystem(); serverInfo = new BukkitServerInfo(plugin); + hookHandler = new HookHandler(); + planAPI = new BukkitAPI(this); + StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass()); new ShutdownHook().register(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java index d31e3a1a30..86fc6525fa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.system.database.BungeeDBSystem; 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.listeners.BungeeListenerSystem; import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; @@ -29,7 +29,7 @@ public BungeeSystem(PlanBungee plugin) { listenerSystem = new BungeeListenerSystem(plugin); taskSystem = new BungeeTaskSystem(plugin); - infoSystem = new BukkitInfoSystem(); + infoSystem = new BungeeInfoSystem(); serverInfo = new BungeeServerInfo(plugin); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 2be10b2393..6e185baa27 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -4,7 +4,9 @@ */ package com.djrapitops.plan.system; +import com.djrapitops.plan.api.PlanAPI; 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.database.DBSystem; import com.djrapitops.plan.system.file.FileSystem; @@ -44,6 +46,9 @@ public abstract class PlanSystem implements SubSystem { protected TaskSystem taskSystem; protected ServerInfo serverInfo; + protected HookHandler hookHandler; + protected PlanAPI planAPI; + public PlanSystem() { processingQueue = new ProcessingQueue(); webServerSystem = new WebServerSystem(); @@ -117,6 +122,8 @@ private void checkSubSystemInitialization() throws EnableException { NullCheck.check(serverInfo, new IllegalStateException("ServerInfo 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(hookHandler, new IllegalStateException("Plugin Hooks were not initialized.")); + NullCheck.check(planAPI, new IllegalStateException("Plan API was not initialized.")); } catch (Exception e) { throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e); } @@ -167,4 +174,12 @@ public CacheSystem getCacheSystem() { public InfoSystem getInfoSystem() { return infoSystem; } + + public HookHandler getHookHandler() { + return hookHandler; + } + + public PlanAPI getPlanAPI() { + return planAPI; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java index 7d578ed843..bf4ee88830 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java @@ -8,10 +8,6 @@ import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; 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. @@ -36,13 +32,9 @@ public static CacheSystem getInstance() { @Override public void enable() throws EnableException { - 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); - } + dataCache.enable(); + geolocationCache.enable(); + } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java index a2d907d92a..d3fb5d21c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/DataCache.java @@ -2,6 +2,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.PlanSystem; +import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.log.Log; @@ -21,9 +22,9 @@ * @author Rsl1122 * @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 playerNames; private final Map uuids; private final Map displayNames; @@ -35,13 +36,21 @@ public class DataCache extends SessionCache { */ public DataCache(PlanSystem system) { super(system); - db = system.getDatabaseSystem().getActiveDatabase(); playerNames = new HashMap<>(); displayNames = new HashMap<>(); uuids = new HashMap<>(); } + @Override + public void enable() { + db = system.getDatabaseSystem().getActiveDatabase(); + } + + @Override + public void disable() { + } + public static DataCache getInstance() { DataCache dataCache = CacheSystem.getInstance().getDataCache(); NullCheck.check(dataCache, new IllegalStateException("Data Cache was not initialized.")); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java index 20f43d04bb..7cbd1978ff 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/GeolocationCache.java @@ -1,7 +1,10 @@ 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.utilities.NullCheck; +import com.djrapitops.plugin.api.utility.log.Log; import com.google.common.cache.Cache; import com.maxmind.geoip2.DatabaseReader; import com.maxmind.geoip2.exception.GeoIp2Exception; @@ -13,6 +16,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.URL; +import java.net.UnknownHostException; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.util.HashMap; @@ -29,14 +33,29 @@ * @author Fuzzlemann * @since 3.5.5 */ -public class GeolocationCache { +public class GeolocationCache implements SubSystem { private final Map geolocationCache; - private final File geolocationDB; + private File geolocationDB; public GeolocationCache() { geolocationCache = new HashMap<>(); + } + + @Override + public void enable() throws EnableException { 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() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index ed4e927986..a8c99af8cc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -50,7 +50,7 @@ public void enable() throws EnableException { Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName())); Benchmark.stop("Enable", "Init Database"); } catch (DBInitException e) { - throw new EnableException(db.getName() + "-Database failed to initialize", e); + throw new EnableException("Database failed to initialize", e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java index b1709ac5a2..34cf4fed0e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java @@ -1,7 +1,5 @@ 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.plugin.api.utility.log.Log; import org.apache.commons.dbcp2.BasicDataSource; @@ -16,15 +14,7 @@ public class MySQLDB extends SQLDB { private BasicDataSource dataSource; - private final SQLTransferOps transferOps; - public MySQLDB() { - transferOps = new SQLTransferOps(this); - } - - @Override - public TransferOperations transfer() { - return transferOps; } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 01808fb479..35c73d24ea 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -48,6 +48,7 @@ public abstract class SQLDB extends Database { private final SQLSearchOps searchOps; private final SQLCountOps countOps; private final SQLSaveOps saveOps; + private final SQLTransferOps transferOps; private final boolean usingMySQL; private boolean open = false; @@ -81,7 +82,7 @@ public SQLDB() { countOps = new SQLCountOps(this); searchOps = new SQLSearchOps(this); saveOps = new SQLSaveOps(this); - + transferOps = new SQLTransferOps(this); } /** @@ -390,4 +391,9 @@ public CountOperations count() { public SaveOperations save() { return saveOps; } + + @Override + public TransferOperations transfer() { + return transferOps; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index b140d0ceb5..e9a1f1fd15 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -1,9 +1,7 @@ package com.djrapitops.plan.system.database.databases.sql; 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.system.database.databases.operation.TransferOperations; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.AbsRunnable; @@ -37,11 +35,6 @@ public SQLiteDB(String dbName) { this.dbName = dbName; } - @Override - public TransferOperations transfer() throws UnsupportedTransferDatabaseException { - throw new UnsupportedTransferDatabaseException(this); - } - /** * Setups the {@link BasicDataSource} */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java index e74d959332..985db34e71 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -69,7 +69,7 @@ public void createTable() throws DBCreateTableException { .column(columnSenderID, Sql.INT).notNull() .column(columnExpiry, Sql.LONG).notNull().defaultValue("0") .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. .foreignKey(columnSenderID, serverTable.toString(), serverTable.getColumnID()) .toString() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java index c7dad76ad1..997a9df4c0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java @@ -27,6 +27,9 @@ public BukkitInfoSystem() { @Override protected void runLocally(InfoRequest infoRequest) throws WebException { + if (infoRequest instanceof CacheNetworkPageContentRequest) { + return; + } if (infoRequest instanceof InfoRequestWithVariables) { infoRequest.handleRequest(((InfoRequestWithVariables) infoRequest).getVariables()); } else { 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 ac0ada2369..4f6045e0bc 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 @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.info; 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.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; @@ -57,10 +58,14 @@ public void generateAnalysisPage(UUID serverUUID) 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); } - connectionSystem.sendInfoRequest(infoRequest); } protected abstract void runLocally(InfoRequest infoRequest) throws WebException; @@ -70,6 +75,8 @@ public void enable() throws EnableException { connectionSystem.enable(); try { updateNetworkPage(); + } catch (NoServersException e) { + /* Ignored */ } catch (WebException e) { // TODO Exception handling Log.toLog(this.getClass().getName(), e); @@ -87,7 +94,7 @@ public ConnectionSystem getConnectionSystem() { public abstract void updateNetworkPage() throws WebException; - public void requestSetUp(String address) throws WebException { + public void requestSetUp(String address) { // TODO } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index 71e675d032..c9a58b115f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -77,7 +77,7 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer } } 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; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java index 1273d6de6c..5c256b3953 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java @@ -63,7 +63,7 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer } } 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; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index a51ff1eafa..11dfc3b7ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -67,7 +67,7 @@ public ConnectionOut(Server toServer, UUID serverUUID, InfoRequest infoRequest) public void sendRequest() throws WebException { String address = toServer.getWebAddress(); 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(); if (address.startsWith("https")) { HttpsURLConnection httpsConn = (HttpsURLConnection) connection; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index d83bf9a638..982f6bea58 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -54,11 +54,13 @@ public InfoRequest getInfoRequest(String name) { private Map loadDataRequests() { Map requests = new HashMap<>(); putRequest(requests, CacheInspectPageRequest.createHandler()); + putRequest(requests, CacheInspectPluginsTabRequest.createHandler()); putRequest(requests, CacheAnalysisPageRequest.createHandler()); putRequest(requests, CacheNetworkPageContentRequest.createHandler()); putRequest(requests, GenerateAnalysisPageRequest.createHandler()); putRequest(requests, GenerateInspectPageRequest.createHandler()); + putRequest(requests, GenerateInspectPluginsTabRequest.createHandler()); return requests; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index 9f02cb10fb..a79b52af50 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -24,12 +24,11 @@ */ public abstract class ConfigSystem implements SubSystem { - protected final Config config; + protected Config config; protected final Locale locale; protected final Theme theme; public ConfigSystem() { - config = new Config(FileSystem.getConfigFile()); locale = new Locale(); theme = new Theme(); } @@ -50,6 +49,7 @@ public Theme getThemeSystem() { @Override public void enable() throws EnableException { + config = new Config(FileSystem.getConfigFile()); try { copyDefaults(); config.save(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java index 73326d38d8..93ece4bc62 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/RequestHandler.java @@ -16,7 +16,6 @@ import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; -import java.io.IOException; import java.util.List; /** @@ -50,7 +49,7 @@ public void handle(HttpExchange exchange) { } response.setResponseHeaders(responseHeaders); response.send(exchange); - } catch (IOException e) { + } catch (Exception e) { if (Settings.DEV_MODE.isTrue()) { e.printStackTrace(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 5a33ea9bf6..e5a5a4c5a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -18,6 +18,7 @@ import com.djrapitops.plan.system.webserver.response.errors.UnauthorizedServerResponse; import com.djrapitops.plugin.api.utility.log.Log; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -79,8 +80,10 @@ public void registerWebAPIPages() { public Response getResponse(Request request) { String targetString = request.getTarget(); - List target = Arrays.asList(targetString.split("/")); - target.remove(0); + List target = new ArrayList<>(Arrays.asList(targetString.split("/"))); + if (!target.isEmpty()) { + target.remove(0); + } try { return getResponse(request, targetString, target); } catch (WebUserAuthException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index fc64703157..24e925518a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -1,6 +1,7 @@ package com.djrapitops.plan.system.webserver; import com.djrapitops.plan.PlanPlugin; +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.settings.Settings; @@ -44,17 +45,28 @@ public class WebServer implements SubSystem { private ResponseHandler responseHandler; @Override - public void enable() { + public void enable() throws EnableException { this.port = Settings.WEBSERVER_PORT.getNumber(); + requestHandler = new RequestHandler(this); + responseHandler = requestHandler.getResponseHandler(); + PlanPlugin plugin = PlanPlugin.getInstance(); StaticHolder.saveInstance(RequestHandler.class, plugin.getClass()); StaticHolder.saveInstance(ResponseHandler.class, plugin.getClass()); - requestHandler = new RequestHandler(this); - responseHandler = requestHandler.getResponseHandler(); - 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 @@ -65,7 +77,7 @@ public void disable() { /** * Starts up the WebServer in a new Thread Pool. */ - public void initServer() { + private void initServer() { // Check if Bukkit WebServer has been disabled. if (!Check.isBungeeAvailable() && Settings.WEBSERVER_DISABLED.isTrue()) { return; @@ -86,7 +98,6 @@ public void initServer() { Log.infoColor("§eUser Authorization Disabled! (Not possible over http)"); server = HttpServer.create(new InetSocketAddress(Settings.WEBSERVER_IP.toString(), port), 10); } - server.createContext("/", requestHandler); server.setExecutor(new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(100))); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java index 7d22df88cd..b1f5c4ee07 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServerSystem.java @@ -7,11 +7,8 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.PlanSystem; 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.plugin.api.Benchmark; -import com.djrapitops.plugin.api.Check; -import com.djrapitops.plugin.api.utility.log.Log; /** * WebServer subsystem for managing WebServer initialization. @@ -38,17 +35,7 @@ public static boolean isWebServerEnabled() { @Override public void enable() throws EnableException { Benchmark.start("WebServer Initialization"); - webServer.initServer(); - 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?"); - } - } + webServer.enable(); Benchmark.stop("Enable", "WebServer Initialization"); ResponseHandler responseHandler = webServer.getResponseHandler(); responseHandler.registerWebAPIPages(); From cefe17ead839760857fca9f3973a98adf3bd80e1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 25 Jan 2018 16:02:05 +0200 Subject: [PATCH 057/166] Remove redundant code --- .../main/java/com/djrapitops/plan/Plan.java | 3 - .../java/com/djrapitops/plan/PlanBungee.java | 13 +--- .../api/exceptions/PassEncryptException.java | 10 --- .../plan/command/PlanBungeeCommand.java | 4 +- .../djrapitops/plan/command/PlanCommand.java | 10 +-- .../plan/command/commands/AnalyzeCommand.java | 59 +++++++---------- .../plan/command/commands/DevCommand.java | 6 +- .../plan/command/commands/InfoCommand.java | 7 +- .../plan/command/commands/InspectCommand.java | 11 ++-- .../plan/command/commands/ManageCommand.java | 4 +- .../plan/command/commands/NetworkCommand.java | 6 +- .../command/commands/RegisterCommand.java | 6 +- .../plan/command/commands/SearchCommand.java | 4 +- .../commands/manage/ManageBackupCommand.java | 11 +--- .../commands/manage/ManageImportCommand.java | 4 +- .../djrapitops/plan/data/AnalysisData.java | 9 +-- .../djrapitops/plan/data/PlayerProfile.java | 7 +- .../plan/data/container/UserInfo.java | 12 ---- .../plan/data/element/TableContainer.java | 12 ++-- .../data/plugin/PluginsConfigSection.java | 2 +- .../plan/system/cache/SessionCache.java | 11 ++-- .../plan/system/database/DBSystem.java | 6 +- .../system/database/databases/Database.java | 2 +- .../system/database/databases/sql/SQLDB.java | 5 +- .../databases/sql/tables/ServerTable.java | 7 +- .../plan/system/info/InfoSystem.java | 4 +- .../connection/BukkitConnectionSystem.java | 16 ++--- .../connection/BungeeConnectionSystem.java | 14 ++-- .../system/info/connection/ConnectionLog.java | 11 +--- .../info/connection/ConnectionSystem.java | 4 +- .../request/CacheAnalysisPageRequest.java | 7 ++ .../info/request/CacheInspectPageRequest.java | 7 ++ .../plan/system/info/server/Server.java | 2 +- .../system/info/server/ServerInfoFile.java | 25 -------- .../listeners/BukkitListenerSystem.java | 4 +- .../plan/system/listeners/ListenerSystem.java | 8 --- .../listeners/bukkit/DeathEventListener.java | 19 ++---- .../bukkit/GamemodeChangeListener.java | 14 +--- .../bukkit/PlayerOnlineListener.java | 5 +- .../system/processing/ProcessingQueue.java | 5 -- .../plan/system/processing/Processor.java | 36 +++++++++++ .../processors/CommandProcessor.java | 2 +- .../processors/NewNickActionProcessor.java | 47 -------------- .../{Processor.java => ObjectProcessor.java} | 17 ++--- .../processors/TPSInsertProcessor.java | 2 +- .../info/InspectCacheRequestProcessor.java | 2 +- .../info/NetworkPageUpdateProcessor.java | 8 +-- .../processors/player/DeathProcessor.java | 32 ---------- .../processors/player/KillProcessor.java | 3 - .../processors/player/NameProcessor.java | 24 +++++-- .../processors/player/PlayerProcessor.java | 4 +- .../processors/player/RegisterProcessor.java | 7 +- .../system/settings/WorldAliasSettings.java | 2 +- .../system/settings/config/ConfigSystem.java | 2 +- .../plan/system/settings/locale/Locale.java | 2 +- .../plan/system/webserver/Request.java | 4 -- .../webserver/auth/BasicAuthentication.java | 2 - .../webserver/pages/parsing/InspectPage.java | 15 ++--- .../response/errors/ForbiddenResponse.java | 3 +- .../response/errors/NotFoundResponse.java | 3 +- .../plan/system/webserver/webapi/WebAPI.java | 44 ------------- .../webserver/webapi/WebAPIManager.java | 60 ----------------- .../webapi/bukkit/AnalysisReadyWebAPI.java | 34 ---------- .../webapi/bukkit/AnalyzeWebAPI.java | 34 ---------- .../webapi/bukkit/ConfigurationWebAPI.java | 4 +- .../webapi/bukkit/InspectWebAPI.java | 40 ------------ .../webapi/bukkit/IsOnlineWebAPI.java | 47 -------------- .../RequestInspectPluginsTabBukkitWebAPI.java | 54 ---------------- .../webapi/bungee/IsCachedWebAPI.java | 59 ----------------- .../webapi/bungee/PostHtmlWebAPI.java | 45 ------------- .../bungee/PostInspectPluginsTabWebAPI.java | 60 ----------------- .../bungee/PostNetworkPageContentWebAPI.java | 47 -------------- .../PostOriginalBukkitSettingsWebAPI.java | 3 +- .../bungee/RequestPluginsTabWebAPI.java | 56 ---------------- .../webapi/bungee/RequestSetupWebAPI.java | 39 ----------- .../plan/utilities/FormatUtils.java | 4 +- .../plan/utilities/ManageUtils.java | 2 - .../djrapitops/plan/utilities/MiscUtils.java | 2 +- .../utilities/analysis/AnalysisUtils.java | 2 - .../analysis/DouglasPeuckerAlgorithm.java | 5 +- .../plan/utilities/analysis/Line.java | 6 +- .../plan/utilities/analysis/MathUtils.java | 32 +--------- .../utilities/comparators/MapComparator.java | 14 ---- .../comparators/PieSliceComparator.java | 4 +- ...parator.java => PlayerKillComparator.java} | 2 +- .../comparators/PluginDataNameComparator.java | 2 +- .../comparators/PointComparator.java | 2 + .../comparators/SessionLengthComparator.java | 2 + .../comparators/SessionStartComparator.java | 2 + .../utilities/file/export/AnalysisExport.java | 6 ++ .../utilities/file/export/HtmlExport.java | 5 +- .../utilities/file/export/PlayerExport.java | 6 ++ .../utilities/file/export/SpecificExport.java | 2 +- .../plan/utilities/html/HtmlStructure.java | 9 --- .../structure/SessionTabStructureCreator.java | 4 +- .../utilities/html/tables/ActionsTable.java | 45 +++++++++++++ .../html/tables/ActionsTableCreator.java | 50 --------------- .../html/tables/CommandUseTable.java | 41 ++++++++++++ .../html/tables/CommandUseTableCreator.java | 53 --------------- .../utilities/html/tables/GeoInfoTable.java | 40 ++++++++++++ .../html/tables/GeoInfoTableCreator.java | 42 ------------ .../utilities/html/tables/KillsTable.java | 52 +++++++++++++++ .../html/tables/KillsTableCreator.java | 64 ------------------- .../utilities/html/tables/NicknameTable.java | 42 ++++++++++++ .../html/tables/NicknameTableCreator.java | 40 ------------ .../plan/utilities/queue/Consumer.java | 2 - .../java/com/djrapitops/plan/api/API.java | 2 - 107 files changed, 464 insertions(+), 1341 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/processing/Processor.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java rename Plan/src/main/java/com/djrapitops/plan/system/processing/processors/{Processor.java => ObjectProcessor.java} (53%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java rename Plan/src/main/java/com/djrapitops/plan/utilities/comparators/{KillDataComparator.java => PlayerKillComparator.java} (81%) create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTable.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTable.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTableCreator.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTable.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTableCreator.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTable.java delete mode 100644 Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTableCreator.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index fad8fb4736..b4637e8070 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -43,9 +43,6 @@ /** * Main class for Bukkit that manages the plugin. - *

    - * Everything can be accessed through this class. Use Plan.getInstance() to get - * the initialised instance of Plan. * * @author Rsl1122 * @since 1.0.0 diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index d063b03a53..f61495c84f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -8,8 +8,7 @@ import com.djrapitops.plan.system.BungeeSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.info.server.BungeeServerInfo; -import com.djrapitops.plan.system.info.server.ServerProperties; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.theme.PlanColorScheme; @@ -34,9 +33,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { private BungeeSystem system; - private BungeeServerInfo serverInfoManager; - private ServerProperties variableHolder; - @Deprecated private boolean setupAllowed = false; @@ -52,7 +48,7 @@ public void onEnable() { system.enable(); // TODO BungeeServerInfo & move there. - String ip = variableHolder.getIp(); + String ip = ServerInfo.getServerProperties().getIp(); if ("0.0.0.0".equals(ip)) { Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); Log.info("Player Analytics partially enabled (Use /planbungee to reload config)"); @@ -108,11 +104,6 @@ public ColorScheme getColorScheme() { return PlanColorScheme.create(); } - @Deprecated - public ServerProperties getVariable() { - return variableHolder; - } - @Deprecated public boolean isSetupAllowed() { return setupAllowed; diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java index 8c5a12b0fb..4962480277 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/PassEncryptException.java @@ -2,9 +2,6 @@ public class PassEncryptException extends Exception { - public PassEncryptException() { - } - public PassEncryptException(String s) { super(s); } @@ -13,11 +10,4 @@ public PassEncryptException(String s, Throwable throwable) { super(s, throwable); } - public PassEncryptException(Throwable throwable) { - super(throwable); - } - - public PassEncryptException(String s, Throwable throwable, boolean b, boolean b1) { - super(s, throwable, b, b1); - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java index 1ee1528788..ac0f802b62 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java @@ -45,11 +45,11 @@ public void addCommands() { new ListCommand(), new BungeeSetupToggleCommand(plugin) ); - RegisterCommand registerCommand = new RegisterCommand(plugin); + RegisterCommand registerCommand = new RegisterCommand(); add( registerCommand, new WebUserCommand(plugin, registerCommand), - new NetworkCommand(plugin), + new NetworkCommand(), new ListServersCommand(plugin) ); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java index 8e7ba2efec..ec060ea6a7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java @@ -43,23 +43,23 @@ public void addCommands() { add( new InspectCommand(plugin), new QInspectCommand(plugin), - new AnalyzeCommand(plugin), - new SearchCommand(plugin), + new AnalyzeCommand(), + new SearchCommand(), new InfoCommand(plugin), new ReloadCommand(plugin), new ManageCommand(plugin), new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()), new ListCommand() ); - RegisterCommand registerCommand = new RegisterCommand(plugin); + RegisterCommand registerCommand = new RegisterCommand(); add( registerCommand, new WebUserCommand(plugin, registerCommand), - new NetworkCommand(plugin), + new NetworkCommand(), new ListServersCommand(plugin)); if (Settings.DEV_MODE.isTrue()) { - add(new DevCommand(plugin)); + add(new DevCommand()); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index dc3aeb4283..25cd0b7e1c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; @@ -9,7 +8,7 @@ import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -20,8 +19,6 @@ import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; -import com.djrapitops.plugin.task.AbsRunnable; -import com.djrapitops.plugin.task.RunnableFactory; import org.bukkit.ChatColor; import java.util.Map; @@ -39,9 +36,8 @@ public class AnalyzeCommand extends SubCommand { /** * Subcommand Constructor. * - * @param plugin Current instance of Plan */ - public AnalyzeCommand(Plan plugin) { + public AnalyzeCommand() { super("analyze, analyse, analysis, a", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), @@ -58,24 +54,21 @@ public String[] addHelp() { public boolean onCommand(ISender sender, String commandLabel, String[] args) { sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString()); - new Processor(sender) { - @Override - public void process() { - try { - Server server = getServer(args).orElseGet(ServerInfo::getServer); - UUID serverUUID = server.getUuid(); - if (!ServerInfo.getServerUUID().equals(serverUUID) || !Analysis.isAnalysisBeingRun()) { - InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(serverUUID)); - } - sendWebUserNotificationIfNecessary(sender); - sendLink(server, sender); - } catch (DBException | WebException e) { - // TODO Exception handling - sender.sendMessage(ChatColor.RED + " Error occurred: " + e.toString()); - Log.toLog(this.getClass().getName(), e); + Processor.queue(() -> { + try { + Server server = getServer(args).orElseGet(ServerInfo::getServer); + UUID serverUUID = server.getUuid(); + if (!ServerInfo.getServerUUID().equals(serverUUID) || !Analysis.isAnalysisBeingRun()) { + InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(serverUUID)); } + sendWebUserNotificationIfNecessary(sender); + sendLink(server, sender); + } catch (DBException | WebException e) { + // TODO Exception handling + sender.sendMessage(ChatColor.RED + " Error occurred: " + e.toString()); + Log.toLog(this.getClass().getName(), e); } - }.queue(); + }); return true; } @@ -97,21 +90,17 @@ private void sendLink(Server server, ISender sender) { private void sendWebUserNotificationIfNecessary(ISender sender) { if (WebServerSystem.getInstance().getWebServer().isAuthRequired() && CommandUtils.isPlayer(sender)) { - RunnableFactory.createNew(new AbsRunnable("WebUser exist check task") { - @Override - public void run() { - try { - boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName()); - if (!senderHasWebUser) { - sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); - } - } catch (Exception e) { - Log.toLog(this.getClass().getName() + getName(), e); - } finally { - this.cancel(); + + Processor.queue(() -> { + try { + boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName()); + if (!senderHasWebUser) { + sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); } + } catch (Exception e) { + Log.toLog(this.getClass().getName() + getName(), e); } - }).runTaskAsynchronously(); + }); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java index 5aa5af2c08..7021b997ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/DevCommand.java @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -20,11 +19,8 @@ */ public class DevCommand extends SubCommand { - private final Plan plugin; - - public DevCommand(Plan plugin) { + public DevCommand() { super("dev", CommandType.PLAYER_OR_ARGS, "plan.*", "Test Plugin functions not testable with unit tests.", ""); - this.plugin = plugin; } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java index e1c5f4bf61..1d826081ec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InfoCommand.java @@ -1,9 +1,11 @@ package com.djrapitops.plan.command.commands; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.SubCommand; @@ -40,10 +42,13 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { String sColor = cs.getSecondaryColor(); String tColor = cs.getTertiaryColor(); String ball = Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString(); + + String upToDate = VersionCheckSystem.isNewVersionAvailable() ? "Update Available" : "Up to date"; String[] messages = { Locale.get(Msg.CMD_HEADER_INFO).toString(), ball + mColor + " Version: " + sColor + plugin.getDescription().getVersion(), - ball + mColor + " Active Database: " + tColor + plugin.getDB().getConfigName(), + ball + mColor + " Up to date: " + sColor + upToDate, + ball + mColor + " Active Database: " + tColor + Database.getActive().getConfigName(), Locale.get(Msg.CMD_CONSTANT_FOOTER).toString() }; sender.sendMessage(messages); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index a0556bb31b..b4b50ac8ed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -83,13 +83,12 @@ public void run() { } } new InspectCacheRequestProcessor(uuid, sender, playerName).queue(); + } catch (FatalDBException ex) { + Log.toLog(this.getClass().getName(), ex); + sender.sendMessage(ChatColor.RED + "Fatal database exception occurred: " + ex.getMessage()); } catch (DBException ex) { - if (ex instanceof FatalDBException) { - Log.toLog(this.getClass().getName(), ex); - sender.sendMessage(ChatColor.RED + "Fatal database exception occurred: " + ex.getMessage()); - } else { - sender.sendMessage(ChatColor.YELLOW + "Non-Fatal database exception occurred: " + ex.getMessage()); - } + Log.toLog(this.getClass().getName(), ex); + sender.sendMessage(ChatColor.YELLOW + "Non-Fatal database exception occurred: " + ex.getMessage()); } finally { this.cancel(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java index 1726cc496c..b3a035ec3a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java @@ -38,9 +38,9 @@ public void addCommands() { add( new ManageMoveCommand(plugin), new ManageHotswapCommand(plugin), - new ManageBackupCommand(plugin), + new ManageBackupCommand(), new ManageRestoreCommand(plugin), - new ManageImportCommand(plugin), + new ManageImportCommand(), new ManageRemoveCommand(plugin), new ManageClearCommand(plugin), new ManageSetupCommand(plugin), 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 fe23026221..57f89eca5f 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 @@ -1,6 +1,5 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; @@ -20,17 +19,14 @@ */ public class NetworkCommand extends SubCommand { - private final PlanPlugin plugin; - /** * Class Constructor. */ - public NetworkCommand(PlanPlugin plugin) { + public NetworkCommand() { super("network, n, netw", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), "Get the link to the network page"); - this.plugin = plugin; } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index 74f32c9c52..96487c5b4c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; @@ -31,15 +30,12 @@ */ public class RegisterCommand extends SubCommand { - private final PlanPlugin plugin; - - public RegisterCommand(PlanPlugin plugin) { + public RegisterCommand() { super("register", CommandType.PLAYER_OR_ARGS, "", // No Permission Requirement Locale.get(Msg.CMD_USG_WEB_REGISTER).toString(), " [name] [access lvl]"); - this.plugin = plugin; if (Check.isBukkitAvailable()) { setupFilter(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java index c0538e04b7..f177e96bee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -28,9 +27,8 @@ public class SearchCommand extends SubCommand { /** * Class Constructor. * - * @param plugin Current instance of Plan */ - public SearchCommand(Plan plugin) { + public SearchCommand() { super("search", CommandType.PLAYER_OR_ARGS, Permissions.SEARCH.getPermission(), diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java index 0b485b18ca..01604a48f7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageBackupCommand.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.command.commands.manage; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; @@ -24,21 +23,13 @@ */ public class ManageBackupCommand extends SubCommand { - private final Plan plugin; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public ManageBackupCommand(Plan plugin) { + public ManageBackupCommand() { super("backup", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE_BACKUP).toString(), ""); - this.plugin = plugin; } @Override 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 28ea80b7cc..cefb1a4651 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 @@ -1,6 +1,5 @@ package com.djrapitops.plan.command.commands.manage; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.processing.importing.ImporterManager; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; @@ -25,9 +24,8 @@ public class ManageImportCommand extends SubCommand { /** * Class Constructor. * - * @param plugin Current instance of Plan */ - public ManageImportCommand(Plan plugin) { + public ManageImportCommand() { super("import", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java index baad80760d..1589ff4d84 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java @@ -17,7 +17,6 @@ import com.djrapitops.plan.utilities.analysis.MathUtils; import com.djrapitops.plan.utilities.comparators.SessionStartComparator; import com.djrapitops.plan.utilities.html.Html; -import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plan.utilities.html.graphs.ActivityStackGraph; import com.djrapitops.plan.utilities.html.graphs.PunchCardGraph; import com.djrapitops.plan.utilities.html.graphs.WorldMap; @@ -26,7 +25,7 @@ import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie; import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator; import com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator; -import com.djrapitops.plan.utilities.html.tables.CommandUseTableCreator; +import com.djrapitops.plan.utilities.html.tables.CommandUseTable; import com.djrapitops.plan.utilities.html.tables.SessionsTableCreator; import com.djrapitops.plugin.api.TimeAmount; @@ -88,10 +87,6 @@ private void addConstants() { addValue("playersOnline", ServerProfile.getPlayersOnline()); } - public long getRefreshDate() { - return refreshDate; - } - public void analyze(ServerProfile profile) { long now = MiscUtils.getTime(); refreshDate = now; @@ -167,7 +162,7 @@ private void healthTab(long now, List players, List tpsDataM private void commandUsage(Map commandUsage) { addValue("commandUniqueCount", String.valueOf(commandUsage.size())); addValue("commandCount", MathUtils.sumInt(commandUsage.values().stream().map(i -> (int) i))); - addValue("tableBodyCommands", HtmlUtils.removeXSS(CommandUseTableCreator.createTable(commandUsage))); + addValue("tableBodyCommands", new CommandUseTable(commandUsage).parseBody()); } private void geolocationsTab(List geoLocations) { diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index 6a41170914..ca4b02b6ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -128,12 +128,7 @@ public static long getMobKillCount(Stream s) { // Calculating Getters public ActivityIndex getActivityIndex(long date) { - ActivityIndex index = activityIndexCache.get(date); - if (index == null) { - index = new ActivityIndex(this, date); - activityIndexCache.put(date, index); - } - return index; + return activityIndexCache.computeIfAbsent(date, dateValue -> new ActivityIndex(this, dateValue)); } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/UserInfo.java b/Plan/src/main/java/com/djrapitops/plan/data/container/UserInfo.java index 6c99b9c742..35cb710340 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/UserInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/UserInfo.java @@ -38,18 +38,10 @@ public String getName() { return name; } - public void setName(String name) { - this.name = name; - } - public long getRegistered() { return registered; } - public void setRegistered(long registered) { - this.registered = registered; - } - public long getLastSeen() { return lastSeen; } @@ -62,10 +54,6 @@ public boolean isBanned() { return banned; } - public void setBanned(boolean banned) { - this.banned = banned; - } - public boolean isOpped() { return opped; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java index 759f04344a..6a3ced105a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/TableContainer.java @@ -16,7 +16,7 @@ * * @author Rsl1122 */ -public final class TableContainer { +public class TableContainer { private final String[] header; private List values; @@ -38,18 +38,18 @@ public TableContainer(boolean players, String... header) { values = new ArrayList<>(); } - public void addRow(Serializable... values) { + public final void addRow(Serializable... values) { this.values.add(values); } - public String parseHtml() { + public final String parseHtml() { return Html.TABLE_SCROLL.parse() + parseHeader() + parseBody() + "

    "; } - private String parseBody() { + public final String parseBody() { StringBuilder body = new StringBuilder(); if (values.isEmpty()) { @@ -73,11 +73,11 @@ private String parseBody() { return Html.TABLE_BODY.parse(body.toString()); } - public void setColor(String color) { + public final void setColor(String color) { this.color = color; } - public String parseHeader() { + public final String parseHeader() { StringBuilder header = new StringBuilder(""); for (String title : this.header) { header.append("").append(title).append(""); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java index 598e1bc001..b37cb143e0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/PluginsConfigSection.java @@ -23,7 +23,7 @@ public boolean hasSection(PluginData dataSource) { } private ConfigNode getPluginsSection() { - return ConfigSystem.getInstance().getConfig().getConfigNode("Plugins"); + return ConfigSystem.getConfig().getConfigNode("Plugins"); } public void createSection(PluginData dataSource) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java index b84dab53d5..6070b67d97 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/cache/SessionCache.java @@ -5,7 +5,7 @@ import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.connection.WebExceptionLogger; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.log.Log; @@ -57,12 +57,9 @@ public static void clear() { public void cacheSession(UUID uuid, Session session) { activeSessions.put(uuid, session); - new Processor(system) { - @Override - public void process() { - WebExceptionLogger.logIfOccurs(this.getClass(), () -> system.getInfoSystem().generateAndCachePlayerPage(uuid)); - } - }.queue(); + Processor.queue(() -> WebExceptionLogger.logIfOccurs(this.getClass(), () -> + system.getInfoSystem().generateAndCachePlayerPage(uuid)) + ); } public void endSession(UUID uuid, long time) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index a8c99af8cc..f60527b532 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -46,7 +46,7 @@ public void enable() throws EnableException { Benchmark.start("Init Database"); Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString()); initDatabase(); - db.scheduleClean(10L); + db.scheduleClean(1L); Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName())); Benchmark.stop("Enable", "Init Database"); } catch (DBInitException e) { @@ -60,10 +60,6 @@ public Set getDatabases() { return databases; } - public void setDatabases(Set databases) { - this.databases = databases; - } - @Override public void disable() { try { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index 59ace042b1..dff787a037 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -17,7 +17,7 @@ */ public abstract class Database { - private boolean open; + protected boolean open = false; public static Database getActive() { Database database = DBSystem.getInstance().getActiveDatabase(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 35c73d24ea..3f088be73d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -51,7 +51,6 @@ public abstract class SQLDB extends Database { private final SQLTransferOps transferOps; private final boolean usingMySQL; - private boolean open = false; private ITask dbCleanTask; public SQLDB() { @@ -103,7 +102,6 @@ public void init() throws DBInitException { try { setupDataSource(); setupDatabase(); - open = true; } finally { Benchmark.stop("Database", benchName); Log.logDebug("Database"); @@ -229,8 +227,8 @@ public Table[] getAllTablesInRemoveOrder() { @Override public void close() { - setStatus("Closed"); open = false; + setStatus("Closed"); Log.logDebug("Database"); // Log remaining Debug info if present if (dbCleanTask != null) { dbCleanTask.cancel(); @@ -248,6 +246,7 @@ public void setVersion(int version) throws SQLException { private void clean() throws SQLException { Log.info("Cleaning the database."); tpsTable.clean(); + transferTable.clean(); Log.info("Clean complete."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java index 15a41f0f11..53e8e36dce 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java @@ -412,12 +412,7 @@ public Optional processResults(ResultSet set) throws SQLException { public int getMaxPlayers() throws SQLException { String sql = "SELECT SUM(" + columnMaxPlayers + ") AS max FROM " + tableName; - return query(new QueryStatement(sql) { - @Override - public void prepare(PreparedStatement statement) { - - } - + return query(new QueryAllStatement(sql) { @Override public Integer processResults(ResultSet set) throws SQLException { if (set.next()) { 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 4f6045e0bc..dc51f738d3 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 @@ -7,6 +7,7 @@ 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.WebFailException; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem; @@ -94,7 +95,8 @@ public ConnectionSystem getConnectionSystem() { public abstract void updateNetworkPage() throws WebException; - public void requestSetUp(String address) { + public void requestSetUp(String address) throws WebException { // TODO + throw new WebFailException(""); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index c9a58b115f..0c15fee695 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -20,8 +20,6 @@ import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.RunnableFactory; -import java.util.HashMap; -import java.util.Map; import java.util.Optional; import java.util.UUID; @@ -35,10 +33,8 @@ public class BukkitConnectionSystem extends ConnectionSystem { private long latestServerMapRefresh; private Server mainServer; - private Map servers; public BukkitConnectionSystem() { - servers = new HashMap<>(); latestServerMapRefresh = 0; } @@ -48,7 +44,7 @@ private void refreshServerMap() { Database database = Database.getActive(); Optional bungeeInformation = database.fetch().getBungeeInformation(); bungeeInformation.ifPresent(server -> mainServer = server); - servers = database.fetch().getBukkitServers(); + bukkitServers = database.fetch().getBukkitServers(); latestServerMapRefresh = MiscUtils.getTime(); } catch (DBException e) { Log.toLog(this.getClass().getName(), e); @@ -60,7 +56,7 @@ private void refreshServerMap() { protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException { refreshServerMap(); - if (mainServer == null && servers.isEmpty()) { + if (mainServer == null && bukkitServers.isEmpty()) { throw new NoServersException("No Servers available to process requests."); } @@ -69,11 +65,11 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer server = mainServer; } else if (infoRequest instanceof GenerateAnalysisPageRequest) { UUID serverUUID = ((GenerateAnalysisPageRequest) infoRequest).getServerUUID(); - server = servers.get(serverUUID); + server = bukkitServers.get(serverUUID); } else if (infoRequest instanceof GenerateInspectPageRequest) { Optional serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); if (serverUUID.isPresent()) { - server = servers.getOrDefault(serverUUID.get(), ServerInfo.getServer()); + server = bukkitServers.getOrDefault(serverUUID.get(), ServerInfo.getServer()); } } if (server == null) { @@ -84,10 +80,10 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer @Override public void sendWideInfoRequest(WideRequest infoRequest) throws NoServersException { - if (servers.isEmpty()) { + if (bukkitServers.isEmpty()) { throw new NoServersException("No Servers Available to make process request."); } - for (Server server : servers.values()) { + for (Server server : bukkitServers.values()) { WebExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server)); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java index 5c256b3953..5a08412def 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java @@ -17,8 +17,6 @@ import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.RunnableFactory; -import java.util.HashMap; -import java.util.Map; import java.util.Optional; import java.util.UUID; @@ -30,17 +28,15 @@ public class BungeeConnectionSystem extends ConnectionSystem { private long latestServerMapRefresh; - private Map servers; public BungeeConnectionSystem() { - servers = new HashMap<>(); latestServerMapRefresh = 0; } private void refreshServerMap() { if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.MINUTE.ms() * 2L) { try { - servers = Database.getActive().fetch().getBukkitServers(); + bukkitServers = Database.getActive().fetch().getBukkitServers(); latestServerMapRefresh = MiscUtils.getTime(); } catch (DBException e) { Log.toLog(this.getClass().getName(), e); @@ -55,11 +51,11 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer throw new NoServersException("Bungee should not send Cache requests."); } else if (infoRequest instanceof GenerateAnalysisPageRequest) { UUID serverUUID = ((GenerateAnalysisPageRequest) infoRequest).getServerUUID(); - server = servers.get(serverUUID); + server = bukkitServers.get(serverUUID); } else if (infoRequest instanceof GenerateInspectPageRequest) { Optional serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); if (serverUUID.isPresent()) { - server = servers.getOrDefault(serverUUID.get(), ServerInfo.getServer()); + server = bukkitServers.getOrDefault(serverUUID.get(), ServerInfo.getServer()); } } if (server == null) { @@ -70,10 +66,10 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer @Override public void sendWideInfoRequest(WideRequest infoRequest) throws NoServersException { - if (servers.isEmpty()) { + if (bukkitServers.isEmpty()) { throw new NoServersException("No Servers Available to make process request."); } - for (Server server : servers.values()) { + for (Server server : bukkitServers.values()) { WebExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server)); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java index 366811aab3..8e35a2d818 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java @@ -43,11 +43,8 @@ public static boolean isConnectionPlausible(Server server) { } Map serverLog = getInstance().getLog().get(server); - if (Verify.isEmpty(serverLog)) { - return true; - } + return Verify.isEmpty(serverLog) || hasConnectionSucceeded(serverLog); - return hasConnectionSucceeded(serverLog); } public static boolean hasConnectionSucceeded(Server server) { @@ -55,11 +52,9 @@ public static boolean hasConnectionSucceeded(Server server) { return false; } Map serverLog = getInstance().getLog().get(server); - if (Verify.isEmpty(serverLog)) { - return false; - } + return !Verify.isEmpty(serverLog) + && hasConnectionSucceeded(serverLog); - return hasConnectionSucceeded(serverLog); } private static boolean hasConnectionSucceeded(Map serverLog) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 982f6bea58..d8cc0d87ec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -33,10 +33,10 @@ public abstract class ConnectionSystem implements SubSystem { protected final ConnectionLog connectionLog; protected final Map dataRequests; - protected Map servers; + protected Map bukkitServers; public ConnectionSystem() { - servers = new HashMap<>(); + bukkitServers = new HashMap<>(); dataRequests = loadDataRequests(); connectionLog = new ConnectionLog(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java index c355695f28..0cf8b50d90 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java @@ -8,12 +8,15 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.processing.Processor; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pages.DefaultResponses; 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.utilities.Base64Util; +import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.utilities.Verify; import java.util.Map; @@ -63,11 +66,15 @@ public Response handleRequest(Map variables) throws WebException try { Map pages = Database.getActive().transfer().getEncodedServerHtml(); + boolean export = Settings.ANALYSIS_EXPORT.isTrue(); for (Map.Entry entry : pages.entrySet()) { UUID serverUUID = entry.getKey(); String html = Base64Util.decode(entry.getValue()); ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); + if (export) { + Processor.queue(() -> HtmlExport.exportServer(serverUUID)); + } } } catch (DBException e) { throw new TransferDatabaseException(e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index 3ff1a0ee09..241d19fb67 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -8,12 +8,15 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.processing.Processor; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.pages.DefaultResponses; 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.InspectPageResponse; import com.djrapitops.plan.utilities.Base64Util; +import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.utilities.Verify; import java.util.Map; @@ -63,11 +66,15 @@ public Response handleRequest(Map variables) throws WebException try { Map pages = Database.getActive().transfer().getEncodedPlayerHtml(); + boolean export = Settings.ANALYSIS_EXPORT.isTrue(); for (Map.Entry entry : pages.entrySet()) { UUID uuid = entry.getKey(); String html = Base64Util.decode(entry.getValue()); ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(uuid, html)); + if (export) { + Processor.queue(() -> HtmlExport.exportPlayer(uuid)); + } } } catch (DBException e) { throw new TransferDatabaseException(e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java index cd54ad203e..84be99fd98 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/Server.java @@ -17,7 +17,7 @@ public class Server { private int id; private String name; private String webAddress; - private int maxPlayers = -1; + private int maxPlayers; public Server(int id, UUID uuid, String name, String webAddress, int maxPlayers) { this.id = id; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java index e3f12d5c37..b2dc6a15d6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerInfoFile.java @@ -6,7 +6,6 @@ import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plugin.api.config.Config; -import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; import java.io.File; @@ -42,28 +41,4 @@ public Optional getUUID() { return Optional.of(UUID.fromString(uuidString)); } - public String getBungeeWebAddress() { - return getString("Bungee.WebAddress"); - } - - public int markConnectionFail() { - try { - int fails = getInt("Bungee.Fail"); - set("Bungee.Fail", fails + 1); - save(); - return fails; - } catch (IOException e) { - Log.toLog(this.getClass().getName(), e); - } - return -1; - } - - public void resetConnectionFails() { - try { - set("Bungee.Fail", 0); - save(); - } catch (IOException e) { - Log.toLog(this.getClass().getName(), e); - } - } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java index 12191c9a93..1d2d4c1079 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/BukkitListenerSystem.java @@ -17,10 +17,10 @@ protected void registerListeners() { plugin.registerListener( new PlayerOnlineListener(), new ChatListener(), - new GamemodeChangeListener(plugin), + new GamemodeChangeListener(), new WorldChangeListener(), new CommandPreprocessListener(plugin), - new DeathEventListener(plugin) + new DeathEventListener() ); PlayerOnlineListener.setCountKicks(true); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java index e5c22ab805..4b4e717d1a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java @@ -1,18 +1,10 @@ package com.djrapitops.plan.system.listeners; -import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; public abstract class ListenerSystem implements SubSystem { - public static ListenerSystem getInstance() { - ListenerSystem listenerSystem = PlanSystem.getInstance().getListenerSystem(); - NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); - return listenerSystem; - } - @Override public void enable() { Benchmark.start("Register Listeners"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java index 67687c794c..6f58050727 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/DeathEventListener.java @@ -1,7 +1,8 @@ package com.djrapitops.plan.system.listeners.bukkit; -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.processing.processors.player.DeathProcessor; +import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.system.cache.SessionCache; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.processing.processors.player.KillProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; @@ -23,17 +24,6 @@ */ public class DeathEventListener implements Listener { - private final Plan plugin; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public DeathEventListener(Plan plugin) { - this.plugin = plugin; - } - /** * Command use listener. * @@ -46,7 +36,8 @@ public void onDeath(EntityDeathEvent event) { LivingEntity dead = event.getEntity(); if (dead instanceof Player) { - new DeathProcessor(dead.getUniqueId()).queue(); + // Process Death + Processor.queue(() -> SessionCache.getCachedSession(dead.getUniqueId()).ifPresent(Session::died)); } try { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java index 39956f151d..3e04d6a62d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/GamemodeChangeListener.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.listeners.bukkit; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.settings.WorldAliasSettings; @@ -22,17 +21,6 @@ */ public class GamemodeChangeListener implements Listener { - private final Plan plugin; - - /** - * Class Constructor. - * - * @param plugin Current instance of Plan - */ - public GamemodeChangeListener(Plan plugin) { - this.plugin = plugin; - } - /** * GM Change Event Listener. * @@ -52,7 +40,7 @@ public void onGamemodeChange(PlayerGameModeChangeEvent event) { new WorldAliasSettings().addWorld(worldName); - Optional cachedSession = SessionCache.getInstance().getCachedSession(uuid); + Optional cachedSession = SessionCache.getCachedSession(uuid); cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time)); } catch (Exception e) { Log.toLog(this.getClass(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index ea7b134c4d..d69935576f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.cache.SessionCache; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; import com.djrapitops.plan.system.processing.processors.player.*; import com.djrapitops.plan.system.tasks.TaskSystem; @@ -101,7 +101,8 @@ public void onPlayerJoin(PlayerJoinEvent event) { new IPUpdateProcessor(uuid, ip, time), new NameProcessor(uuid, playerName, displayName) ), - new NetworkPageUpdateProcessor()); + new NetworkPageUpdateProcessor() + ); } catch (Exception e) { Log.toLog(this.getClass(), e); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index 467e8735f9..3df7403f79 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -3,7 +3,6 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.system.processing.processors.Processor; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plan.utilities.queue.Consumer; import com.djrapitops.plan.utilities.queue.Queue; @@ -98,10 +97,6 @@ protected void consume(Processor process) { Log.toLog(this.getTaskName() + ":" + process.getClass().getSimpleName(), e); } } - - @Override - protected void clearVariables() { - } } class ProcessSetup extends Setup { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/Processor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/Processor.java new file mode 100644 index 0000000000..d65f6d724d --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/Processor.java @@ -0,0 +1,36 @@ +/* + * 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; + +/** + * Interface for ProcessingQueue. + *

    + * Allows lambda Processor creation. + * + * @author Rsl1122 + */ +public interface Processor { + + static void queueMany(Processor... processors) { + ProcessingQueue processingQueue = ProcessingQueue.getInstance(); + for (Processor processor : processors) { + processingQueue.queue(processor); + } + } + + /** + * A way to run code Async in ProcessingQueue. + *

    + * Good for lambdas. + * + * @param processor Processor. + */ + static void queue(Processor processor) { + ProcessingQueue.getInstance().queue(processor); + } + + void process(); + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java index e107873c72..875393bb6e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/CommandProcessor.java @@ -13,7 +13,7 @@ * * @author Rsl1122 */ -public class CommandProcessor extends Processor { +public class CommandProcessor extends ObjectProcessor { public CommandProcessor(String object) { super(object); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java deleted file mode 100644 index f47a9f7746..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/NewNickActionProcessor.java +++ /dev/null @@ -1,47 +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.system.processing.processors; - -import com.djrapitops.plan.api.exceptions.database.DBException; -import com.djrapitops.plan.data.Actions; -import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor; -import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plan.utilities.html.HtmlUtils; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.util.UUID; - -/** - * Processor for inserting a Name Change action to the Actions table. - * - * @author Rsl1122 - * @since 4.0.0 - */ -public class NewNickActionProcessor extends PlayerProcessor { - - private final String displayName; - - public NewNickActionProcessor(UUID uuid, String displayName) { - super(uuid); - this.displayName = displayName; - } - - @Override - public void process() { - UUID uuid = getUUID(); - - String info = HtmlUtils.removeXSS(displayName); - - Action action = new Action(MiscUtils.getTime(), Actions.NEW_NICKNAME, info); - - try { - Database.getActive().save().action(uuid, action); - } catch (DBException e) { - Log.toLog(this.getClass().getName(), e); - } - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/ObjectProcessor.java similarity index 53% rename from Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java rename to Plan/src/main/java/com/djrapitops/plan/system/processing/processors/ObjectProcessor.java index 7c87c80594..970978a8b5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/Processor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/ObjectProcessor.java @@ -4,34 +4,27 @@ */ package com.djrapitops.plan.system.processing.processors; -import com.djrapitops.plan.system.processing.ProcessingQueue; +import com.djrapitops.plan.system.processing.Processor; /** * Abstract class for processing different objects using Generics. * * @author Rsl1122 */ -public abstract class Processor { +public abstract class ObjectProcessor implements Processor { protected final T object; - public Processor(T object) { + public ObjectProcessor(T object) { this.object = object; } - public static void queueMany(Processor... processors) { - ProcessingQueue processingQueue = ProcessingQueue.getInstance(); - for (Processor processor : processors) { - processingQueue.queue(processor); - } - } - public abstract void process(); - public T getObject() { + protected T getObject() { return object; } public void queue() { - queueMany(this); + Processor.queue(this); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java index ac30c9fa5d..9bc77adc69 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java @@ -17,7 +17,7 @@ * * @author Rsl1122 */ -public class TPSInsertProcessor extends Processor> { +public class TPSInsertProcessor extends ObjectProcessor> { public TPSInsertProcessor(List object) { super(object); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java index ed0be671f6..b56ad17c8f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/InspectCacheRequestProcessor.java @@ -35,7 +35,7 @@ public InspectCacheRequestProcessor(UUID uuid, ISender sender, String playerName @Override public void process() { - SessionCache.getInstance().refreshActiveSessionsState(); + SessionCache.refreshActiveSessionsState(); try { InfoSystem.getInstance().generateAndCachePlayerPage(getUUID()); sendInspectMsg(sender, playerName); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java index 9d11a84f6c..a1bb9fbeb0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/info/NetworkPageUpdateProcessor.java @@ -6,7 +6,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plugin.api.utility.log.Log; /** @@ -14,11 +14,7 @@ * * @author Rsl1122 */ -public class NetworkPageUpdateProcessor extends Processor { - - public NetworkPageUpdateProcessor() { - super(null); - } +public class NetworkPageUpdateProcessor implements Processor { @Override public void process() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java deleted file mode 100644 index f15c7448b0..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/DeathProcessor.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.djrapitops.plan.system.processing.processors.player; - -import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.system.cache.SessionCache; - -import java.util.Optional; -import java.util.UUID; - -/** - * Updates death count of the current session. - * - * @author Rsl1122 - * @since 4.0.0 - */ -public class DeathProcessor extends PlayerProcessor { - - /** - * Constructor. - * - * @param uuid UUID of the dead player. - */ - public DeathProcessor(UUID uuid) { - super(uuid); - } - - @Override - public void process() { - UUID uuid = getUUID(); - Optional cachedSession = SessionCache.getCachedSession(uuid); - cachedSession.ifPresent(Session::died); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java index 94ee3983eb..95ede66395 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/KillProcessor.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.cache.SessionCache; @@ -44,8 +43,6 @@ public KillProcessor(UUID uuid, long time, LivingEntity dead, String weaponName) public void process() { UUID uuid = getUUID(); - Plan plugin = Plan.getInstance(); - Optional cachedSession = SessionCache.getCachedSession(uuid); if (!cachedSession.isPresent()) { return; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java index 708595e228..0ace174882 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/NameProcessor.java @@ -4,13 +4,15 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; +import com.djrapitops.plan.data.Actions; +import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.server.ServerInfo; -import com.djrapitops.plan.system.processing.ProcessingQueue; -import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor; +import com.djrapitops.plan.system.processing.Processor; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plugin.api.utility.log.Log; import java.util.List; @@ -36,7 +38,6 @@ public NameProcessor(UUID uuid, String playerName, String displayName) { @Override public void process() { UUID uuid = getUUID(); - Plan plugin = Plan.getInstance(); DataCache dataCache = DataCache.getInstance(); String cachedName = dataCache.getName(uuid); String cachedDisplayName = dataCache.getDisplayName(uuid); @@ -64,6 +65,19 @@ private void cueNameChangeActionProcessor(UUID uuid, Database db) throws DBExcep if (nicknames.contains(displayName)) { return; } - ProcessingQueue.getInstance().queue(new NewNickActionProcessor(uuid, displayName)); + + long time = MiscUtils.getTime(); + + Processor.queue(() -> { + String info = HtmlUtils.removeXSS(displayName); + + Action action = new Action(time, Actions.NEW_NICKNAME, info); + + try { + Database.getActive().save().action(uuid, action); + } catch (DBException e) { + Log.toLog(this.getClass().getName(), e); + } + }); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/PlayerProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/PlayerProcessor.java index d65f4fd23c..006e782183 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/PlayerProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/PlayerProcessor.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.processing.processors.player; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.processors.ObjectProcessor; import java.util.UUID; @@ -15,7 +15,7 @@ * * @author Rsl1122 */ -public abstract class PlayerProcessor extends Processor { +public abstract class PlayerProcessor extends ObjectProcessor { public PlayerProcessor(UUID uuid) { super(uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index 8dae1a0a99..f3613f5322 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java @@ -9,7 +9,8 @@ import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; +import com.djrapitops.plan.system.processing.processors.ObjectProcessor; import com.djrapitops.plugin.api.utility.log.Log; import java.util.UUID; @@ -25,9 +26,9 @@ public class RegisterProcessor extends PlayerProcessor { private final long time; private final int playersOnline; private final String name; - private final Processor[] afterProcess; + private final ObjectProcessor[] afterProcess; - public RegisterProcessor(UUID uuid, long registered, long time, String name, int playersOnline, Processor... afterProcess) { + public RegisterProcessor(UUID uuid, long registered, long time, String name, int playersOnline, ObjectProcessor... afterProcess) { super(uuid); this.registered = registered; this.time = time; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java index 80703f0bf6..2125710739 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java @@ -37,7 +37,7 @@ public Map getAliases() { } private ConfigNode getAliasSection() { - Config config = ConfigSystem.getInstance().getConfig(); + Config config = ConfigSystem.getConfig(); return config.getConfigNode(Settings.WORLD_ALIASES.getPath()); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java index a79b52af50..caf5848720 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/config/ConfigSystem.java @@ -64,7 +64,7 @@ public void enable() throws EnableException { /** * Copies default values from file in jar to Config. * - * @throws IOException + * @throws IOException If file can't be read or written. */ protected abstract void copyDefaults() throws IOException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Locale.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Locale.java index 8791808412..045f71390f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Locale.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/locale/Locale.java @@ -96,7 +96,7 @@ private void writeNewDefaultLocale() throws IOException { .collect(Collectors.toList()); Files.write(FileSystem.getLocaleFile().toPath(), lines, StandardCharsets.UTF_8); - Config config = ConfigSystem.getInstance().getConfig(); + Config config = ConfigSystem.getConfig(); config.set(Settings.WRITE_NEW_LOCALE.getPath(), false); config.save(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java index 3a03c2c3ba..7ac666ce92 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/Request.java @@ -46,10 +46,6 @@ public String getTarget() { return target; } - public boolean isAPIRequest() { - return "POST".equals(requestMethod); - } - public InputStream getRequestBody() { return exchange.getRequestBody(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java index 73e0d92970..3be7cc2651 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java @@ -24,8 +24,6 @@ public class BasicAuthentication implements Authentication { private String authenticationString; - private WebUser user; - public BasicAuthentication(String authenticationString) { this.authenticationString = authenticationString; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java index f63ce00dc2..53540f8e32 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java @@ -30,9 +30,9 @@ import com.djrapitops.plan.utilities.html.graphs.pie.ServerPreferencePie; import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie; import com.djrapitops.plan.utilities.html.structure.ServerAccordionCreator; -import com.djrapitops.plan.utilities.html.tables.ActionsTableCreator; -import com.djrapitops.plan.utilities.html.tables.GeoInfoTableCreator; -import com.djrapitops.plan.utilities.html.tables.NicknameTableCreator; +import com.djrapitops.plan.utilities.html.tables.ActionsTable; +import com.djrapitops.plan.utilities.html.tables.GeoInfoTable; +import com.djrapitops.plan.utilities.html.tables.NicknameTable; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; @@ -85,7 +85,7 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); String online = "Offline"; - Optional activeSession = SessionCache.getInstance().getCachedSession(uuid); + Optional activeSession = SessionCache.getCachedSession(uuid); if (activeSession.isPresent()) { Session session = activeSession.get(); session.setSessionID(Integer.MAX_VALUE); @@ -116,8 +116,8 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se String favoriteServer = serverNames.get(profile.getFavoriteServer()); addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown"); - addValue("tableBodyNicknames", NicknameTableCreator.createTable(profile.getNicknames(), serverNames)); - addValue("tableBodyIPs", GeoInfoTableCreator.createTable(profile.getGeoInformation())); + addValue("tableBodyNicknames", new NicknameTable(profile.getNicknames(), serverNames).parseBody()); + addValue("tableBodyIPs", new GeoInfoTable(profile.getGeoInformation()).parseBody()); Map> sessions = profile.getSessions(); Map> sessionsByServerName = sessions.entrySet().stream() @@ -186,14 +186,13 @@ public String parse(PlayerProfile profile, UUID serverUUID, Map se addValue("sessionAverageWeek", sessionAverageWeek > 0L ? FormatUtils.formatTimeAmount(sessionAverageWeek) : "-"); addValue("sessionAverageMonth", sessionAverageMonth > 0L ? FormatUtils.formatTimeAmount(sessionAverageMonth) : "-"); - addValue("sessionCount", sessionCount); addValue("sessionCountDay", sessionCountDay); addValue("sessionCountWeek", sessionCountWeek); addValue("sessionCountMonth", sessionCountMonth); List actions = profile.getAllActions(); - addValue("tableBodyActions", ActionsTableCreator.createTable(actions)); + addValue("tableBodyActions", new ActionsTable(actions).parseBody()); String punchCardData = new PunchCardGraph(allSessions).toHighChartsSeries(); WorldTimes worldTimes = profile.getWorldTimes(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java index 1d0d9a7b80..1f0f25b63f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ForbiddenResponse.java @@ -13,8 +13,7 @@ public ForbiddenResponse() { } public ForbiddenResponse(String msg) { - super.setHeader("HTTP/1.1 403 Forbidden"); - super.setTitle("403 Forbidden - Access Denied"); + this(); super.setParagraph(msg); super.replacePlaceholders(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java index 1ce3432363..3aef2ad4cc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java @@ -16,8 +16,7 @@ public NotFoundResponse() { } public NotFoundResponse(String msg) { - super.setHeader("HTTP/1.1 404 Not Found"); - super.setTitle("404 Not Found"); + this(); super.setParagraph(msg); super.replacePlaceholders(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java index 218aa20eee..2fa5a07f30 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPI.java @@ -4,7 +4,6 @@ */ package com.djrapitops.plan.system.webserver.webapi; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.Settings; @@ -13,7 +12,6 @@ import com.djrapitops.plan.system.webserver.response.api.SuccessResponse; 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.NotFoundResponse; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -25,11 +23,8 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; /** * @author Rsl1122 @@ -59,33 +54,6 @@ public WebAPI() { this.variables = new HashMap<>(); } - public static Map readVariables(String requestBody) { - String[] variables = requestBody.split(";&variable;"); - - return Arrays.stream(variables) - .map(variable -> variable.split("=", 2)) - .filter(splitVariables -> splitVariables.length == 2) - .collect(Collectors.toMap(splitVariables -> splitVariables[0], splitVariables -> splitVariables[1], (a, b) -> b)); - } - - public Response processRequest(PlanPlugin plugin, Map variables) { - String sender = variables.get("sender"); - if (sender == null) { - Log.debug(getClass().getSimpleName() + ": Sender not Found"); - return badRequest("Sender not present"); - } else { - try { - UUID.fromString(sender); - } catch (Exception e) { - Log.debug(getClass().getSimpleName() + ": Invalid Sender UUID"); - return badRequest("Faulty Sender value"); - } - } - return onRequest(plugin, variables); - } - - public abstract Response onRequest(PlanPlugin plugin, Map variables); - public void sendRequest(String address) throws WebException { Verify.nullCheck(address); @@ -165,10 +133,6 @@ protected void addVariable(String key, String value) { variables.put(key, value); } - public Map getVariables() { - return variables; - } - private SSLSocketFactory getRelaxedSocketFactory() throws NoSuchAlgorithmException, KeyManagementException { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); @@ -179,14 +143,6 @@ protected Response success() { return ResponseCache.loadResponse(PageId.TRUE.id(), SuccessResponse::new); } - protected Response fail(String reason) { - return ResponseCache.loadResponse(PageId.FALSE.id(), () -> { - NotFoundResponse notFoundResponse = new NotFoundResponse(""); - notFoundResponse.setContent(reason); - return notFoundResponse; - }); - } - protected Response badRequest(String error) { return ResponseCache.loadResponse(PageId.ERROR.of(error), () -> new BadRequestResponse(error)); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java deleted file mode 100644 index f61f6eef79..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/WebAPIManager.java +++ /dev/null @@ -1,60 +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.system.webserver.webapi; - -import com.djrapitops.plan.system.webserver.pages.TreePageHandler; -import com.djrapitops.plan.utilities.PassEncryptUtil; - -import java.util.*; - -/** - * @author Fuzzlemann and Rsl1122 - */ -@Deprecated -public class WebAPIManager extends TreePageHandler { - - private static final Set accessKeys = new HashSet<>(); - private final Map registry; - - /** - * Constructor used to hide the public constructor - */ - public WebAPIManager() { - registry = new HashMap<>(); - } - - public void registerNewAPI(WebAPI... api) { - for (WebAPI webAPI : api) { - registerNewAPI(webAPI); - } - } - - public boolean isAuthorized(String key) { - return accessKeys.contains(key); - } - - public void authorize(String key) { - accessKeys.remove(key); - } - - public String generateNewAccessKey() throws Exception { - String key = PassEncryptUtil.createHash(UUID.randomUUID().toString().substring(0, 5)).split(":")[4]; - accessKeys.add(key); - return key; - } - - public void registerNewAPI(WebAPI api) { - registry.put(api.getClass().getSimpleName().toLowerCase(), api); - } - - public T getAPI(Class api) { - WebAPI webAPI = getAPI(api.getSimpleName()); - return (T) webAPI; - } - - public WebAPI getAPI(String apiName) { - return registry.get(apiName.toLowerCase()); - } -} 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 deleted file mode 100644 index 0e4f0a50e2..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalysisReadyWebAPI.java +++ /dev/null @@ -1,34 +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.system.webserver.webapi.bukkit; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; - -import java.util.Map; -import java.util.UUID; - -/** - * @author Rsl1122 - */ -@Deprecated -public class AnalysisReadyWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - return fail("Deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendRequest(String address, UUID serverUUID) throws WebException { - addVariable("serverUUID", serverUUID.toString()); - super.sendRequest(address); - } -} 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 deleted file mode 100644 index 0abc9ccfbe..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/AnalyzeWebAPI.java +++ /dev/null @@ -1,34 +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.system.webserver.webapi.bukkit; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; - -import java.util.Map; -import java.util.UUID; - -/** - * @author Rsl1122 - */ -@Deprecated -public class AnalyzeWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - return fail("Deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendRequest(String address, UUID serverUUID) throws WebException { - addVariable("serverUUID", serverUUID.toString()); - super.sendRequest(address); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index 80648ed64e..5b5a629618 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -24,9 +24,9 @@ /** * @author Fuzzlemann */ +@Deprecated public class ConfigurationWebAPI extends WebAPI { - @Override public Response onRequest(PlanPlugin plugin, Map variables) { if (!Check.isBukkitAvailable()) { Log.debug("Called a wrong server type"); @@ -42,7 +42,7 @@ public Response onRequest(PlanPlugin plugin, Map variables) { } @Override - public void sendRequest(String address) throws WebException { + public void sendRequest(String address) { throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java deleted file mode 100644 index 4507dbe65f..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/InspectWebAPI.java +++ /dev/null @@ -1,40 +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.system.webserver.webapi.bukkit; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; - -import java.util.Map; -import java.util.UUID; - -/** - * @author Rsl1122 - */ -@Deprecated -public class InspectWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - String uuidS = variables.get("uuid"); - if (uuidS == null) { - return badRequest("UUID not included"); - } - UUID uuid = UUID.fromString(uuidS); - - return fail("WebAPI deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendRequest(String address, UUID uuid) throws WebException { - addVariable("uuid", uuid.toString()); - super.sendRequest(address); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java deleted file mode 100644 index 47f1e50fe1..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/IsOnlineWebAPI.java +++ /dev/null @@ -1,47 +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.system.webserver.webapi.bukkit; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import org.bukkit.entity.Player; - -import java.util.Map; -import java.util.UUID; - -/** - * @author Fuzzlemann - */ -public class IsOnlineWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - String uuidS = variables.get("uuid"); - if (uuidS == null) { - return badRequest("UUID not included"); - } - UUID uuid = UUID.fromString(uuidS); - - Player player = Plan.getInstance().getServer().getPlayer(uuid); - - if (player != null && player.isOnline()) { - return success(); - } else { - return fail("Not Online"); - } - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendRequest(String address, UUID uuid) throws WebException { - addVariable("uuid", uuid.toString()); - super.sendRequest(address); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java deleted file mode 100644 index 741abac3b2..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/RequestInspectPluginsTabBukkitWebAPI.java +++ /dev/null @@ -1,54 +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.system.webserver.webapi.bukkit; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plugin.api.Check; - -import java.util.Map; -import java.util.UUID; - -/** - * WebAPI for requesting Inspect plugins tab contents from a Bukkit Server. - *

    - * Call: Bungee to Bukkit - *

    - * Bad Requests: - * - Called a Bungee Server - * - Did not include uuid variable - * - * @author Rsl1122 - */ -@Deprecated -public class RequestInspectPluginsTabBukkitWebAPI extends WebAPI { - - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - if (!Check.isBukkitAvailable()) { - return badRequest("Called a Bungee Server"); - } - - String uuidS = variables.get("uuid"); - if (uuidS == null) { - return badRequest("UUID not included"); - } - UUID uuid = UUID.fromString(uuidS); - - return fail("Deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendRequest(String address, UUID uuid) throws WebException { - addVariable("uuid", uuid.toString()); - super.sendRequest(address); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java deleted file mode 100644 index d8b3c317db..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/IsCachedWebAPI.java +++ /dev/null @@ -1,59 +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.system.webserver.webapi.bungee; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.NotFoundException; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; - -import java.util.Map; -import java.util.UUID; - -/** - * WebAPI for checking if a page is in webserver cache. - * - * @author Rsl1122 - */ -@Deprecated -public class IsCachedWebAPI extends WebAPI { - - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - try { - return fail("Deprecated"); - } catch (NullPointerException e) { - return badRequest(e.toString()); - } - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public boolean isInspectCached(String address, UUID uuid) throws WebException { - addVariable("uuid", uuid.toString()); - addVariable("target", "inspectPage"); - try { - super.sendRequest(address); - return true; - } catch (NotFoundException e) { - return false; - } - } - - public boolean isAnalysisCached(String address, UUID serverUUID) throws WebException { - addVariable("serverUUID", serverUUID.toString()); - addVariable("target", "analysisPage"); - try { - super.sendRequest(address); - return true; - } catch (NotFoundException e) { - return false; - } - } -} \ No newline at end of file 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 deleted file mode 100644 index b54d10ee09..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostHtmlWebAPI.java +++ /dev/null @@ -1,45 +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.system.webserver.webapi.bungee; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; - -import java.util.Map; -import java.util.UUID; - -/** - * WebAPI for posting Html pages such as Inspect or server pages. - * - * @author Rsl1122 - */ -@Deprecated -public class PostHtmlWebAPI extends WebAPI { - - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - return fail("Deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendInspectHtml(String address, UUID uuid, String html) throws WebException { - addVariable("uuid", uuid.toString()); - addVariable("target", "inspectPage"); - addVariable("html", html); - super.sendRequest(address); - } - - public void sendAnalysisHtml(String address, String html) throws WebException { - addVariable("html", html); - addVariable("target", "analysisPage"); - super.sendRequest(address); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java deleted file mode 100644 index 8161fc5e2b..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostInspectPluginsTabWebAPI.java +++ /dev/null @@ -1,60 +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.system.webserver.webapi.bungee; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; - -import java.util.Map; -import java.util.UUID; - -/** - * WebAPI for posting Inspect page Plugins tab contents to the Bungee server. - *

    - * Call: Bukkit to Bungee - *

    - * Bad Requests: - * - Did not include uuid - * - * @author Rsl1122 - */ -@Deprecated -public class PostInspectPluginsTabWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - String uuidS = variables.get("uuid"); - if (uuidS == null) { - return badRequest("uuid not included"); - } - - UUID uuid = UUID.fromString(uuidS); - UUID serverUUID = UUID.fromString(variables.get("sender")); - String nav = variables.get("nav"); - if (nav == null) { - return badRequest("nav not included"); - } - String html = variables.get("html"); - if (html == null) { - return badRequest("html not included"); - } - String[] content = new String[]{nav, html}; - - return fail("Deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendPluginsTab(String address, UUID uuid, String[] html) throws WebException { - addVariable("uuid", uuid.toString()); - addVariable("nav", html[0]); - addVariable("html", html[1]); - super.sendRequest(address); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java deleted file mode 100644 index 80e9962a5b..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostNetworkPageContentWebAPI.java +++ /dev/null @@ -1,47 +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.system.webserver.webapi.bungee; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plugin.api.Check; - -import java.util.Map; -import java.util.UUID; - -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ -@Deprecated -public class PostNetworkPageContentWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - if (Check.isBukkitAvailable()) { - return badRequest("Called a Bukkit server."); - } - - UUID serverUUID = UUID.fromString(variables.get("sender")); - String html = variables.get("html"); - if (html == null) { - return badRequest("html not present"); - } - - return fail("Deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendNetworkContent(String address, String html) throws WebException { - addVariable("html", html); - super.sendRequest(address); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java index cb61156850..5130d7b307 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/PostOriginalBukkitSettingsWebAPI.java @@ -21,9 +21,9 @@ * * @author Rsl1122 */ +@Deprecated public class PostOriginalBukkitSettingsWebAPI extends WebAPI { - @Override public Response onRequest(PlanPlugin plugin, Map variables) { if (Check.isBukkitAvailable()) { return badRequest("Called a Bukkit Server"); @@ -45,7 +45,6 @@ public Response onRequest(PlanPlugin plugin, Map variables) { return success(); } - @Override public void sendRequest(String address) throws WebException { addVariable("WebServerPort", Integer.toString(Settings.WEBSERVER_PORT.getNumber())); addVariable("ServerName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java deleted file mode 100644 index 9fddbc5d3e..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestPluginsTabWebAPI.java +++ /dev/null @@ -1,56 +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.system.webserver.webapi.bungee; - -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plugin.api.Check; - -import java.util.Map; -import java.util.UUID; - -/** - * WebAPI for requesting Bungee Server to request Plugins tab contents from every server. - *

    - * Call: Bukkit to Bungee - *

    - * Bad Requests: - * - Called a Bukkit Server - * - Did not include uuid variable - * - * @author Rsl1122 - */ -public class RequestPluginsTabWebAPI extends WebAPI { - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - if (!Check.isBungeeAvailable()) { - return badRequest("Called a Bukkit Server"); - } - - String uuidS = variables.get("uuid"); - if (uuidS == null) { - return badRequest("UUID not included"); - } - UUID uuid = UUID.fromString(uuidS); - - sendRequestsToBukkitServers(plugin, uuid); - return success(); - } - - @Override - public void sendRequest(String address) throws WebException { - throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead."); - } - - public void sendRequest(String address, UUID uuid) throws WebException { - addVariable("uuid", uuid.toString()); - super.sendRequest(address); - } - - public void sendRequestsToBukkitServers(PlanPlugin plugin, UUID uuid) { - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java deleted file mode 100644 index d62d996330..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bungee/RequestSetupWebAPI.java +++ /dev/null @@ -1,39 +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.system.webserver.webapi.bungee; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.webapi.WebAPI; -import com.djrapitops.plugin.api.Check; - -import java.util.Map; - -/** - * //TODO Class Javadoc Comment - * - * @author Rsl1122 - */ -@Deprecated -public class RequestSetupWebAPI extends WebAPI { - - @Override - public Response onRequest(PlanPlugin plugin, Map variables) { - return fail("Deprecated"); - } - - @Override - public void sendRequest(String address) throws WebException { - if (!Check.isBukkitAvailable()) { - throw new IllegalStateException("Not supposed to be called on Bungee"); - } - - Plan plugin = Plan.getInstance(); - addVariable("webAddress", plugin.getWebServer().getAccessAddress()); - super.sendRequest(address); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index c3c65eae75..1cbd9a8dbe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -233,8 +233,8 @@ public static String formatIP(String ip) { /** * Gets lines for stack trace recursively. * - * @param throwable - * @return + * @param throwable Throwable element + * @return lines of stack trace. */ public static List getStackTrace(Throwable throwable) { List stackTrace = new ArrayList<>(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java index c3a6d0a609..5c162a2083 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.utilities; -import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.DBSystem; @@ -32,7 +31,6 @@ private ManageUtils() { * @param copyFromDB Database you want to backup. */ public static void backup(String dbName, Database copyFromDB) throws DBInitException, SQLException { - Plan plugin = Plan.getInstance(); String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-"); String fileName = dbName + "-backup-" + timeStamp; SQLiteDB backupDB = new SQLiteDB(fileName); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index 2e08101a9e..5a788d2785 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -107,7 +107,7 @@ public static List getMatchingPlayerNames(String search) { return matches; } - public static List flatMap(Collection> coll) { + public static List flatMap(Collection> coll) { return coll.stream().flatMap(Collection::stream).collect(Collectors.toList()); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index e2afd52e91..2b3d8a1245 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -1,6 +1,5 @@ package com.djrapitops.plan.utilities.analysis; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Session; @@ -142,7 +141,6 @@ public static void addMissingWorlds(WorldTimes worldTimes) { try { // Add 0 time for worlds not present. Set nonZeroWorlds = worldTimes.getWorldTimes().keySet(); - PlanPlugin plugin = PlanPlugin.getInstance(); for (String world : Database.getActive().fetch().getWorldNames(ServerInfo.getServerUUID())) { if (nonZeroWorlds.contains(world)) { continue; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeuckerAlgorithm.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeuckerAlgorithm.java index c6b550cdde..7bc24d362d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeuckerAlgorithm.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeuckerAlgorithm.java @@ -5,8 +5,9 @@ import java.util.List; /** - * Ramer-Douglas-Peucker Point Reduction Algorithm for reducing points from - * graphs. + * Ramer-Douglas-Peucker Point Reduction Algorithm Implementation for reducing points from graphs. + * + * https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm * * @author Rsl1122 * @since 3.5.2 diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Line.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Line.java index f857d32d7d..2c0b84783d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Line.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Line.java @@ -6,7 +6,11 @@ package com.djrapitops.plan.utilities.analysis; /** - * @author ristolah + * This math object is used in Ramer–Douglas–Peucker algorithm. + * + * https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm + * + * @author Rsl1122 */ public class Line { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java index f1969c1964..5078a1433d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/MathUtils.java @@ -3,7 +3,9 @@ import java.io.Serializable; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; -import java.util.*; +import java.util.Collection; +import java.util.Locale; +import java.util.OptionalDouble; import java.util.stream.Stream; /** @@ -153,34 +155,6 @@ public static double sumDouble(Stream values) { .sum(); } - /** - * Gets the biggest Integer in a Collection with Integer as Entry - * If the Collection is empty, it will return 1. - * - * @param values The Collection with Integer as the Entry - * @return The biggest Integer - * @see #getBiggestLong(Collection) - */ - public static int getBiggest(Collection values) { - OptionalInt biggest = values.stream().mapToInt(i -> i).max(); - - return biggest.isPresent() ? biggest.getAsInt() : 1; - } - - /** - * Gets the biggest Long in a Collection with Long as Entry - * If the Collection is empty, it will return 1. - * - * @param values The Collection with Long as the Entry - * @return The biggest Integer - * @see #getBiggest(Collection) - */ - public static long getBiggestLong(Collection values) { - OptionalLong biggest = values.stream().mapToLong(i -> i).max(); - - return biggest.isPresent() ? biggest.getAsLong() : 1; - } - /** * Rounds the double to a double with two digits at the end. * Output: #.## diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/MapComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/MapComparator.java index 129de42f27..b537e44cec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/MapComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/MapComparator.java @@ -31,18 +31,4 @@ public static List sortByValue(Map map) { return sortedList; } - /** - * Sorts a Map of String, Long by the Values of the Map. - * - * @param map Map to sort - * @return List with String Array, where first value is the value and second - * is the key. - */ - public static List sortByValueLong(Map map) { - List sortedList = new ArrayList<>(); - map.keySet().forEach(key -> sortedList.add(new String[]{String.valueOf(map.get(key)), key})); - sortedList.sort(Comparator.comparing(strings -> Long.valueOf(strings[0]))); - return sortedList; - } - } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java index 06c6b8922f..2ac2573947 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PieSliceComparator.java @@ -9,7 +9,9 @@ import java.util.Comparator; /** - * Compares PieSlices to descending Percentage order. + * Comparator for PieSlices to descending Percentage order. + * + * @author Rsl1122 */ public class PieSliceComparator implements Comparator { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/KillDataComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PlayerKillComparator.java similarity index 81% rename from Plan/src/main/java/com/djrapitops/plan/utilities/comparators/KillDataComparator.java rename to Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PlayerKillComparator.java index 6ed0c31018..4b5b4c3165 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/KillDataComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PlayerKillComparator.java @@ -7,7 +7,7 @@ /** * @author Fuzzlemann */ -public class KillDataComparator implements Comparator { +public class PlayerKillComparator implements Comparator { @Override public int compare(PlayerKill o1, PlayerKill o2) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PluginDataNameComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PluginDataNameComparator.java index 519640e9a7..16ebaf43b1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PluginDataNameComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PluginDataNameComparator.java @@ -10,7 +10,7 @@ import java.util.Comparator; /** - * Comparator for UserInfo for Alphabetical Name order. + * Comparator for PluginData for Alphabetical Name order. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PointComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PointComparator.java index b26a12adce..90db064d2b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PointComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/PointComparator.java @@ -10,6 +10,8 @@ import java.util.Comparator; /** + * Comparator for Points for ascending x value order. + * * @author Rsl1122 * @since 3.5.2 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionLengthComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionLengthComparator.java index d1c90df18d..04e8478ad8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionLengthComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionLengthComparator.java @@ -5,6 +5,8 @@ import java.util.Comparator; /** + * Comparator for Sessions in descending length order. + * * @author Rsl1122 */ public class SessionLengthComparator implements Comparator { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionStartComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionStartComparator.java index f783df30bb..14056d10b2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionStartComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/SessionStartComparator.java @@ -5,6 +5,8 @@ import java.util.Comparator; /** + * Comparator for Sessions in descending start order (Latest first). + * * @author Rsl1122 */ public class SessionStartComparator implements Comparator { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java index 40719156db..92a8d4d694 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/AnalysisExport.java @@ -4,6 +4,8 @@ */ package com.djrapitops.plan.utilities.file.export; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import java.io.IOException; @@ -29,6 +31,10 @@ public AnalysisExport(UUID serverUUID, String serverName) { @Override public void run() { try { + if (Check.isBukkitAvailable() && ConnectionSystem.getInstance().isServerAvailable()) { + return; + } + exportAvailableServerPage(serverUUID, serverName); } catch (IOException e) { Log.toLog(this.getClass().getName(), e); 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 445fab3cb6..c249d37a4d 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 @@ -12,7 +12,6 @@ import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.settings.theme.ThemeVal; 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; @@ -41,7 +40,7 @@ public static void exportServer(UUID serverUUID) { Optional serverName = Database.getActive().fetch().getServerName(serverUUID); serverName.ifPresent(s -> RunnableFactory.createNew(new AnalysisExport(serverUUID, s)).runTaskAsynchronously()); } catch (DBException e) { - Log.toLog(PostHtmlWebAPI.class.getClass().getName(), e); + Log.toLog(HtmlExport.class.getClass().getName(), e); } } @@ -52,7 +51,7 @@ public static void exportPlayer(UUID playerUUID) { RunnableFactory.createNew(new PlayerExport(playerUUID, playerName)).runTaskAsynchronously(); } } catch (DBException e) { - Log.toLog(PostHtmlWebAPI.class.getClass().getName(), e); + Log.toLog(HtmlExport.class.getClass().getName(), e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java index 3d9a50fcc4..c70a2a2dae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/PlayerExport.java @@ -4,6 +4,8 @@ */ package com.djrapitops.plan.utilities.file.export; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import java.io.IOException; @@ -29,6 +31,10 @@ public PlayerExport(UUID uuid, String name) { @Override public void run() { try { + if (Check.isBukkitAvailable() && ConnectionSystem.getInstance().isServerAvailable()) { + return; + } + exportAvailablePlayerPage(uuid, name); } catch (IOException e) { Log.toLog(this.getClass().getName(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java index 9119838e60..389d76db2d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/export/SpecificExport.java @@ -103,7 +103,7 @@ protected void exportAvailableServerPage(UUID serverUUID, String serverName) thr .replace("src=\"plugins/", "src=\"../plugins/") .replace("src=\"js/", "src=\"../js/"); - File htmlLocation = null; + File htmlLocation; if (usingBungee) { if (serverUUID.equals(ServerInfo.getServerUUID())) { htmlLocation = new File(outputFolder, "network"); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 6a6f2bdf79..f10aa2af57 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -178,15 +178,6 @@ public static String createServerContainer() { "})"; } - public static String parseOfflineServerContainer(String oldContent) { - if (oldContent == null) { - return ""; - } - String[] split = oldContent.split("

    ", 2); - String[] split2 = split[1].split("box-footer", 2); - return split[0] + "

    Offline

    banned, boolean op) { boolean offline = "offline".equalsIgnoreCase(online); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index 2b0ecb6769..159fa94f55 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -16,7 +16,7 @@ import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie; -import com.djrapitops.plan.utilities.html.tables.KillsTableCreator; +import com.djrapitops.plan.utilities.html.tables.KillsTable; import com.djrapitops.plan.utilities.html.tables.SessionsTableCreator; import com.djrapitops.plugin.utilities.Verify; @@ -89,7 +89,7 @@ public static String[] createStructure(Map>> ses WorldPie worldPie = new WorldPie(worldTimes); - String killTable = KillsTableCreator.createTable(session.getPlayerKills()); + String killTable = new KillsTable(session.getPlayerKills()).parseHtml(); // Accordion panel header html.append("
    actions) { + super("Date", "Action", "Info"); + + if (actions.isEmpty()) { + addRow("No Actions"); + } else { + addValues(actions); + } + } + + private void addValues(List actions) { + int i = 0; + for (Action action : actions) { + if (i > 50) { + break; + } + addRow( + FormatUtils.formatTimeStampYear(action.getDate()), + action.getDoneAction().toString(), + HtmlUtils.swapColorsToSpan(action.getAdditionalInfo()) + ); + i++; + } + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java deleted file mode 100644 index 27b567d87a..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/ActionsTableCreator.java +++ /dev/null @@ -1,50 +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.utilities.html.tables; - -import com.djrapitops.plan.data.container.Action; -import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.html.Html; -import com.djrapitops.plan.utilities.html.HtmlUtils; - -import java.util.List; - -/** - * Utility Class for creating Actions Table for inspect page. - * - * @author Rsl1122 - */ -public class ActionsTableCreator { - - - public ActionsTableCreator() { - throw new IllegalStateException("Utility class"); - } - - public static String createTable(List actions) { - StringBuilder html = new StringBuilder(); - if (actions.isEmpty()) { - html.append(Html.TABLELINE_3.parse("No Actions", "-", "-")); - } else { - int i = 0; - for (Action action : actions) { - if (i >= 100) { - break; - } - - long date = action.getDate(); - - html.append(Html.TABLELINE_3_CUSTOMKEY_1.parse( - String.valueOf(date), FormatUtils.formatTimeStampYear(date), - action.getDoneAction().toString(), - HtmlUtils.swapColorsToSpan(action.getAdditionalInfo()) - )); - - i++; - } - } - return html.toString(); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTable.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTable.java new file mode 100644 index 0000000000..72c6a674e9 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTable.java @@ -0,0 +1,41 @@ +package com.djrapitops.plan.utilities.html.tables; + +import com.djrapitops.plan.data.element.TableContainer; +import com.djrapitops.plan.utilities.comparators.MapComparator; +import com.djrapitops.plan.utilities.html.HtmlUtils; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @author Rsl1122 + */ +public class CommandUseTable extends TableContainer { + + public CommandUseTable(Map commandUse) { + super("Command", "Times Used"); + + if (commandUse.isEmpty()) { + addRow("No Commands"); + } else { + addValues(commandUse); + } + } + + private void addValues(Map commandUse) { + List sorted = MapComparator.sortByValue(commandUse); + Collections.reverse(sorted); + + int i = 0; + for (String[] values : sorted) { + if (i >= 500) { + break; + } + String command = HtmlUtils.removeXSS(values[1]); + addRow(command, values[0]); + + i++; + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTableCreator.java deleted file mode 100644 index 344dd382c7..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/CommandUseTableCreator.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.djrapitops.plan.utilities.html.tables; - -import com.djrapitops.plan.utilities.comparators.MapComparator; -import com.djrapitops.plan.utilities.html.Html; -import com.djrapitops.plugin.api.utility.log.Log; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * @author Rsl1122 - */ -public class CommandUseTableCreator { - - /** - * Constructor used to hide the public constructor - */ - private CommandUseTableCreator() { - throw new IllegalStateException("Utility class"); - } - - /** - * @param commandUse The commands and the amount of times casted - * @return The created command use table - */ - public static String createTable(Map commandUse) { - List sorted = MapComparator.sortByValue(commandUse); - - StringBuilder html = new StringBuilder(); - if (sorted.isEmpty()) { - html.append(Html.TABLELINE_2.parse("No Commands", "")); - } else { - Collections.reverse(sorted); - int i = 0; - for (String[] values : sorted) { - if (i >= 500) { - break; - } - - try { - html.append(Html.TABLELINE_2.parse(values[1], values[0])); - } catch (IllegalArgumentException e) { - Log.toLog("CommandUseTable - Cause: " + values[0] + " " + values[1], e); - } - - i++; - } - } - - return html.toString(); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTable.java new file mode 100644 index 0000000000..d21c779726 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTable.java @@ -0,0 +1,40 @@ +/* + * 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.utilities.html.tables; + +import com.djrapitops.plan.data.container.GeoInfo; +import com.djrapitops.plan.data.element.TableContainer; +import com.djrapitops.plan.utilities.FormatUtils; + +import java.util.List; + +/** + * Utility Class for creating IP Table for inspect page. + * + * @author Rsl1122 + */ +public class GeoInfoTable extends TableContainer { + + public GeoInfoTable(List geoInfo) { + super("IP", "Geolocation", "Last Used"); + + if (geoInfo.isEmpty()) { + addRow("No Connections"); + } else { + addValues(geoInfo); + } + } + + private void addValues(List geoInfo) { + for (GeoInfo info : geoInfo) { + long date = info.getLastUsed(); + addRow( + FormatUtils.formatIP(info.getIp()), + info.getGeolocation(), + date != 0 ? FormatUtils.formatTimeStampYear(date) : "-" + ); + } + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTableCreator.java deleted file mode 100644 index 02ba41c314..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/GeoInfoTableCreator.java +++ /dev/null @@ -1,42 +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.utilities.html.tables; - -import com.djrapitops.plan.data.container.GeoInfo; -import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.comparators.GeoInfoComparator; -import com.djrapitops.plan.utilities.html.Html; - -import java.util.List; - -/** - * Utility Class for creating IP Table for inspect page. - * - * @author Rsl1122 - */ -public class GeoInfoTableCreator { - - public GeoInfoTableCreator() { - throw new IllegalStateException("Utility class"); - } - - public static String createTable(List geoInfo) { - geoInfo.sort(new GeoInfoComparator()); - StringBuilder html = new StringBuilder(); - if (geoInfo.isEmpty()) { - html.append(Html.TABLELINE_3.parse("No Connections", "-", "-")); - } else { - for (GeoInfo info : geoInfo) { - long date = info.getLastUsed(); - html.append(Html.TABLELINE_3.parse( - FormatUtils.formatIP(info.getIp()), - info.getGeolocation(), - date != 0 ? FormatUtils.formatTimeStampYear(date) : "-" - )); - } - } - return html.toString(); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java new file mode 100644 index 0000000000..057cec7b37 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java @@ -0,0 +1,52 @@ +package com.djrapitops.plan.utilities.html.tables; + +import com.djrapitops.plan.api.PlanAPI; +import com.djrapitops.plan.data.container.PlayerKill; +import com.djrapitops.plan.data.element.TableContainer; +import com.djrapitops.plan.system.cache.DataCache; +import com.djrapitops.plan.utilities.FormatUtils; +import com.djrapitops.plan.utilities.comparators.PlayerKillComparator; +import com.djrapitops.plan.utilities.html.Html; + +import java.util.Collections; +import java.util.List; + +/** + * @author Rsl1122 + */ +public class KillsTable extends TableContainer { + + public KillsTable(List playerKills) { + super(Html.FONT_AWESOME_ICON.parse("clock-o") + " Time", "Killed", "With"); + + if (playerKills.isEmpty()) { + addRow("No Kills"); + } else { + addValues(playerKills); + } + } + + private void addValues(List playerKills) { + playerKills.sort(new PlayerKillComparator()); + Collections.reverse(playerKills); + + int i = 0; + DataCache dataCache = DataCache.getInstance(); + for (PlayerKill kill : playerKills) { + if (i >= 20) { + break; + } + + long date = kill.getTime(); + + String name = dataCache.getName(kill.getVictim()); + addRow( + FormatUtils.formatTimeStamp(date), + Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), + kill.getWeapon() + ); + + i++; + } + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java deleted file mode 100644 index 7a8b208bcf..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTableCreator.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.djrapitops.plan.utilities.html.tables; - -import com.djrapitops.plan.api.PlanAPI; -import com.djrapitops.plan.data.container.PlayerKill; -import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.settings.locale.Locale; -import com.djrapitops.plan.system.settings.locale.Msg; -import com.djrapitops.plan.utilities.FormatUtils; -import com.djrapitops.plan.utilities.comparators.KillDataComparator; -import com.djrapitops.plan.utilities.html.Html; - -import java.util.Collections; -import java.util.List; - -/** - * @author Rsl1122 - */ -public class KillsTableCreator { - - /** - * Constructor used to hide the public constructor - */ - private KillsTableCreator() { - throw new IllegalStateException("Utility class"); - } - - /** - * @param playerKills The list of the {@link PlayerKill} Objects from which the kill table should be created - * @return The created kills table - */ - public static String createTable(List playerKills) { - StringBuilder html = new StringBuilder(Html.TABLE_KILLS_START.parse()); - - if (playerKills.isEmpty()) { - html.append(Html.TABLELINE_3.parse(Locale.get(Msg.HTML_TABLE_NO_KILLS).parse(), "", "")); - } else { - playerKills.sort(new KillDataComparator()); - Collections.reverse(playerKills); - - int i = 0; - DataCache dataCache = DataCache.getInstance(); - for (PlayerKill kill : playerKills) { - if (i >= 20) { - break; - } - - long date = kill.getTime(); - - String name = dataCache.getName(kill.getVictim()); - html.append(Html.TABLELINE_3_CUSTOMKEY_1.parse( - String.valueOf(date), FormatUtils.formatTimeStamp(date), - Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), - kill.getWeapon() - )); - - i++; - } - } - - html.append(Html.TABLE_END.parse()); - - return html.toString(); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTable.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTable.java new file mode 100644 index 0000000000..38a2ec0a66 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTable.java @@ -0,0 +1,42 @@ +/* + * 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.utilities.html.tables; + +import com.djrapitops.plan.data.element.TableContainer; +import com.djrapitops.plan.utilities.html.HtmlUtils; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * Utility Class for creating Nicknames Table for inspect page. + * + * @author Rsl1122 + */ +public class NicknameTable extends TableContainer { + + public NicknameTable(Map> nicknames, Map serverNames) { + super("Nickname", "Server"); + + if (nicknames.isEmpty()) { + addRow("No Nicknames"); + } else { + addValues(nicknames, serverNames); + } + } + + private void addValues(Map> nicknames, Map serverNames) { + for (Map.Entry> entry : nicknames.entrySet()) { + String serverName = serverNames.getOrDefault(entry.getKey(), "Unknown"); + for (String nick : entry.getValue()) { + addRow( + HtmlUtils.swapColorsToSpan(HtmlUtils.removeXSS(nick)), + serverName + ); + } + } + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTableCreator.java deleted file mode 100644 index f67591905b..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/NicknameTableCreator.java +++ /dev/null @@ -1,40 +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.utilities.html.tables; - -import com.djrapitops.plan.utilities.html.Html; -import com.djrapitops.plan.utilities.html.HtmlUtils; - -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * Utility Class for creating Nicknames Table for inspect page. - * - * @author Rsl1122 - */ -public class NicknameTableCreator { - - - public NicknameTableCreator() { - throw new IllegalStateException("Utility class"); - } - - public static String createTable(Map> nicknames, Map serverNames) { - StringBuilder html = new StringBuilder(); - if (nicknames.isEmpty()) { - html.append(Html.TABLELINE_2.parse("No Nicknames", "-")); - } else { - for (Map.Entry> entry : nicknames.entrySet()) { - String serverName = serverNames.getOrDefault(entry.getKey(), "Unknown"); - for (String nick : entry.getValue()) { - html.append(Html.TABLELINE_2.parse(HtmlUtils.swapColorsToSpan(HtmlUtils.removeXSS(nick)), serverName)); - } - } - } - return html.toString(); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java index 95e900a4f0..7694d15b8d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java @@ -47,7 +47,5 @@ protected void stop() { } } - protected abstract void clearVariables(); - protected abstract void consume(T toConsume); } 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 d434bcf1d2..097cc5520c 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 @@ -20,7 +20,6 @@ import com.djrapitops.plugin.utilities.Verify; import org.bukkit.OfflinePlayer; -import java.sql.SQLException; import java.util.Collection; import java.util.Collections; import java.util.UUID; @@ -280,7 +279,6 @@ public UUID playerNameToUUID(String playerName) { * Should be called from async thread. * * @return Collection of UUIDs that can be found in the database. - * @throws SQLException If database error occurs. * @since 3.4.2 */ @Deprecated From 7faa619ae39037066472ca5037728dc46e3ec315 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 25 Jan 2018 16:04:40 +0200 Subject: [PATCH 058/166] Fixed lag caused by WorldAliasSettings.addWorld #493 --- .../plan/system/settings/WorldAliasSettings.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java index 2125710739..b7b54ffcc4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/WorldAliasSettings.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.system.settings; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.config.ConfigNode; @@ -54,11 +55,13 @@ public void addWorld(String world) { String previousValue = aliasSect.getConfigNode(world).getValue(); if (Verify.isEmpty(previousValue)) { aliasSect.set(world, world); - } - try { - aliasSect.save(); - } catch (IOException e) { - Log.toLog(this.getClass().getName(), e); + Processor.queue(() -> { + try { + aliasSect.save(); + } catch (IOException e) { + Log.toLog(this.getClass().getName(), e); + } + }); } } From 9d47cd32a863fa14fdda18ea06db415fa00c0736 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 26 Jan 2018 11:18:44 +0200 Subject: [PATCH 059/166] Moved a couple data classes to new package. --- .../plan/command/commands/QInspectCommand.java | 2 +- .../java/com/djrapitops/plan/data/PlayerProfile.java | 2 +- .../data/{element => calculation}/ActivityIndex.java | 10 +++++----- .../plan/data/{ => calculation}/AnalysisData.java | 5 +++-- .../data/{element => calculation}/HealthNotes.java | 3 +-- .../plan/data/{ => calculation}/RawData.java | 2 +- .../info/request/GenerateAnalysisPageRequest.java | 2 +- .../system/webserver/pages/parsing/AnalysisPage.java | 2 +- .../system/webserver/pages/parsing/InspectPage.java | 2 +- .../djrapitops/plan/utilities/analysis/Analysis.java | 2 +- .../plan/utilities/analysis/AnalysisUtils.java | 2 +- .../plan/utilities/html/graphs/ActivityStackGraph.java | 2 +- .../plan/utilities/html/graphs/pie/ActivityPie.java | 2 +- .../utilities/html/tables/PlayersTableCreator.java | 2 +- .../java/main/java/com/djrapitops/plan/api/API.java | 4 ++-- 15 files changed, 22 insertions(+), 22 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/data/{element => calculation}/ActivityIndex.java (98%) rename Plan/src/main/java/com/djrapitops/plan/data/{ => calculation}/AnalysisData.java (99%) rename Plan/src/main/java/com/djrapitops/plan/data/{element => calculation}/HealthNotes.java (99%) rename Plan/src/main/java/com/djrapitops/plan/data/{ => calculation}/RawData.java (97%) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java index 323b6c5696..ffe3fb842b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/QInspectCommand.java @@ -3,7 +3,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.data.element.ActivityIndex; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index ca4b02b6ee..4d7e2ac604 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -4,11 +4,11 @@ */ package com.djrapitops.plan.data; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.MiscUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/ActivityIndex.java similarity index 98% rename from Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java rename to Plan/src/main/java/com/djrapitops/plan/data/calculation/ActivityIndex.java index 833ee8c2d1..9b26a6ce8f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/ActivityIndex.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/ActivityIndex.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.data.element; +package com.djrapitops.plan.data.calculation; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.container.Session; @@ -17,6 +17,10 @@ public ActivityIndex(PlayerProfile player, long date) { value = calculate(player, date); } + public static String[] getGroups() { + return new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"}; + } + private long loadSetting(long value) { return value <= 0 ? 1 : value; } @@ -25,10 +29,6 @@ private int loadSetting(int value) { return value <= 0 ? 1 : value; } - public static String[] getGroups() { - return new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"}; - } - private double calculate(PlayerProfile player, long date) { long week = TimeAmount.WEEK.ms(); long weekAgo = date - week; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java rename to Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java index 1589ff4d84..a72867e86a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java @@ -1,11 +1,12 @@ -package com.djrapitops.plan.data; +package com.djrapitops.plan.data.calculation; import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.data.PlayerProfile; +import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.StickyData; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.element.AnalysisContainer; -import com.djrapitops.plan.data.element.HealthNotes; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.settings.Settings; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/HealthNotes.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java rename to Plan/src/main/java/com/djrapitops/plan/data/calculation/HealthNotes.java index e66d5be307..cda85234b2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/HealthNotes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/HealthNotes.java @@ -2,9 +2,8 @@ * 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.data.element; +package com.djrapitops.plan.data.calculation; -import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; import com.djrapitops.plan.data.container.StickyData; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/RawData.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/RawData.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/data/RawData.java rename to Plan/src/main/java/com/djrapitops/plan/data/calculation/RawData.java index 5f2f7cd69e..03c57bcd82 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/RawData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/RawData.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.data; +package com.djrapitops.plan.data.calculation; import com.djrapitops.plugin.utilities.Verify; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index c9cc337c64..d64d717d62 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.api.exceptions.connection.BadRequestException; import com.djrapitops.plan.api.exceptions.connection.InternalErrorException; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.data.AnalysisData; +import com.djrapitops.plan.data.calculation.AnalysisData; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java index 4c344250e8..65fa5e9b41 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/AnalysisPage.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.pages.parsing; import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.data.AnalysisData; +import com.djrapitops.plan.data.calculation.AnalysisData; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.html.HtmlUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java index 53540f8e32..c915a243a8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java @@ -6,9 +6,9 @@ import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.data.PlayerProfile; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 077b5f2bef..580365fc8c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -1,9 +1,9 @@ package com.djrapitops.plan.utilities.analysis; import com.djrapitops.plan.PlanPlugin; -import com.djrapitops.plan.data.AnalysisData; import com.djrapitops.plan.data.PlayerProfile; import com.djrapitops.plan.data.ServerProfile; +import com.djrapitops.plan.data.calculation.AnalysisData; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.plugin.BanData; import com.djrapitops.plan.data.plugin.HookHandler; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index 2b3d8a1245..c406dd5b1c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -2,9 +2,9 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.PlayerProfile; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.StickyData; -import com.djrapitops.plan.data.element.ActivityIndex; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.system.database.databases.Database; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java index fdc0949932..f9cfba8da1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.utilities.html.graphs; -import com.djrapitops.plan.data.element.ActivityIndex; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.utilities.FormatUtils; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java index 28fafff136..afdc6d8d76 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/pie/ActivityPie.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.utilities.html.graphs.pie; -import com.djrapitops.plan.data.element.ActivityIndex; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.settings.theme.ThemeVal; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java index 855a1e5303..8bdd9d3bc7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java @@ -2,7 +2,7 @@ import com.djrapitops.plan.api.PlanAPI; import com.djrapitops.plan.data.PlayerProfile; -import com.djrapitops.plan.data.element.ActivityIndex; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.TableContainer; import com.djrapitops.plan.data.plugin.PluginData; 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 097cc5520c..fab223ba9b 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 @@ -3,7 +3,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; -import com.djrapitops.plan.data.AnalysisData; +import com.djrapitops.plan.data.calculation.AnalysisData; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; @@ -214,7 +214,7 @@ public String getAnalysisHtmlAsString() { */ @Deprecated public AnalysisData getAnalysisDataFromCache() { - return new AnalysisData(); + throw new UnsupportedOperationException("No longer supported"); } /** From 311be89b0342f7c846fd738339573d4f6a9b7185 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 26 Jan 2018 11:20:12 +0200 Subject: [PATCH 060/166] fixed a bug in jquery.dataTables.js introduced in 0320b2cea83e626d06c16d13cd034d46d68d33ee --- .../resources/web/plugins/jquery-datatable/jquery.dataTables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js b/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js index 2739c76808..87566af629 100644 --- a/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js +++ b/Plan/src/main/resources/web/plugins/jquery-datatable/jquery.dataTables.js @@ -55,7 +55,7 @@ // Browser factory( jQuery, window, document ); } -}; +} (function( $, window, document, undefined ) { "use strict"; From a8b4caf58be5232ead3c29c4ba4a8c5fee5482a4 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 26 Jan 2018 11:56:29 +0200 Subject: [PATCH 061/166] Fixes some things broken earlier: - Fixed local InfoRequest handling - Fixed /player/xxx pages causing internal exception - Fixed /server/ pages remaining as "refreshing" page (Caused by Analysis being run before returning the info page, essentially overriding the finished analysis page) - Fixed /folder/xxx pages not having javascript or css. --- .../plan/command/commands/AnalyzeCommand.java | 2 +- .../databases/sql/operation/SQLErrorUtil.java | 4 +++- .../databases/sql/tables/TransferTable.java | 4 ++-- .../plan/system/info/BukkitInfoSystem.java | 1 + .../plan/system/info/connection/ConnectionIn.java | 4 ++-- .../info/request/CacheAnalysisPageRequest.java | 2 +- .../info/request/CacheInspectPageRequest.java | 2 +- .../request/CacheInspectPluginsTabRequest.java | 4 ++-- .../request/CacheNetworkPageContentRequest.java | 2 +- .../info/request/GenerateAnalysisPageRequest.java | 4 ++-- .../info/request/GenerateInspectPageRequest.java | 4 ++-- .../request/GenerateInspectPluginsTabRequest.java | 4 ++-- .../plan/system/webserver/ResponseHandler.java | 13 ++++++------- .../webserver/pages/InfoRequestPageHandler.java | 1 + .../system/webserver/pages/PlayerPageHandler.java | 3 +++ .../system/webserver/pages/RootPageHandler.java | 1 + .../system/webserver/pages/ServerPageHandler.java | 7 ++++++- .../system/webserver/pages/TreePageHandler.java | 1 + .../{pages => response}/DefaultResponses.java | 2 +- .../response/errors/NotFoundResponse.java | 3 ++- .../response/pages/AnalysisPageResponse.java | 15 +++++++++------ .../main/java/com/djrapitops/plan/api/API.java | 2 +- 22 files changed, 51 insertions(+), 34 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/system/webserver/{pages => response}/DefaultResponses.java (95%) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 25cd0b7e1c..ebe71a642a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -59,7 +59,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { Server server = getServer(args).orElseGet(ServerInfo::getServer); UUID serverUUID = server.getUuid(); if (!ServerInfo.getServerUUID().equals(serverUUID) || !Analysis.isAnalysisBeingRun()) { - InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(serverUUID)); + InfoSystem.getInstance().generateAnalysisPage(serverUUID); } sendWebUserNotificationIfNecessary(sender); sendLink(server, sender); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java index 4cbe78a90b..c3e8f1edd5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java @@ -14,7 +14,9 @@ public static DBException getExceptionFor(SQLException e) { String message = e.getMessage(); if (message.contains("Communications link failure")) { return new FatalDBException("MySQL-connection failed", e); - } else if (message.contains("syntax")) { + } else if (message.contains("syntax") + || message.contains("SQL Error or missing database") + || message.contains("no such column")) { return new FatalDBException("There is an error in SQL syntax", e); } else if (message.contains("duplicate key")) { return new FatalDBException("An SQL save method attempts to save duplicates.", e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java index 985db34e71..015ec0a5f3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -56,7 +56,7 @@ public TransferTable(SQLDB db) { columnContent + ") VALUES (" + serverTable.statementSelectServerID + ", " + - "?, ?, ?, ?, ?)"; + "?, ?, ?, ?)"; selectStatement = "SELECT * FROM " + tableName + " WHERE " + columnInfoType + "= ?" + @@ -241,7 +241,7 @@ public void prepare(PreparedStatement statement) throws SQLException { @Override public Optional processResults(ResultSet set) throws SQLException { if (set.next()) { - return Optional.of(UUID.fromString(set.getString(columnExtraVariables))); + return Optional.of(UUID.fromString(set.getString("s_uuid"))); } return Optional.empty(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java index 997a9df4c0..ca97ce4829 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java @@ -30,6 +30,7 @@ protected void runLocally(InfoRequest infoRequest) throws WebException { if (infoRequest instanceof CacheNetworkPageContentRequest) { return; } + infoRequest.placeDataToDatabase(); if (infoRequest instanceof InfoRequestWithVariables) { infoRequest.handleRequest(((InfoRequestWithVariables) infoRequest).getVariables()); } else { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java index 12f43406fb..bc154e721e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java @@ -36,7 +36,7 @@ public ConnectionIn(Request httpRequest, InfoRequest infoRequest) throws WebExce private void checkAuthentication(Map variables) throws WebException { String sender = variables.get("sender"); - NullCheck.check(sender, new BadRequestException("Sender ('sender') was not included.")); + NullCheck.check(sender, new BadRequestException("Sender ('sender') variable not supplied in the request.")); UUID serverUUID = UUID.fromString(sender); try { @@ -44,7 +44,7 @@ private void checkAuthentication(Map variables) throws WebExcept if (infoRequest instanceof RequestSetupRequest) { return; } - throw new UnauthorizedServerException(sender + "Sender was not found from database"); + throw new UnauthorizedServerException(sender + " (Sender) was not found from database"); } } catch (DBException e) { throw new TransferDatabaseException(e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java index 0cf8b50d90..45eca01b3b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; 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; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index 241d19fb67..744b9df1ac 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; 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; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java index 42a27f37a2..07f71b1252 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; 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; @@ -65,7 +65,7 @@ public Response handleRequest(Map variables) throws WebException // Available variables: sender, player String player = variables.get("player"); - NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied.")); + NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied in the request.")); UUID uuid = UUID.fromString(player); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java index ef84db1836..e15af05869 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java @@ -9,7 +9,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; -import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; 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; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index d64d717d62..4771b3a7b4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -12,7 +12,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.server.ServerInfo; -import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.pages.parsing.AnalysisPage; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; @@ -53,7 +53,7 @@ public Response handleRequest(Map variables) throws WebException // Variables available: sender, server String server = variables.get("server"); - NullCheck.check(server, new BadRequestException("Server UUID 'server' variable not supplied.")); + NullCheck.check(server, new BadRequestException("Server UUID 'server' variable not supplied in the request.")); UUID serverUUID = UUID.fromString(server); if (!ServerInfo.getServerUUID().equals(serverUUID)) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index ca55159dc4..e31f536afc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -11,7 +11,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebFailException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.info.InfoSystem; -import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.pages.parsing.InspectPage; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.NullCheck; @@ -53,7 +53,7 @@ public Response handleRequest(Map variables) throws WebException // Available variables: sender, player String player = variables.get("player"); - NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied.")); + NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied in the request.")); UUID uuid = UUID.fromString(player); String html = getHtml(uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java index 39a467af5c..2fb05d2a11 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.api.exceptions.connection.BadRequestException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; -import com.djrapitops.plan.system.webserver.pages.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; 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; @@ -51,7 +51,7 @@ public Response handleRequest(Map variables) throws WebException // Available variables: sender, player String player = variables.get("player"); - NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied.")); + NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied in the request.")); UUID uuid = UUID.fromString(player); String[] navAndhtml = getNavAndHtml(uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index e5a5a4c5a5..172da9a75c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -120,15 +120,14 @@ private Response getResponse(Request request, String targetString, List } } } - + if (targetString.endsWith(".css")) { + return ResponseCache.loadResponse(PageId.CSS.of(targetString), () -> new CSSResponse(targetString)); + } + if (targetString.endsWith(".js")) { + return ResponseCache.loadResponse(PageId.JS.of(targetString), () -> new JavaScriptResponse(targetString)); + } PageHandler pageHandler = getPageHandler(target); if (pageHandler == null) { - if (targetString.endsWith(".css")) { - return ResponseCache.loadResponse(PageId.CSS.of(targetString), () -> new CSSResponse(targetString)); - } - if (targetString.endsWith(".js")) { - return ResponseCache.loadResponse(PageId.JS.of(targetString), () -> new JavaScriptResponse(targetString)); - } return DefaultResponses.NOT_FOUND.get(); } else { if (authentication.isPresent() && pageHandler.isAuthorized(authentication.get(), target)) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java index ded1fae515..ddf89e7913 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.info.request.InfoRequest; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.NullCheck; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java index fcfe472e6b..b60a969a1a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.webserver.pages; import com.djrapitops.plan.api.exceptions.WebUserAuthException; +import com.djrapitops.plan.api.exceptions.connection.InternalErrorException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.WebUser; @@ -12,6 +13,7 @@ import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; 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; @@ -54,6 +56,7 @@ public Response getResponse(Request request, List target) throws WebExce } } catch (DBException e) { Log.toLog(this.getClass().getName(), e); + throw new InternalErrorException("Analysis", e); } return notFound("Player has not played on this server."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java index 9034bc20eb..b5f8ca26c9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/RootPageHandler.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.ResponseHandler; import com.djrapitops.plan.system.webserver.auth.Authentication; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plugin.api.utility.log.Log; 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 6ae0579530..662356dc60 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 @@ -30,7 +30,12 @@ public class ServerPageHandler extends PageHandler { @Override public Response getResponse(Request request, List target) { UUID serverUUID = getServerUUID(target); - return ResponseCache.loadResponse(PageId.SERVER.of(serverUUID), AnalysisPageResponse::refreshNow); + Response response = ResponseCache.loadResponse(PageId.SERVER.of(serverUUID)); + if (response != null) { + return response; + } else { + return AnalysisPageResponse.refreshNow(); + } } private UUID getServerUUID(List target) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java index 6d22c79b2c..89b034ea8b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/TreePageHandler.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.auth.Authentication; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import java.util.HashMap; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DefaultResponses.java similarity index 95% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java rename to Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DefaultResponses.java index f4f031a3f0..214c32f585 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/DefaultResponses.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/DefaultResponses.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.webserver.pages; +package com.djrapitops.plan.system.webserver.response; import com.djrapitops.plan.system.webserver.response.PromptAuthorizationResponse; import com.djrapitops.plan.system.webserver.response.Response; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java index 3aef2ad4cc..46273df1b0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/NotFoundResponse.java @@ -16,7 +16,8 @@ public NotFoundResponse() { } public NotFoundResponse(String msg) { - this(); + super.setHeader("HTTP/1.1 404 Not Found"); + super.setTitle(Html.FONT_AWESOME_ICON.parse("map-signs") + " 404 Not Found"); super.setParagraph(msg); super.replacePlaceholders(); } 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 6538d937f7..b2442f4c5a 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 @@ -2,6 +2,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plugin.api.utility.log.Log; @@ -13,12 +14,14 @@ public class AnalysisPageResponse extends Response { public static AnalysisPageResponse refreshNow() { - try { - InfoSystem.getInstance().generateAnalysisPageOfThisServer(); - } catch (WebException e) { - // TODO Exception handling - Log.toLog(AnalysisPageResponse.class, e); - } + Processor.queue(() -> { + try { + InfoSystem.getInstance().generateAnalysisPageOfThisServer(); + } catch (WebException e) { + // TODO Exception handling + Log.toLog(AnalysisPageResponse.class, e); + } + }); return new AnalysisPageResponse(getRefreshingHtml()); } 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 fab223ba9b..6a5555863e 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 @@ -10,7 +10,7 @@ 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.DefaultResponses; 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; From 654cdd3d62339ead7b799c2a9a0c5e7e2871ee7a Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 26 Jan 2018 12:00:16 +0200 Subject: [PATCH 062/166] Fixed /plan m backup and /plan m restore --- .../com/djrapitops/plan/system/database/databases/sql/SQLDB.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java index 3f088be73d..e4b7599a31 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java @@ -96,6 +96,7 @@ public SQLDB() { */ @Override public void init() throws DBInitException { + open = true; setStatus("Initiating"); String benchName = "Init " + getConfigName(); Benchmark.start("Database", benchName); From 3d6472343c8545e6c60562fa2f3a4a35c5d38cc7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 27 Jan 2018 13:03:22 +0200 Subject: [PATCH 063/166] Re-implemented /plan m setup & /planbungee setup (toggle) --- .../plan/command/PlanBungeeCommand.java | 2 +- .../commands/BungeeSetupToggleCommand.java | 15 ++- .../system/database/databases/Database.java | 3 +- .../plan/system/info/InfoSystem.java | 19 +++- .../system/info/connection/ConnectionIn.java | 10 +- .../system/info/connection/ConnectionOut.java | 2 +- .../info/connection/ConnectionSystem.java | 35 ++++--- .../connection}/InfoRequestPageHandler.java | 5 +- .../info/request/RequestSetupRequest.java | 28 ------ .../info/request/SaveDBSettingsRequest.java | 96 +++++++++++++++++++ .../info/request/SendDBSettingsRequest.java | 85 ++++++++++++++++ .../system/info/request/SetupRequest.java | 14 +++ .../system/webserver/ResponseHandler.java | 1 + .../analysis/ReduceGapTriangles.java | 4 +- 14 files changed, 257 insertions(+), 62 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/system/{webserver/pages => info/connection}/InfoRequestPageHandler.java (87%) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/SetupRequest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java index ac0f802b62..102b51cd47 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanBungeeCommand.java @@ -43,7 +43,7 @@ public void addCommands() { new ReloadCommand(plugin), new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()), new ListCommand(), - new BungeeSetupToggleCommand(plugin) + new BungeeSetupToggleCommand() ); RegisterCommand registerCommand = new RegisterCommand(); add( diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java index a267e56d59..f4e3b7482f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/BungeeSetupToggleCommand.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.command.commands; -import com.djrapitops.plan.PlanBungee; +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.ISender; @@ -19,20 +19,19 @@ */ public class BungeeSetupToggleCommand extends SubCommand { - private final PlanBungee plugin; - - public BungeeSetupToggleCommand(PlanBungee plugin) { + public BungeeSetupToggleCommand() { super("setup", CommandType.ALL, Permissions.MANAGE.getPermission(), "Toggle Setup mode for Bungee"); - this.plugin = plugin; } @Override public boolean onCommand(ISender sender, String s, String[] strings) { - boolean setupAllowed = plugin.isSetupAllowed(); + boolean setupAllowed = ConnectionSystem.isSetupAllowed(); + ConnectionSystem connectionSystem = ConnectionSystem.getInstance(); + if (setupAllowed) { - plugin.setSetupAllowed(false); + connectionSystem.setSetupAllowed(false); } else { - plugin.setSetupAllowed(true); + connectionSystem.setSetupAllowed(true); } String msg = !setupAllowed ? "§aSet-up is now Allowed" : "§cSet-up is now Forbidden"; sender.sendMessage(msg); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java index dff787a037..497757e571 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/Database.java @@ -10,8 +10,7 @@ /** * Abstract class representing a Database. *

    - * All methods should be only called from an asynchronous thread, unless stated - * otherwise. + * All Operations methods should be only called from an asynchronous thread. * * @author Rsl1122 */ 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 dc51f738d3..7ac3af6013 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 @@ -5,17 +5,21 @@ package com.djrapitops.plan.system.info; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.api.exceptions.connection.WebFailException; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.info.connection.ConnectionSystem; 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.system.info.request.SendDBSettingsRequest; +import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import java.util.UUID; @@ -95,8 +99,15 @@ public ConnectionSystem getConnectionSystem() { public abstract void updateNetworkPage() throws WebException; - public void requestSetUp(String address) throws WebException { - // TODO - throw new WebFailException(""); + public void requestSetUp(String addressToRequestServer) throws WebException { + if (Check.isBungeeAvailable()) { + throw new BadRequestException("Method not available on Bungee."); + } + Server bungee = new Server(-1, null, "Bungee", addressToRequestServer, -1); + String addressOfThisServer = WebServerSystem.getInstance().getWebServer().getAccessAddress(); + + ConnectionSystem connectionSystem = ConnectionSystem.getInstance(); + connectionSystem.setSetupAllowed(true); + connectionSystem.sendInfoRequest(new SendDBSettingsRequest(addressOfThisServer), bungee); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java index bc154e721e..177eae260c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java @@ -4,7 +4,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.request.InfoRequest; -import com.djrapitops.plan.system.info.request.RequestSetupRequest; +import com.djrapitops.plan.system.info.request.SetupRequest; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.NullCheck; @@ -41,8 +41,12 @@ private void checkAuthentication(Map variables) throws WebExcept try { if (!Database.getActive().check().isServerInDatabase(serverUUID)) { - if (infoRequest instanceof RequestSetupRequest) { - return; + if (infoRequest instanceof SetupRequest) { + if (ConnectionSystem.isSetupAllowed()) { + return; + } else { + throw new ForbiddenException("Setup not enabled on this server, use commands to enable."); + } } throw new UnauthorizedServerException(sender + " (Sender) was not found from database"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index 11dfc3b7ed..3e74d7fbaa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -122,7 +122,7 @@ public void sendRequest() throws WebException { case 400: throw new WebFailException("Bad Request: " + url.toString() + " | " + parameters); case 403: - throw new ForbiddenException(url.toString() + " returned 403, this is not supposed to happen."); + throw new ForbiddenException(url.toString() + " returned 403."); case 404: throw new NotFoundException(url.toString() + " returned a 404, ensure that your server is connected to an up to date Plan server."); case 412: diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index d8cc0d87ec..94d1c29cf7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -34,8 +34,10 @@ public abstract class ConnectionSystem implements SubSystem { protected final ConnectionLog connectionLog; protected final Map dataRequests; protected Map bukkitServers; + private boolean setupAllowed; public ConnectionSystem() { + setupAllowed = false; bukkitServers = new HashMap<>(); dataRequests = loadDataRequests(); connectionLog = new ConnectionLog(); @@ -47,21 +49,16 @@ public static ConnectionSystem getInstance() { return connectionSystem; } + public static boolean isSetupAllowed() { + return getInstance().setupAllowed; + } + public InfoRequest getInfoRequest(String name) { return dataRequests.get(name.toLowerCase()); } - private Map loadDataRequests() { - Map requests = new HashMap<>(); - putRequest(requests, CacheInspectPageRequest.createHandler()); - putRequest(requests, CacheInspectPluginsTabRequest.createHandler()); - putRequest(requests, CacheAnalysisPageRequest.createHandler()); - putRequest(requests, CacheNetworkPageContentRequest.createHandler()); - - putRequest(requests, GenerateAnalysisPageRequest.createHandler()); - putRequest(requests, GenerateInspectPageRequest.createHandler()); - putRequest(requests, GenerateInspectPluginsTabRequest.createHandler()); - return requests; + public void setSetupAllowed(boolean setupAllowed) { + this.setupAllowed = setupAllowed; } private void putRequest(Map requests, InfoRequest request) { @@ -104,4 +101,20 @@ protected Optional getServerWherePlayerIsOnline(GenerateInspectPageRequest } return Optional.empty(); } + + private Map loadDataRequests() { + Map requests = new HashMap<>(); + putRequest(requests, CacheInspectPageRequest.createHandler()); + putRequest(requests, CacheInspectPluginsTabRequest.createHandler()); + putRequest(requests, CacheAnalysisPageRequest.createHandler()); + putRequest(requests, CacheNetworkPageContentRequest.createHandler()); + + putRequest(requests, GenerateAnalysisPageRequest.createHandler()); + putRequest(requests, GenerateInspectPageRequest.createHandler()); + putRequest(requests, GenerateInspectPluginsTabRequest.createHandler()); + + putRequest(requests, SaveDBSettingsRequest.createHandler()); + putRequest(requests, SendDBSettingsRequest.createHandler()); + return requests; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java similarity index 87% rename from Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java rename to Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java index ddf89e7913..3d1584634e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/InfoRequestPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java @@ -2,14 +2,13 @@ * 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.webserver.pages; +package com.djrapitops.plan.system.info.connection; import com.djrapitops.plan.api.exceptions.connection.NotFoundException; import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.system.info.connection.ConnectionIn; -import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.info.request.InfoRequest; import com.djrapitops.plan.system.webserver.Request; +import com.djrapitops.plan.system.webserver.pages.PageHandler; import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.NullCheck; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java deleted file mode 100644 index 64a9d089c8..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/RequestSetupRequest.java +++ /dev/null @@ -1,28 +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.system.info.request; - -import com.djrapitops.plan.system.webserver.response.Response; - -import java.util.Map; - -/** - * InfoRequest for /plan m setup command. - * - * @author Rsl1122 - */ -// TODO -public class RequestSetupRequest extends InfoRequestWithVariables { - - @Override - public void placeDataToDatabase() { - // Not Required with setup request. - } - - @Override - public Response handleRequest(Map variables) { - return null; - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java new file mode 100644 index 0000000000..ece10fd3b8 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java @@ -0,0 +1,96 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.Check; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.util.Map; + +/** + * InfoRequest for sending Database config settings to Bukkit servers. + * + * @author Rsl1122 + */ +public class SaveDBSettingsRequest extends InfoRequestWithVariables implements SetupRequest { + + public SaveDBSettingsRequest() { + variables.put("DB_TYPE", "mysql"); // Settings.DB_TYPE + variables.put("DB_HOST", Settings.DB_HOST.toString()); + variables.put("DB_USER", Settings.DB_USER.toString()); + variables.put("DB_PASS", Settings.DB_PASS.toString()); + variables.put("DB_DATABASE", Settings.DB_DATABASE.toString()); + variables.put("DB_PORT", Settings.DB_PORT.toString()); + } + + /** + * Private constructor for creating a handler. + */ + private SaveDBSettingsRequest(boolean b) { + } + + public static SaveDBSettingsRequest createHandler() { + return new SaveDBSettingsRequest(true); + } + + @Override + public void placeDataToDatabase() { + /* Not necessary */ + } + + @Override + public Response handleRequest(Map variables) throws WebException { + if (Check.isBungeeAvailable()) { + return new BadRequestResponse("Not supposed to be called on a Bungee server"); + } + if (Settings.BUNGEE_COPY_CONFIG.isFalse() || Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isTrue()) { + return new BadRequestResponse("Bungee config settings overridden on this server."); + } + + setSettings(variables); + Log.info("----------------------------------"); + Log.info("The Received Bungee Database Settings, restarting Plan.."); + Log.info("----------------------------------"); + Plan.getInstance().reloadPlugin(true); + + return DefaultResponses.SUCCESS.get(); + } + + private void setSettings(Map variables) throws BadRequestException { + String type = variables.get("DB_TYPE"); + String host = variables.get("DB_HOST"); + String user = variables.get("DB_USER"); + String pass = variables.get("DB_PASS"); + String database = variables.get("DB_DATABASE"); + String portS = variables.get("DB_PORT"); + + NullCheck.check(type, new BadRequestException("DB_TYPE not specified in the request.")); + NullCheck.check(host, new BadRequestException("DB_HOST not specified in the request.")); + NullCheck.check(user, new BadRequestException("DB_USER not specified in the request.")); + NullCheck.check(pass, new BadRequestException("DB_PASS not specified in the request.")); + NullCheck.check(database, new BadRequestException("DB_DATABASE not specified in the request.")); + NullCheck.check(portS, new BadRequestException("DB_PORT not specified in the request.")); + + try { + Settings.DB_PORT.set(Integer.valueOf(portS)); + } catch (NumberFormatException e) { + throw new BadRequestException("DB_PORT was not a number."); + } + Settings.DB_TYPE.set(type); + Settings.DB_HOST.set(host); + Settings.DB_USER.set(user); + Settings.DB_PASS.set(pass); + Settings.DB_DATABASE.set(database); + Settings.save(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java new file mode 100644 index 0000000000..7712125b83 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java @@ -0,0 +1,85 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.server.Server; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; +import com.djrapitops.plan.utilities.NullCheck; +import com.djrapitops.plugin.api.Check; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * InfoRequest used for requesting DB settings from Bungee. + * + * @author Rsl1122 + */ +public class SendDBSettingsRequest extends InfoRequestWithVariables implements SetupRequest { + + public SendDBSettingsRequest(String webServerAddress) { + NullCheck.check(webServerAddress, new IllegalArgumentException("webServerAddress can not be null.")); + + variables.put("address", webServerAddress); + variables.put("WebServerPort", Integer.toString(Settings.WEBSERVER_PORT.getNumber())); + variables.put("ServerName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); + variables.put("ThemeBase", Settings.THEME_BASE.toString()); + } + + private SendDBSettingsRequest() { + } + + public static SendDBSettingsRequest createHandler() { + return new SendDBSettingsRequest(); + } + + @Override + public void placeDataToDatabase() { + /* Not necessary */ + } + + @Override + public Response handleRequest(Map variables) throws WebException { + // Available variables: sender, address + if (Check.isBukkitAvailable()) { + return new BadRequestResponse("Not supposed to be called on a Bukkit server"); + } + + String address = variables.get("address"); + NullCheck.check(address, new BadRequestException("WebServer Address ('address') not specified in the request.")); + + String webServerPortS = variables.get("WebServerPort"); + String serverName = variables.get("ServerName"); + String themeBase = variables.get("ThemeBase"); + NullCheck.check(webServerPortS, new BadRequestException("WebServer Port ('WebServerPort') not specified in the request.")); + NullCheck.check(serverName, new BadRequestException("Server Name ('ServerName') not specified in the request.")); + NullCheck.check(themeBase, new BadRequestException("Theme Base ('ThemeBase') not specified in the request.")); + + UUID serverUUID = UUID.fromString(variables.get("sender")); + setOriginalSettings(serverUUID, webServerPortS, serverName, themeBase); + + Server bukkit = new Server(-1, serverUUID, serverName, address, -1); + + InfoSystem.getInstance().getConnectionSystem().sendInfoRequest(new SaveDBSettingsRequest(), bukkit); + + return DefaultResponses.SUCCESS.get(); + } + + private void setOriginalSettings(UUID serverUUID, String webServerPortS, String serverName, String themeBase) { + Map settings = new HashMap<>(); + int webServerPort = Integer.parseInt(webServerPortS); + settings.put("WebServerPort", webServerPort); + settings.put("ServerName", serverName); + settings.put("ThemeBase", themeBase); + Settings.serverSpecific().addOriginalBukkitSettings(serverUUID, settings); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SetupRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SetupRequest.java new file mode 100644 index 0000000000..f21e38fd2c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SetupRequest.java @@ -0,0 +1,14 @@ +/* + * 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.info.request; + +/** + * InfoRequest that is related to initial communications. + * + * @author Rsl1122 + */ +public interface SetupRequest extends InfoRequest { + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 172da9a75c..c6c72a1d57 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException; import com.djrapitops.plan.api.exceptions.connection.*; +import com.djrapitops.plan.system.info.connection.InfoRequestPageHandler; import com.djrapitops.plan.system.webserver.auth.Authentication; import com.djrapitops.plan.system.webserver.pages.*; import com.djrapitops.plan.system.webserver.response.*; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ReduceGapTriangles.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ReduceGapTriangles.java index 3de42f283a..805e306775 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ReduceGapTriangles.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ReduceGapTriangles.java @@ -9,7 +9,9 @@ import java.util.Set; /** - * Created by Fuzzlemann on 30.07.2017. + * Utility for reducing Points in LineGraphs. + * + * @author Rsl1122 (Refactored into this class by Fuzzlemann) */ public class ReduceGapTriangles { From 1de272366263c66d6c861a25138dcfe03d0fd1e7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 27 Jan 2018 13:16:45 +0200 Subject: [PATCH 064/166] Re-implemented GraphTest. --- .../commands/manage/ManageSetupCommand.java | 3 +- .../djrapitops/plan/ui/graphs/GraphTest.java | 71 +++++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index c024a40e91..8f328762bb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -15,8 +15,7 @@ import com.djrapitops.plugin.command.SubCommand; /** - * This manage subcommand is used to swap to a different database and reload the - * plugin if the connection to the new database can be established. + * This manage SubCommand is used to request settings from Bungee so that connection can be established. * * @author Rsl1122 * @since 2.3.0 diff --git a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java b/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java index 2d071de613..14df8854d3 100644 --- a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java @@ -1,57 +1,37 @@ -/* +/* * 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.ui.graphs; -import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.data.time.WorldTimes; -import com.djrapitops.plan.utilities.analysis.Point; import com.djrapitops.plan.utilities.html.graphs.line.*; -import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.RandomData; -import test.utilities.TestInit; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import java.util.Stack; + +import static org.junit.Assert.assertTrue; /** - * @author Fuzzlemann + * Tests various Graphs. + * + * @author Rsl1122 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({JavaPlugin.class}) public class GraphTest { private final List tpsList = new ArrayList<>(); - private final List sessionList = new ArrayList<>(); - private final Map geoList = new HashMap<>(); - private final WorldTimes worldTimes = new WorldTimes("WORLD", "SURVIVAL"); - - private List points = new ArrayList<>(); @Before - public void setUp() throws Exception { - TestInit t = TestInit.init(); + public void setUp() { for (int i = 0; i < 10; i++) { tpsList.add(new TPS(i, i, i, i, i, i, i)); - sessionList.add(new Session(i, (long) i, (long) i, i, i)); - geoList.put(String.valueOf(i), i); } - - points = RandomData.randomPoints(); } @Test - @Ignore("Test should use Stack instead") public void testLineGraphsForBracketErrors() { AbstractLineGraph[] graphs = new AbstractLineGraph[]{ new CPUGraph(tpsList), @@ -63,8 +43,41 @@ public void testLineGraphsForBracketErrors() { }; for (AbstractLineGraph graph : graphs) { + System.out.print("Bracket Test: " + graph.getClass().getSimpleName() + " | "); String series = graph.toHighChartsSeries(); - // TODO Use Stack instead. + + System.out.println(series); + + char[] chars = series.toCharArray(); + assertBracketMatch(chars); + } + } + + private void assertBracketMatch(char[] chars) { + Stack bracketStack = new Stack<>(); + for (int i = 0; i < chars.length; i++) { + char c = chars[i]; + switch (c) { + case '{': + case '[': + case '(': + bracketStack.push(c); + break; + case ')': + Character pop = bracketStack.pop(); + assertTrue("Bracket mismatch at char: " + i + " Expected (, got " + pop, '(' == pop); + break; + case ']': + Character pop1 = bracketStack.pop(); + assertTrue("Bracket mismatch at char: " + i + " Expected [, got " + pop1, '[' == pop1); + break; + case '}': + Character pop2 = bracketStack.pop(); + assertTrue("Bracket mismatch at char: " + i + " Expected {, got " + pop2, '{' == pop2); + break; + default: + break; + } } } } From 83e90c74db61f8a84a7bab60558765c13197c029 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 27 Jan 2018 13:46:34 +0200 Subject: [PATCH 065/166] Started work on Test cleanup: - Moved test packages to standard Maven test path - Removed PowerMock & EasyMock and started using only Mockito - Started writing BukkitMockUtil --- Plan/pom.xml | 47 +-- .../djrapitops/plan/data/PlayerKillTest.java | 2 +- .../plan/data/PlayerProfileTest.java | 2 +- .../com/djrapitops/plan/data/SessionTest.java | 0 .../djrapitops/plan/data/UserInfoTest.java | 2 +- .../importer/ImportBuilderTest.java | 2 +- .../plan/data/cache/DataCacheTest.java | 0 .../plan/data/cache/GeolocationCacheTest.java | 2 +- .../plan/data/cache/ResponseCacheTest.java | 2 +- .../plan/data/cache/SessionCacheTest.java | 2 +- .../plan/data/time/GMTimesTest.java | 0 .../plan/data/time/WorldTimesTest.java | 2 +- .../plan/system/BukkitSystemTest.java | 13 + .../plan/system/cache/SessionCacheTest.java | 6 +- .../plan/system/database/MySQLTest.java | 0 .../plan/system/database/SQLiteTest.java | 14 +- .../databases/sql/tables/ActionsTest.java | 0 .../system/settings}/PermissionsTest.java | 5 +- .../plan/system/settings}/SettingsTest.java | 5 +- .../plan/system/webserver/WebServerTest.java | 4 +- .../plan/utilities/ConditionTest.java | 6 +- .../plan/utilities/FormatUtilsTest.java | 6 +- .../plan/utilities/MiscUtilsTest.java | 9 +- .../plan/utilities/PassEncryptTest.java | 2 +- .../utilities/analysis/AnalysisUtilsTest.java | 2 +- .../utilities/analysis/MathUtilsTest.java | 2 +- .../utilities/comparators/ComparatorTest.java | 2 +- .../plan/utilities/export/HastebinTest.java | 4 +- .../plan/utilities/html}/HtmlTest.java | 3 +- .../plan/utilities/html}/HtmlUtilsTest.java | 5 +- .../utilities/html}/graphs/GraphTest.java | 2 +- .../test/java/utilities/BukkitMockUtil.java | 92 ++++++ Plan/src/test/java/utilities/DBTestSuite.java | 51 ++++ Plan/src/test/java/utilities/MockUtils.java | 216 +++++++++++++ Plan/src/test/java/utilities/RandomData.java | 77 +++++ .../test/java/utilities/TestConstants.java | 18 ++ Plan/src/test/java/utilities/TestInit.java | 285 ++++++++++++++++++ Plan/src/test/java/utilities/TestUtils.java | 18 ++ .../org.mockito.plugins.MockMaker | 1 + 39 files changed, 823 insertions(+), 88 deletions(-) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/PlayerKillTest.java (96%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/PlayerProfileTest.java (99%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/SessionTest.java (100%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/UserInfoTest.java (95%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java (99%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/cache/DataCacheTest.java (100%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java (98%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java (97%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/cache/SessionCacheTest.java (96%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/time/GMTimesTest.java (100%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/data/time/WorldTimesTest.java (99%) create mode 100644 Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java rename Plan/{test/main => src/test}/java/com/djrapitops/plan/system/cache/SessionCacheTest.java (89%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/system/database/MySQLTest.java (100%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/system/database/SQLiteTest.java (98%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java (100%) rename Plan/{test/main/java/com/djrapitops/plan => src/test/java/com/djrapitops/plan/system/settings}/PermissionsTest.java (84%) rename Plan/{test/main/java/com/djrapitops/plan => src/test/java/com/djrapitops/plan/system/settings}/SettingsTest.java (93%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/system/webserver/WebServerTest.java (94%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/ConditionTest.java (93%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/FormatUtilsTest.java (98%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/MiscUtilsTest.java (96%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/PassEncryptTest.java (96%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java (97%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java (99%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java (99%) rename Plan/{test/main => src/test}/java/com/djrapitops/plan/utilities/export/HastebinTest.java (97%) rename Plan/{test/main/java/com/djrapitops/plan/ui => src/test/java/com/djrapitops/plan/utilities/html}/HtmlTest.java (91%) rename Plan/{test/main/java/com/djrapitops/plan/utilities => src/test/java/com/djrapitops/plan/utilities/html}/HtmlUtilsTest.java (93%) rename Plan/{test/main/java/com/djrapitops/plan/ui => src/test/java/com/djrapitops/plan/utilities/html}/graphs/GraphTest.java (98%) create mode 100644 Plan/src/test/java/utilities/BukkitMockUtil.java create mode 100644 Plan/src/test/java/utilities/DBTestSuite.java create mode 100644 Plan/src/test/java/utilities/MockUtils.java create mode 100644 Plan/src/test/java/utilities/RandomData.java create mode 100644 Plan/src/test/java/utilities/TestConstants.java create mode 100644 Plan/src/test/java/utilities/TestInit.java create mode 100644 Plan/src/test/java/utilities/TestUtils.java create mode 100644 Plan/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker diff --git a/Plan/pom.xml b/Plan/pom.xml index d75ce1638d..b999fc7dff 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -96,55 +96,20 @@ 1.2 compile - - - org.powermock - powermock - 1.6.6 - pom - - - org.powermock - powermock-api-mockito - 1.6.6 - - - org.powermock - powermock-module-junit4 - 1.6.6 - - - org.powermock - powermock-module-junit4-rule - 1.6.6 - - - org.powermock - powermock-classloading-xstream - 1.6.6 - + + org.mockito mockito-core - 1.10.19 - jar - - - - org.powermock - powermock-api-easymock - 1.6.6 + 2.13.0 jar - - - org.easymock - easymock - 3.4 + test junit junit 4.12 + test org.hamcrest @@ -158,7 +123,7 @@ clean package install ${project.name} ${basedir}/src/main/java - ${basedir}/test/main/java + ${basedir}/src/test/java . diff --git a/Plan/test/main/java/com/djrapitops/plan/data/PlayerKillTest.java b/Plan/src/test/java/com/djrapitops/plan/data/PlayerKillTest.java similarity index 96% rename from Plan/test/main/java/com/djrapitops/plan/data/PlayerKillTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/PlayerKillTest.java index 8817468303..387584594d 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/PlayerKillTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/PlayerKillTest.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.data.container.PlayerKill; import org.junit.Test; -import test.utilities.RandomData; +import utilities.RandomData; import java.util.UUID; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java b/Plan/src/test/java/com/djrapitops/plan/data/PlayerProfileTest.java similarity index 99% rename from Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/PlayerProfileTest.java index afb4124035..528111c236 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/PlayerProfileTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/PlayerProfileTest.java @@ -10,7 +10,7 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.TestInit; +import utilities.TestInit; import java.util.ArrayList; import java.util.List; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/SessionTest.java b/Plan/src/test/java/com/djrapitops/plan/data/SessionTest.java similarity index 100% rename from Plan/test/main/java/com/djrapitops/plan/data/SessionTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/SessionTest.java diff --git a/Plan/test/main/java/com/djrapitops/plan/data/UserInfoTest.java b/Plan/src/test/java/com/djrapitops/plan/data/UserInfoTest.java similarity index 95% rename from Plan/test/main/java/com/djrapitops/plan/data/UserInfoTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/UserInfoTest.java index cb6dc380d3..c7af8e2c23 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/UserInfoTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/UserInfoTest.java @@ -9,7 +9,7 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.TestInit; +import utilities.TestInit; /** * @author Rsl1122 diff --git a/Plan/test/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java b/Plan/src/test/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java similarity index 99% rename from Plan/test/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java index f2841cc14d..9bfb8f7e9d 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java @@ -11,7 +11,7 @@ import com.djrapitops.plan.system.processing.importing.UserImportData; import com.google.common.collect.ImmutableMap; import org.junit.Test; -import test.utilities.RandomData; +import utilities.RandomData; import java.util.Arrays; import java.util.Collections; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/DataCacheTest.java similarity index 100% rename from Plan/test/main/java/com/djrapitops/plan/data/cache/DataCacheTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/cache/DataCacheTest.java diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java similarity index 98% rename from Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java index 2f15f4516e..2403afb503 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java @@ -8,7 +8,7 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.TestInit; +import utilities.TestInit; import java.util.HashMap; import java.util.Map; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java similarity index 97% rename from Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java index 5df25db015..caff19d569 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java @@ -3,7 +3,7 @@ import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.ResponseCache; import org.junit.Test; -import test.utilities.RandomData; +import utilities.RandomData; import static junit.framework.TestCase.*; diff --git a/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/SessionCacheTest.java similarity index 96% rename from Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/cache/SessionCacheTest.java index 14690a4067..44b7e0f132 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/cache/SessionCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/cache/SessionCacheTest.java @@ -13,7 +13,7 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.TestInit; +import utilities.TestInit; /** * @author Rsl1122 diff --git a/Plan/test/main/java/com/djrapitops/plan/data/time/GMTimesTest.java b/Plan/src/test/java/com/djrapitops/plan/data/time/GMTimesTest.java similarity index 100% rename from Plan/test/main/java/com/djrapitops/plan/data/time/GMTimesTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/time/GMTimesTest.java diff --git a/Plan/test/main/java/com/djrapitops/plan/data/time/WorldTimesTest.java b/Plan/src/test/java/com/djrapitops/plan/data/time/WorldTimesTest.java similarity index 99% rename from Plan/test/main/java/com/djrapitops/plan/data/time/WorldTimesTest.java rename to Plan/src/test/java/com/djrapitops/plan/data/time/WorldTimesTest.java index b193bf6e8c..72c0dad0eb 100644 --- a/Plan/test/main/java/com/djrapitops/plan/data/time/WorldTimesTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/time/WorldTimesTest.java @@ -2,7 +2,7 @@ import com.google.common.collect.ImmutableMap; import org.junit.Test; -import test.utilities.RandomData; +import utilities.RandomData; import java.util.ArrayList; import java.util.List; diff --git a/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java new file mode 100644 index 0000000000..ac7f835b55 --- /dev/null +++ b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java @@ -0,0 +1,13 @@ +/* + * 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; + +/** + * Test for BukkitSystem. + * + * @author Rsl1122 + */ +public class BukkitSystemTest { +} \ No newline at end of file diff --git a/Plan/test/main/java/com/djrapitops/plan/system/cache/SessionCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java similarity index 89% rename from Plan/test/main/java/com/djrapitops/plan/system/cache/SessionCacheTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java index 8138c82974..e490fea969 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/cache/SessionCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java @@ -8,8 +8,8 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.MockUtils; -import test.utilities.TestInit; +import utilities.MockUtils; +import utilities.TestInit; import java.util.Optional; import java.util.UUID; @@ -37,7 +37,7 @@ public void setUp() throws Exception { @Ignore("Ignored, Requires more mocks") public void testAtomity() { SessionCache reloaded = new SessionCache(null); - Optional cachedSession = reloaded.getCachedSession(uuid); + Optional cachedSession = SessionCache.getCachedSession(uuid); assertTrue(cachedSession.isPresent()); assertEquals(session, cachedSession.get()); } diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/MySQLTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/MySQLTest.java similarity index 100% rename from Plan/test/main/java/com/djrapitops/plan/system/database/MySQLTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/database/MySQLTest.java diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java similarity index 98% rename from Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java index c82248c8dd..fe549aa12d 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/database/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java @@ -32,9 +32,10 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.MockUtils; -import test.utilities.RandomData; -import test.utilities.TestInit; +import utilities.MockUtils; +import utilities.RandomData; +import utilities.TestConstants; +import utilities.TestInit; import java.io.File; import java.io.IOException; @@ -74,7 +75,7 @@ public void setUp() throws Exception { when(plan.getDB()).thenReturn(db); - db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20)); + db.getServerTable().saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20)); File f = new File(plan.getDataFolder(), "Errors.txt"); rows = FileUtil.lines(f).size(); @@ -383,9 +384,10 @@ public void testSessionPlaytimeSaving() throws SQLException, DBInitException { assertEquals(expectedLength, sessionsTable.getPlaytime(uuid)); assertEquals(0L, sessionsTable.getPlaytime(uuid, 30000L)); - long playtimeOfServer = sessionsTable.getPlaytimeOfServer(TestInit.getServerUUID()); + UUID serverUUID = TestConstants.SERVER_UUID; + long playtimeOfServer = sessionsTable.getPlaytimeOfServer(serverUUID); assertEquals(expectedLength, playtimeOfServer); - assertEquals(0L, sessionsTable.getPlaytimeOfServer(TestInit.getServerUUID(), 30000L)); + assertEquals(0L, sessionsTable.getPlaytimeOfServer(serverUUID, 30000L)); assertEquals(1, sessionsTable.getSessionCount(uuid)); assertEquals(0, sessionsTable.getSessionCount(uuid, 30000L)); diff --git a/Plan/test/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java similarity index 100% rename from Plan/test/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTest.java diff --git a/Plan/test/main/java/com/djrapitops/plan/PermissionsTest.java b/Plan/src/test/java/com/djrapitops/plan/system/settings/PermissionsTest.java similarity index 84% rename from Plan/test/main/java/com/djrapitops/plan/PermissionsTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/settings/PermissionsTest.java index fc23be670e..00f024a911 100644 --- a/Plan/test/main/java/com/djrapitops/plan/PermissionsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/settings/PermissionsTest.java @@ -3,11 +3,10 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan; +package com.djrapitops.plan.system.settings; -import com.djrapitops.plan.system.settings.Permissions; import org.junit.Test; -import test.utilities.TestUtils; +import utilities.TestUtils; import static org.junit.Assert.assertEquals; diff --git a/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java b/Plan/src/test/java/com/djrapitops/plan/system/settings/SettingsTest.java similarity index 93% rename from Plan/test/main/java/com/djrapitops/plan/SettingsTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/settings/SettingsTest.java index 0eddb3446a..4edc42aa21 100644 --- a/Plan/test/main/java/com/djrapitops/plan/SettingsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/settings/SettingsTest.java @@ -3,16 +3,15 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan; +package com.djrapitops.plan.system.settings; -import com.djrapitops.plan.system.settings.Settings; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.TestInit; +import utilities.TestInit; import java.util.Collections; import java.util.List; diff --git a/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java b/Plan/src/test/java/com/djrapitops/plan/system/webserver/WebServerTest.java similarity index 94% rename from Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/webserver/WebServerTest.java index d5e7c4c54b..39d27ca26c 100644 --- a/Plan/test/main/java/com/djrapitops/plan/system/webserver/WebServerTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/webserver/WebServerTest.java @@ -8,8 +8,8 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.MockUtils; -import test.utilities.TestInit; +import utilities.MockUtils; +import utilities.TestInit; import java.io.IOException; import java.util.HashMap; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/ConditionTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/ConditionTest.java similarity index 93% rename from Plan/test/main/java/com/djrapitops/plan/utilities/ConditionTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/ConditionTest.java index 8ae9aba3de..8c5188e6d2 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/ConditionTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/ConditionTest.java @@ -8,9 +8,9 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.MockUtils; -import test.utilities.RandomData; -import test.utilities.TestInit; +import utilities.MockUtils; +import utilities.RandomData; +import utilities.TestInit; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertTrue; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/FormatUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java similarity index 98% rename from Plan/test/main/java/com/djrapitops/plan/utilities/FormatUtilsTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java index 41f89486bb..8a59521be2 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/FormatUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java @@ -9,9 +9,9 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.MockUtils; -import test.utilities.RandomData; -import test.utilities.TestInit; +import utilities.MockUtils; +import utilities.RandomData; +import utilities.TestInit; import java.text.SimpleDateFormat; import java.util.Date; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/MiscUtilsTest.java similarity index 96% rename from Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index f2ee6dee79..14f774611a 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -20,9 +20,10 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.MockUtils; -import test.utilities.RandomData; -import test.utilities.TestInit; +import utilities.MockUtils; +import utilities.RandomData; +import utilities.TestConstants; +import utilities.TestInit; import java.util.List; import java.util.UUID; @@ -166,7 +167,7 @@ private void setupDatabase() throws Exception { db = new SQLiteDB("debug" + MiscUtils.getTime()); db.init(); - db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20)); + db.getServerTable().saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20)); when(plan.getDB()).thenReturn(db); } diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/PassEncryptTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/PassEncryptTest.java similarity index 96% rename from Plan/test/main/java/com/djrapitops/plan/utilities/PassEncryptTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/PassEncryptTest.java index 8c50ae4e65..1bdc75290a 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/PassEncryptTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/PassEncryptTest.java @@ -2,7 +2,7 @@ import org.junit.Before; import org.junit.Test; -import test.utilities.RandomData; +import utilities.RandomData; import java.util.HashMap; import java.util.Map; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java similarity index 97% rename from Plan/test/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java index e5eee8d5c6..5513a1686e 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java @@ -11,7 +11,7 @@ import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.TestInit; +import utilities.TestInit; import java.util.Arrays; import java.util.Collections; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java similarity index 99% rename from Plan/test/main/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java index 90bccbf6b1..0039baf535 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/MathUtilsTest.java @@ -6,7 +6,7 @@ package com.djrapitops.plan.utilities.analysis; import org.junit.Test; -import test.utilities.RandomData; +import utilities.RandomData; import java.io.Serializable; import java.util.ArrayList; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java similarity index 99% rename from Plan/test/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java index 50bb909470..c6ea8069b3 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java @@ -10,7 +10,7 @@ import com.djrapitops.plan.utilities.analysis.Point; import com.google.common.collect.Ordering; import org.junit.Test; -import test.utilities.RandomData; +import utilities.RandomData; import java.util.*; import java.util.stream.Collectors; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/export/HastebinTest.java similarity index 97% rename from Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/export/HastebinTest.java index ad6d76af3e..3637d6fb67 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/export/HastebinTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/export/HastebinTest.java @@ -13,8 +13,8 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.RandomData; -import test.utilities.TestInit; +import utilities.RandomData; +import utilities.TestInit; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/Plan/test/main/java/com/djrapitops/plan/ui/HtmlTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlTest.java similarity index 91% rename from Plan/test/main/java/com/djrapitops/plan/ui/HtmlTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlTest.java index ef5af70608..0901c9a4b3 100644 --- a/Plan/test/main/java/com/djrapitops/plan/ui/HtmlTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlTest.java @@ -3,9 +3,8 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan.ui; +package com.djrapitops.plan.utilities.html; -import com.djrapitops.plan.utilities.html.Html; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/HtmlUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlUtilsTest.java similarity index 93% rename from Plan/test/main/java/com/djrapitops/plan/utilities/HtmlUtilsTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlUtilsTest.java index 9a88ba575d..4e886fbba8 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/HtmlUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlUtilsTest.java @@ -3,16 +3,15 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan.utilities; +package com.djrapitops.plan.utilities.html; -import com.djrapitops.plan.utilities.html.HtmlUtils; import com.google.common.collect.ImmutableMap; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import test.utilities.RandomData; +import utilities.RandomData; import java.io.Serializable; import java.util.Map; diff --git a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/html/graphs/GraphTest.java similarity index 98% rename from Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java rename to Plan/src/test/java/com/djrapitops/plan/utilities/html/graphs/GraphTest.java index 14df8854d3..72c953538e 100644 --- a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/html/graphs/GraphTest.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.ui.graphs; +package com.djrapitops.plan.utilities.html.graphs; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.utilities.html.graphs.line.*; diff --git a/Plan/src/test/java/utilities/BukkitMockUtil.java b/Plan/src/test/java/utilities/BukkitMockUtil.java new file mode 100644 index 0000000000..22d0176f1e --- /dev/null +++ b/Plan/src/test/java/utilities/BukkitMockUtil.java @@ -0,0 +1,92 @@ +/* + * 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 utilities; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plugin.StaticHolder; +import org.bukkit.plugin.InvalidDescriptionException; +import org.bukkit.plugin.PluginDescriptionFile; +import org.mockito.Mockito; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.logging.Logger; + +import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.Mockito.when; + +/** + * Mocking Utility for Bukkit version of Plan. + * + * @author Rsl1122 + */ +public class BukkitMockUtil { + + private Plan planMock; + + private BukkitMockUtil() { + } + + public static BukkitMockUtil init() { + return new BukkitMockUtil().mockPlugin(); + } + + public BukkitMockUtil mockPlugin() { + planMock = Mockito.mock(Plan.class); + StaticHolder.register(Plan.class, planMock); + StaticHolder.register(planMock); + return this; + } + + public BukkitMockUtil withDataFolder(File tempFolder) { + when(planMock.getDataFolder()).thenReturn(tempFolder); + return this; + } + + public BukkitMockUtil withLogging() { + doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString()); + when(planMock.getLogger()).thenReturn(Logger.getGlobal()); + return this; + } + + private File getFile(String fileName) { + return new File(getClass().getResource(fileName).getPath()); + } + + public BukkitMockUtil withPluginDescription() { + try { + File pluginYml = getFile("/plugin.yml"); + PluginDescriptionFile description = new PluginDescriptionFile(new FileInputStream(pluginYml)); + when(planMock.getDescription()).thenReturn(description); + } catch (FileNotFoundException | InvalidDescriptionException e) { + System.out.println("Error while setting plugin description"); + } + return this; + } + + public BukkitMockUtil withResourceFetchingFromJar() throws Exception { + withPluginFile("config.yml"); + withPluginFile("web/server.html"); + withPluginFile("web/player.html"); + return this; + } + + private void withPluginFile(String fileName) throws Exception { + if (planMock.getDataFolder() == null) { + throw new IllegalStateException("withDataFolder needs to be called before setting files"); + } + try { + File file = getFile("/" + fileName); + when(planMock.getResource(fileName)).thenReturn(new FileInputStream(file)); + } catch (NullPointerException e) { + System.out.println("File is missing! " + fileName); + } + } + + public Plan getPlanMock() { + return planMock; + } +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/DBTestSuite.java b/Plan/src/test/java/utilities/DBTestSuite.java new file mode 100644 index 0000000000..90c6748854 --- /dev/null +++ b/Plan/src/test/java/utilities/DBTestSuite.java @@ -0,0 +1,51 @@ +/* + * 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 utilities; + +import com.djrapitops.plan.system.database.MySQLTest; +import com.djrapitops.plan.system.database.SQLiteTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +import java.io.File; + +/** + * @author Fuzzlemann + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({SQLiteTest.class, MySQLTest.class}) +public class DBTestSuite { + @BeforeClass + public static void setUp() { + clean(); + } + + @AfterClass + public static void tearDown() { + clean(); + } + + private static void clean() { + File testFolder = TestInit.getTestFolder(); + + if (!testFolder.exists() || !testFolder.isDirectory()) { + return; + } + + File[] files = testFolder.listFiles(); + + if (files == null) { + return; + } + + for (File f : files) { + if (!f.delete()) { + f.deleteOnExit(); + } + } + } +} diff --git a/Plan/src/test/java/utilities/MockUtils.java b/Plan/src/test/java/utilities/MockUtils.java new file mode 100644 index 0000000000..2a3265c499 --- /dev/null +++ b/Plan/src/test/java/utilities/MockUtils.java @@ -0,0 +1,216 @@ +package utilities; + +import com.sun.net.httpserver.*; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; + +import java.io.*; +import java.net.InetSocketAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.util.*; +import java.util.zip.GZIPInputStream; + +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Rsl1122 + */ +public class MockUtils { + + public static World mockWorld() { + World mockWorld = Mockito.mock(World.class); + when(mockWorld.toString()).thenReturn("World"); + return mockWorld; + } + + public static Player mockPlayer() { + Player p = PowerMockito.mock(Player.class); + when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); + when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); + when(p.getFirstPlayed()).thenReturn(1234567L); + World mockWorld = mockWorld(); + when(p.getLocation()).thenReturn(new Location(mockWorld, 0, 0, 0)); + when(p.isOp()).thenReturn(true); + when(p.isBanned()).thenReturn(true); + when(p.isOnline()).thenReturn(true); + when(p.getName()).thenReturn("TestName"); + when(p.hasPermission("plan.inspect.other")).thenReturn(true); + return p; + } + + public static UUID getPlayerUUID() { + return UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"); + } + + public static Player mockPlayer2() { + Player p = PowerMockito.mock(Player.class); + when(p.getGameMode()).thenReturn(GameMode.SPECTATOR); + when(p.getUniqueId()).thenReturn(UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80")); + when(p.getFirstPlayed()).thenReturn(3423434L); + World mockWorld = mockWorld(); + when(p.getLocation()).thenReturn(new Location(mockWorld, 1, 0, 1)); + when(p.isOp()).thenReturn(false); + when(p.isBanned()).thenReturn(false); + when(p.isOnline()).thenReturn(false); + when(p.hasPermission("plan.inspect.other")).thenReturn(false); + when(p.getName()).thenReturn("TestName2"); + return p; + } + + public static UUID getPlayer2UUID() { + return UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80"); + } + + public static Set getUUIDs() { + Set uuids = new HashSet<>(); + uuids.add(getPlayerUUID()); + uuids.add(getPlayer2UUID()); + return uuids; + } + + public static Player mockBrokenPlayer() { + Player p = PowerMockito.mock(Player.class); + when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); + when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); + when(p.getFirstPlayed()).thenReturn(1234567L); + World mockWorld = mockWorld(); + when(p.getLocation()).thenReturn(new Location(mockWorld, 0, 0, 0)); + when(p.isOp()).thenReturn(true); + when(p.isBanned()).thenThrow(Exception.class); + when(p.isOnline()).thenReturn(true); + when(p.getName()).thenReturn("TestName"); + return p; + } + + public static CommandSender mockConsoleSender() { + return PowerMockito.mock(CommandSender.class); + } + + public static HttpServer mockHTTPServer() { + HttpServer httpServer = PowerMockito.mock(HttpServer.class); + when(httpServer.getAddress()).thenReturn(new InetSocketAddress(80)); + when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received")); + return httpServer; + } + + public static HttpExchange getHttpExchange(String requestMethod, String requestURI, String body, Map> responseHeaders) { + return new HttpExchange() { + private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + @Override + public Headers getRequestHeaders() { + Headers headers = new Headers(); + headers.put("Authorization", new ArrayList<>()); + return headers; + } + + @Override + public Headers getResponseHeaders() { + Headers headers = new Headers(); + headers.putAll(responseHeaders); + return headers; + } + + @Override + public URI getRequestURI() { + try { + return new URI(requestURI); + } catch (URISyntaxException e) { + return null; + } + } + + @Override + public String getRequestMethod() { + return requestMethod; + } + + @Override + public HttpContext getHttpContext() { + return null; + } + + @Override + public void close() { + + } + + @Override + public InputStream getRequestBody() { + return new ByteArrayInputStream(body.getBytes(Charset.forName("UTF-8"))); + } + + @Override + public OutputStream getResponseBody() { + return outputStream; + } + + @Override + public InetSocketAddress getRemoteAddress() { + return null; + } + + @Override + public InetSocketAddress getLocalAddress() { + return null; + } + + @Override + public String getProtocol() { + return null; + } + + @Override + public Object getAttribute(String name) { + return null; + } + + @Override + public void sendResponseHeaders(int i, long l) { + + } + + @Override + public int getResponseCode() { + return 0; + } + + @Override + public void setAttribute(String s, Object o) { + + } + + @Override + public void setStreams(InputStream inputStream, OutputStream outputStream) { + + } + + @Override + public HttpPrincipal getPrincipal() { + return null; + } + }; + } + + public static String getResponseStream(HttpExchange requestExchange) throws IOException { + InputStream in = new GZIPInputStream( + new ByteArrayInputStream(( + (ByteArrayOutputStream) requestExchange.getResponseBody() + ).toByteArray()) + ); + try (Scanner scanner = new Scanner(in)) { + StringBuilder s = new StringBuilder(); + while (scanner.hasNextLine()) { + s.append(scanner.nextLine()).append("\n"); + } + return s.toString(); + } + } +} diff --git a/Plan/src/test/java/utilities/RandomData.java b/Plan/src/test/java/utilities/RandomData.java new file mode 100644 index 0000000000..3fba949391 --- /dev/null +++ b/Plan/src/test/java/utilities/RandomData.java @@ -0,0 +1,77 @@ +package utilities; + +import com.djrapitops.plan.data.WebUser; +import com.djrapitops.plan.data.container.Session; +import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.data.container.UserInfo; +import com.djrapitops.plan.utilities.PassEncryptUtil; +import com.djrapitops.plan.utilities.analysis.Point; +import org.apache.commons.lang3.RandomStringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; + +public class RandomData { + + private static final Random r = new Random(); + + public static int randomInt(int rangeStart, int rangeEnd) { + return ThreadLocalRandom.current().nextInt(rangeStart, rangeEnd); + } + + public static String randomString(int size) { + return RandomStringUtils.randomAlphanumeric(size); + } + + public static List randomWebUsers() throws PassEncryptUtil.CannotPerformOperationException { + List test = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + test.add(new WebUser(randomString(5), PassEncryptUtil.createHash(randomString(7)), r.nextInt())); + } + return test; + } + + public static List randomTPS() { + List test = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + int randInt = r.nextInt(); + long randLong = r.nextLong(); + test.add(new TPS(randLong, randLong, randInt, randLong, randLong, randInt, randInt)); + } + return test; + } + + public static List randomSessions() { + List test = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + test.add(new Session(1, r.nextLong(), r.nextLong(), 0, 0)); + } + return test; + } + + public static List randomPoints() { + List test = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + test.add(new Point(r.nextLong(), r.nextLong())); + } + return test; + } + + public static T randomEnum(Class clazz) { + int x = r.nextInt(clazz.getEnumConstants().length); + return clazz.getEnumConstants()[x]; + } + + public static List randomUserData() { + List test = new ArrayList<>(); + for (int i = 0; i < 20; i++) { + UserInfo info = new UserInfo(UUID.randomUUID(), randomString(10), r.nextLong(), r.nextBoolean(), r.nextBoolean()); + info.setLastSeen(r.nextLong()); + test.add(info); + } + return test; + } +} diff --git a/Plan/src/test/java/utilities/TestConstants.java b/Plan/src/test/java/utilities/TestConstants.java new file mode 100644 index 0000000000..5e7260a373 --- /dev/null +++ b/Plan/src/test/java/utilities/TestConstants.java @@ -0,0 +1,18 @@ +/* + * 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 utilities; + +import java.util.UUID; + +/** + * Test Constants go here. + * + * @author Rsl1122 + */ +public class TestConstants { + + public static final UUID SERVER_UUID = UUID.fromString("9a27457b-f1a2-4b71-be7f-daf2170a1b66"); + +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/TestInit.java b/Plan/src/test/java/utilities/TestInit.java new file mode 100644 index 0000000000..add0e98d8a --- /dev/null +++ b/Plan/src/test/java/utilities/TestInit.java @@ -0,0 +1,285 @@ +package utilities; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.info.server.BukkitServerInfo; +import com.djrapitops.plan.system.info.server.ServerProperties; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.utilities.file.FileUtil; +import com.djrapitops.plugin.IPlugin; +import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.api.config.Config; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.settings.ColorScheme; +import com.djrapitops.plugin.task.RunnableFactory; +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.Server; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.conversations.Conversation; +import org.bukkit.conversations.ConversationAbandonedEvent; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.plugin.Plugin; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Set; +import java.util.logging.Logger; + +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Rsl1122 + */ +public class TestInit { + + private Plan planMock; + + /** + * Init locale with empty messages. + *

    + * Does not load any messages from anywhere because that would cause exceptions. + */ + public static void initEmptyLocale() { + new Locale(); + } + + /** + * Init locale with mocked Plan. + *

    + * requires getDataFolder mock. + * + * @param plan Mocked Plan + */ + public static void initLocale(Plan plan) { + new Locale().loadLocale(); + } + + public static TestInit init() throws Exception { + TestInit t = new TestInit(); + t.setUp(); + return t; + } + + static File getTestFolder() { + File testFolder = new File("temporaryTestFolder"); + testFolder.mkdir(); + return testFolder; + } + + private void setUp() throws Exception { + planMock = PowerMockito.mock(Plan.class); + + StaticHolder.register(Plan.class, planMock); + StaticHolder.register(planMock); + + // Hacks to make APF find classes + StaticHolder.register(IPlugin.class, planMock); + StaticHolder.saveInstance(this.getClass(), Plan.class); + StaticHolder.saveInstance(PowerMockRunner.class, Plan.class); + + Log.setDebugMode("console"); + + File testFolder = getTestFolder(); + when(planMock.getDataFolder()).thenReturn(testFolder); + + // Files + File config = new File(getClass().getResource("/config.yml").getPath()); + when(planMock.getResource("config.yml")).thenReturn(new FileInputStream(config)); + File analysis = new File(getClass().getResource("/web/server.html").getPath()); + when(planMock.getResource("/web/server.html")).thenReturn(new FileInputStream(analysis)); + File player = new File(getClass().getResource("/web/player.html").getPath()); + when(planMock.getResource("/web/player.html")).thenReturn(new FileInputStream(player)); + + File tempConfigFile = new File(planMock.getDataFolder(), "config.yml"); + Config iConfig = new Config(tempConfigFile, FileUtil.lines(planMock, "config.yml")) { + @Override + public void save() { + } + }; + Server mockServer = mockServer(); + + when(planMock.getServer()).thenReturn(mockServer); + + // Test log settings + when(planMock.getLogger()).thenReturn(Logger.getGlobal()); + Settings.DEBUG.setTemporaryValue(true); + + ServerProperties serverProperties = new ServerProperties(mockServer); + +// when(planMock.getVariable()).thenReturn(serverProperties); + BukkitServerInfo bukkitServerInfo = PowerMockito.mock(BukkitServerInfo.class); + +// DataCache dataCache = new DataCache(planMock) { +// @Override +// public String getName(UUID uuid) { +// return ""; +// } +// }; +// when(planMock.getDataCache()).thenReturn(dataCache); + + ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK); + when(planMock.getColorScheme()).thenReturn(cs); + initLocale(null); + + RunnableFactory.activateTestMode(); + } + + private Server mockServer() { + Server mockServer = PowerMockito.mock(Server.class); + + OfflinePlayer[] ops = new OfflinePlayer[]{MockUtils.mockPlayer(), MockUtils.mockPlayer2()}; + + when(mockServer.getIp()).thenReturn("0.0.0.0"); + when(mockServer.getMaxPlayers()).thenReturn(20); + when(mockServer.getName()).thenReturn("Bukkit"); + when(mockServer.getOfflinePlayers()).thenReturn(ops); + ConsoleCommandSender sender = mockServerCmdSender(); + when(mockServer.getConsoleSender()).thenReturn(sender); + return mockServer; + } + + private ConsoleCommandSender mockServerCmdSender() { + return new ConsoleCommandSender() { + @Override + public void sendMessage(String s) { + System.out.println("Log: " + s); + } + + @Override + public void sendMessage(String[] strings) { + for (String string : strings) { + sendMessage(string); + } + } + + @Override + public Server getServer() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public Spigot spigot() { + return null; + } + + @Override + public boolean isConversing() { + return false; + } + + @Override + public void acceptConversationInput(String s) { + + } + + @Override + public boolean beginConversation(Conversation conversation) { + return false; + } + + @Override + public void abandonConversation(Conversation conversation) { + + } + + @Override + public void abandonConversation(Conversation conversation, ConversationAbandonedEvent conversationAbandonedEvent) { + + } + + @Override + public void sendRawMessage(String s) { + + } + + @Override + public boolean isPermissionSet(String s) { + return false; + } + + @Override + public boolean isPermissionSet(Permission permission) { + return false; + } + + @Override + public boolean hasPermission(String s) { + return false; + } + + @Override + public boolean hasPermission(Permission permission) { + return false; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin) { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, int i) { + return null; + } + + @Override + public void removeAttachment(PermissionAttachment permissionAttachment) { + + } + + @Override + public void recalculatePermissions() { + + } + + @Override + public Set getEffectivePermissions() { + return null; + } + + @Override + public boolean isOp() { + return false; + } + + @Override + public void setOp(boolean b) { + + } + }; + } + + private YamlConfiguration mockConfig() throws IOException, InvalidConfigurationException { + File configFile = new File(getClass().getResource("/config.yml").getPath()); + YamlConfiguration configuration = new YamlConfiguration(); + configuration.load(configFile.getAbsolutePath()); + return configuration; + } + + public Plan getPlanMock() { + return planMock; + } +} diff --git a/Plan/src/test/java/utilities/TestUtils.java b/Plan/src/test/java/utilities/TestUtils.java new file mode 100644 index 0000000000..a4e032861e --- /dev/null +++ b/Plan/src/test/java/utilities/TestUtils.java @@ -0,0 +1,18 @@ +/* + * 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 utilities; + +import java.lang.reflect.Field; + +/** + * @author Fuzzlemann + */ +public class TestUtils { + public static String getStringFieldValue(Enum enumeration, String modifier) throws NoSuchFieldException, IllegalAccessException { + Field field = enumeration.getClass().getDeclaredField(modifier); + field.setAccessible(true); + return (String) field.get(enumeration); + } +} diff --git a/Plan/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/Plan/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 0000000000..ca6ee9cea8 --- /dev/null +++ b/Plan/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline \ No newline at end of file From 0b57955c9cc1778cd25e85d7ce1a3ac931015e18 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 27 Jan 2018 17:30:44 +0200 Subject: [PATCH 066/166] Fixed most tests. Fixed Bungee init (with a test). Test Cleanup. --- Plan/pom.xml | 8 + .../java/com/djrapitops/plan/PlanBungee.java | 11 +- .../java/com/djrapitops/plan/PlanPlugin.java | 23 +- .../com/djrapitops/plan/api/BukkitAPI.java | 33 +- .../com/djrapitops/plan/api/BungeeAPI.java | 40 +++ .../com/djrapitops/plan/api/CommonAPI.java | 47 +++ .../djrapitops/plan/system/BukkitSystem.java | 2 + .../djrapitops/plan/system/BungeeSystem.java | 12 + .../djrapitops/plan/system/PlanSystem.java | 15 +- .../plan/system/database/DBSystem.java | 4 + .../databases/sql/operation/SQLErrorUtil.java | 3 + .../system/info/server/BungeeServerInfo.java | 28 +- .../system/info/server/ServerProperties.java | 12 +- .../plan/system/settings/Settings.java | 21 +- .../plan/utilities/file/FileUtil.java | 2 +- .../plan/data/PlayerProfileTest.java | 22 +- .../com/djrapitops/plan/data/SessionTest.java | 25 -- .../djrapitops/plan/data/UserInfoTest.java | 36 --- .../plan/data/cache/DataCacheTest.java | 45 --- .../plan/data/cache/GeolocationCacheTest.java | 25 +- .../plan/data/cache/SessionCacheTest.java | 37 --- .../plan/system/BukkitSystemTest.java | 41 +++ .../plan/system/BungeeSystemTest.java | 83 +++++ .../plan/system/cache/SessionCacheTest.java | 28 +- .../plan/system/database/SQLiteTest.java | 298 +++++++++--------- .../plan/system/settings/PermissionsTest.java | 27 -- .../plan/system/settings/SettingsTest.java | 71 ----- .../plan/system/webserver/WebServerTest.java | 28 +- .../plan/utilities/ConditionTest.java | 53 ---- .../plan/utilities/FormatUtilsTest.java | 25 +- .../plan/utilities/MiscUtilsTest.java | 60 ++-- .../utilities/analysis/AnalysisUtilsTest.java | 13 - .../plan/utilities/export/HastebinTest.java | 32 +- .../plan/utilities/html/HtmlUtilsTest.java | 8 +- Plan/src/test/java/utilities/DBTestSuite.java | 51 --- .../test/java/utilities/TestConstants.java | 7 +- .../test/java/utilities/TestErrorManager.java | 20 ++ Plan/src/test/java/utilities/TestInit.java | 285 ----------------- Plan/src/test/java/utilities/TestUtils.java | 18 -- .../utilities/{ => mocks}/BukkitMockUtil.java | 50 +-- .../java/utilities/mocks/BungeeMockUtil.java | 102 ++++++ .../test/java/utilities/mocks/MockUtil.java | 50 +++ .../java/utilities/mocks/SystemMockUtil.java | 72 +++++ .../mocks/objects/FakeBungeeConsole.java | 79 +++++ .../mocks/objects/FakeConsoleCmdSender.java | 147 +++++++++ .../{ => mocks/objects}/MockUtils.java | 32 +- .../main/java/test/utilities/DBTestSuite.java | 51 --- .../main/java/test/utilities/MockUtils.java | 216 ------------- .../main/java/test/utilities/RandomData.java | 77 ----- .../main/java/test/utilities/TestInit.java | 291 ----------------- .../main/java/test/utilities/TestUtils.java | 18 -- 51 files changed, 1095 insertions(+), 1689 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/BungeeAPI.java create mode 100644 Plan/src/main/java/com/djrapitops/plan/api/CommonAPI.java delete mode 100644 Plan/src/test/java/com/djrapitops/plan/data/SessionTest.java delete mode 100644 Plan/src/test/java/com/djrapitops/plan/data/UserInfoTest.java delete mode 100644 Plan/src/test/java/com/djrapitops/plan/data/cache/DataCacheTest.java delete mode 100644 Plan/src/test/java/com/djrapitops/plan/data/cache/SessionCacheTest.java create mode 100644 Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java delete mode 100644 Plan/src/test/java/com/djrapitops/plan/system/settings/PermissionsTest.java delete mode 100644 Plan/src/test/java/com/djrapitops/plan/system/settings/SettingsTest.java delete mode 100644 Plan/src/test/java/com/djrapitops/plan/utilities/ConditionTest.java delete mode 100644 Plan/src/test/java/utilities/DBTestSuite.java create mode 100644 Plan/src/test/java/utilities/TestErrorManager.java delete mode 100644 Plan/src/test/java/utilities/TestInit.java delete mode 100644 Plan/src/test/java/utilities/TestUtils.java rename Plan/src/test/java/utilities/{ => mocks}/BukkitMockUtil.java (59%) create mode 100644 Plan/src/test/java/utilities/mocks/BungeeMockUtil.java create mode 100644 Plan/src/test/java/utilities/mocks/MockUtil.java create mode 100644 Plan/src/test/java/utilities/mocks/SystemMockUtil.java create mode 100644 Plan/src/test/java/utilities/mocks/objects/FakeBungeeConsole.java create mode 100644 Plan/src/test/java/utilities/mocks/objects/FakeConsoleCmdSender.java rename Plan/src/test/java/utilities/{ => mocks/objects}/MockUtils.java (87%) delete mode 100644 Plan/test/main/java/test/utilities/DBTestSuite.java delete mode 100644 Plan/test/main/java/test/utilities/MockUtils.java delete mode 100644 Plan/test/main/java/test/utilities/RandomData.java delete mode 100644 Plan/test/main/java/test/utilities/TestInit.java delete mode 100644 Plan/test/main/java/test/utilities/TestUtils.java diff --git a/Plan/pom.xml b/Plan/pom.xml index b999fc7dff..506fa900d5 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -105,6 +105,14 @@ jar test + + + + org.xerial + sqlite-jdbc + 3.21.0 + test + junit junit diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index f61495c84f..16f5e69aed 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -8,7 +8,6 @@ import com.djrapitops.plan.system.BungeeSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.theme.PlanColorScheme; @@ -47,17 +46,9 @@ public void onEnable() { system = new BungeeSystem(this); system.enable(); - // TODO BungeeServerInfo & move there. - String ip = ServerInfo.getServerProperties().getIp(); - if ("0.0.0.0".equals(ip)) { - Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); - Log.info("Player Analytics partially enabled (Use /planbungee to reload config)"); - return; - } - Log.info(Locale.get(Msg.ENABLED).toString()); } catch (Exception e) { - Log.error("Plugin Failed to Initialize Correctly."); + Log.error("Plugin Failed to Initialize Correctly:"); Log.toLog(this.getClass().getName(), e); } registerCommand("planbungee", new PlanBungeeCommand(this)); diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index cfe50bd5ea..153e4aa2e4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -22,12 +22,23 @@ public interface PlanPlugin extends IPlugin { static PlanPlugin getInstance() { boolean bukkitAvailable = Check.isBukkitAvailable(); boolean bungeeAvailable = Check.isBungeeAvailable(); - if (bukkitAvailable && bungeeAvailable) { - // TODO Test Plugin - } else if (bukkitAvailable) { - return Plan.getInstance(); - } else if (bungeeAvailable) { - return PlanBungee.getInstance(); + if (bukkitAvailable) { + try { + Plan instance = Plan.getInstance(); + if (instance != null) { + return instance; + } + } catch (IllegalStateException ignored) { + } + } + if (bungeeAvailable) { + try { + PlanBungee instance = PlanBungee.getInstance(); + if (instance != null) { + return instance; + } + } catch (IllegalStateException ignored) { + } } throw new IllegalAccessError("Plugin instance not available"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java index 2bb305721d..eb90022fac 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java @@ -4,22 +4,18 @@ */ 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 + * PlanAPI extension for Bukkit * * @author Rsl1122 */ -public class BukkitAPI implements PlanAPI { +public class BukkitAPI extends CommonAPI { private final BukkitSystem bukkitSystem; @@ -32,36 +28,11 @@ 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 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(); diff --git a/Plan/src/main/java/com/djrapitops/plan/api/BungeeAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/BungeeAPI.java new file mode 100644 index 0000000000..3e3c53757e --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/BungeeAPI.java @@ -0,0 +1,40 @@ +/* + * 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.data.plugin.PluginData; +import com.djrapitops.plan.system.BungeeSystem; +import com.djrapitops.plan.system.database.databases.operation.FetchOperations; + +import java.util.UUID; + +/** + * PlanAPI extension for Bungee. + * + * @author Rsl1122 + */ +public class BungeeAPI extends CommonAPI { + + private final BungeeSystem bungeeSystem; + + public BungeeAPI(BungeeSystem bungeeSystem) { + this.bungeeSystem = bungeeSystem; + } + + @Override + public void addPluginDataSource(PluginData pluginData) { + bungeeSystem.getHookHandler().addPluginDataSource(pluginData); + } + + @Override + public String getPlayerName(UUID uuid) { + return bungeeSystem.getCacheSystem().getDataCache().getName(uuid); + } + + @Override + public FetchOperations fetchFromPlanDB() { + return bungeeSystem.getDatabaseSystem().getActiveDatabase().fetch(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/api/CommonAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/CommonAPI.java new file mode 100644 index 0000000000..0d1d128268 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/api/CommonAPI.java @@ -0,0 +1,47 @@ +/* + * 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.utilities.uuid.UUIDUtility; +import com.djrapitops.plugin.api.utility.log.Log; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * PlanAPI extension for all implementations. + * + * @author Rsl1122 + */ +public abstract class CommonAPI implements PlanAPI { + + @Override + public String getPlayerInspectPageLink(UUID uuid) { + return getPlayerInspectPageLink(getPlayerName(uuid)); + } + + @Override + public String getPlayerInspectPageLink(String playerName) { + return "../player/" + playerName; + } + + @Override + public UUID playerNameToUUID(String playerName) { + return UUIDUtility.getUUIDOf(playerName); + } + + @Override + public Map getKnownPlayerNames() { + try { + return fetchFromPlanDB().getPlayerNames(); + } catch (DBException e) { + Log.toLog(this.getClass(), e); + return new HashMap<>(); + } + } + +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index 9563b43854..74d84a31ff 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -26,6 +26,8 @@ public class BukkitSystem extends PlanSystem { public BukkitSystem(Plan plugin) { + testSystem = this; + versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); fileSystem = new FileSystem(plugin); configSystem = new BukkitConfigSystem(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java index 86fc6525fa..b779d0c814 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -5,7 +5,10 @@ package com.djrapitops.plan.system; import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.api.BungeeAPI; +import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.system.database.BungeeDBSystem; +import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.info.BungeeInfoSystem; import com.djrapitops.plan.system.info.server.BungeeServerInfo; @@ -22,6 +25,8 @@ public class BungeeSystem extends PlanSystem { public BungeeSystem(PlanBungee plugin) { + testSystem = this; + versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); fileSystem = new FileSystem(plugin); configSystem = new BungeeConfigSystem(); @@ -31,9 +36,16 @@ public BungeeSystem(PlanBungee plugin) { infoSystem = new BungeeInfoSystem(); serverInfo = new BungeeServerInfo(plugin); + + hookHandler = new HookHandler(); + planAPI = new BungeeAPI(this); } public static BungeeSystem getInstance() { return PlanBungee.getInstance().getSystem(); } + + public void setDatabaseSystem(DBSystem dbSystem) { + this.databaseSystem = dbSystem; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 6e185baa27..922aa4e53a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Check; +import com.djrapitops.plugin.api.utility.log.Log; /** * PlanSystem contains everything Plan needs to run. @@ -30,6 +31,8 @@ */ public abstract class PlanSystem implements SubSystem { + protected static PlanSystem testSystem; + // Initialized in this class protected final ProcessingQueue processingQueue; protected final WebServerSystem webServerSystem; @@ -59,10 +62,10 @@ public static PlanSystem getInstance() { boolean bukkitAvailable = Check.isBukkitAvailable(); boolean bungeeAvailable = Check.isBungeeAvailable(); if (bukkitAvailable && bungeeAvailable) { - // TODO test system. + return testSystem; } else if (bungeeAvailable) { return BungeeSystem.getInstance(); - } else { + } else if (bukkitAvailable) { return BukkitSystem.getInstance(); } throw new IllegalAccessError("PlanSystem is not available on this platform."); @@ -106,8 +109,12 @@ public void disable() { versionCheckSystem }; for (SubSystem system : systems) { - if (system != null) { - system.disable(); + try { + if (system != null) { + system.disable(); + } + } catch (Exception e) { + Log.toLog(this.getClass(), e); } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index f60527b532..7576bf1a09 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -85,4 +85,8 @@ public static Database getActiveDatabaseByName(String dbName) throws DBInitExcep } throw new DBInitException(Locale.get(Msg.ENABLE_FAIL_WRONG_DB) + " " + dbName); } + + public void setActiveDatabase(Database db) { + this.db = db; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java index c3e8f1edd5..6fa20cb0d6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLErrorUtil.java @@ -14,8 +14,11 @@ public static DBException getExceptionFor(SQLException e) { String message = e.getMessage(); if (message.contains("Communications link failure")) { return new FatalDBException("MySQL-connection failed", e); + } else if (message.contains("constraint failed")) { + return new FatalDBException("There is an error in saving an item.", e); } else if (message.contains("syntax") || message.contains("SQL Error or missing database") + || message.contains("SQLITE_MISUSE") || message.contains("no such column")) { return new FatalDBException("There is an error in SQL syntax", e); } else if (message.contains("duplicate key")) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java index bfc1f08d87..7fe2504501 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BungeeServerInfo.java @@ -9,6 +9,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.webserver.WebServerSystem; +import com.djrapitops.plugin.api.utility.log.Log; import java.util.Optional; import java.util.UUID; @@ -25,23 +26,38 @@ public BungeeServerInfo(PlanBungee plugin) { } public Server loadServerInfo() throws EnableException { + checkIfDefaultIP(); + try { Database db = Database.getActive(); Optional bungeeInfo = db.fetch().getBungeeInformation(); if (bungeeInfo.isPresent()) { server = bungeeInfo.get(); - String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); - if (!accessAddress.equals(server.getWebAddress())) { - server.setWebAddress(accessAddress); - db.save().serverInfoForThisServer(server); - } + updateServerInfo(db); } else { server = registerBungeeInfo(db); } } catch (DBException e) { throw new EnableException("Failed to read Database for Server"); } - return null; + return server; + } + + private void updateServerInfo(Database db) throws DBException { + String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); + if (!accessAddress.equals(server.getWebAddress())) { + server.setWebAddress(accessAddress); + db.save().serverInfoForThisServer(server); + } + } + + private void checkIfDefaultIP() throws EnableException { + String ip = ServerInfo.getServerProperties().getIp(); + if ("0.0.0.0".equals(ip)) { + Log.error("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); + Log.info("Player Analytics partially enabled (Use /planbungee to reload config)"); + throw new EnableException("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); + } } private Server registerBungeeInfo(Database db) throws DBException, EnableException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java index 4517b020f4..20a545626a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java @@ -18,14 +18,14 @@ public class ServerProperties { private final int port; private final String version; private final String implVersion; - private final String ip; + private final IPWrapper ip; private final int maxPlayers; private final OnlinePlayersWrapper onlinePlayers; public ServerProperties(Server server) { id = server.getServerId(); - ip = server.getIp(); + ip = server::getIp; name = server.getName(); port = server.getPort(); version = server.getVersion(); @@ -43,7 +43,7 @@ public ServerProperties(Server server) { */ public ServerProperties(ProxyServer server) { id = server.getServers().toString(); - ip = Settings.BUNGEE_IP.toString(); + ip = Settings.BUNGEE_IP::toString; name = "BungeeCord"; port = -1; version = server.getVersion(); @@ -60,7 +60,7 @@ public ServerProperties(ProxyServer server) { * @return the ip. */ public String getIp() { - return ip; + return ip.getIP(); } public String getName() { @@ -94,4 +94,8 @@ public int getOnlinePlayers() { private interface OnlinePlayersWrapper { int getOnlinePlayers(); } + + private interface IPWrapper { + String getIP(); + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index c69dcd7e5a..1eeb72de32 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -1,6 +1,7 @@ package com.djrapitops.plan.system.settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.config.Config; import com.djrapitops.plugin.api.utility.log.Log; @@ -96,7 +97,7 @@ public enum Settings { private static final ServerSpecificSettings serverSpecificSettings = new ServerSpecificSettings(); private final String configPath; - private Boolean value; + private Object tempValue; Settings(String path) { this.configPath = path; @@ -116,8 +117,8 @@ public static ServerSpecificSettings serverSpecific() { * @return Boolean value of the config setting, false if not boolean. */ public boolean isTrue() { - if (value != null) { - return value; + if (tempValue != null) { + return (Boolean) tempValue; } return getConfig().getBoolean(configPath); } @@ -141,6 +142,9 @@ public static void save() { */ @Override public String toString() { + if (tempValue != null) { + return String.valueOf(tempValue); + } return getConfig().getString(configPath); } @@ -150,6 +154,9 @@ public String toString() { * @return Integer value of the config setting */ public int getNumber() { + if (tempValue != null) { + return (Integer) tempValue; + } return getConfig().getInt(configPath); } @@ -167,8 +174,8 @@ public String getPath() { return configPath; } - public void setTemporaryValue(Boolean value) { - this.value = value; + public void setTemporaryValue(Object value) { + this.tempValue = value; } public void set(Object value) { @@ -176,6 +183,8 @@ public void set(Object value) { } private Config getConfig() { - return ConfigSystem.getConfig(); + Config config = ConfigSystem.getConfig(); + NullCheck.check(config, new IllegalStateException("Settings are not supposed to be called before ConfigSystem is Enabled!")); + return config; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java index 0a8319700a..dfb176f5c8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/FileUtil.java @@ -81,7 +81,7 @@ public static List lines(PlanPlugin plugin, String resource) throws IOEx lines.add(scanner.nextLine()); } } catch (NullPointerException e) { - Log.infoColor("§ea Resource was not found inside the jar, Plan does not support /reload or updates using " + + Log.infoColor("§ea Resource was not found inside the jar (" + resource + "), Plan does not support /reload or updates using " + "Plugin Managers, restart the server and see if the error persists."); throw new FileNotFoundException("File not found inside jar: " + resource); } finally { diff --git a/Plan/src/test/java/com/djrapitops/plan/data/PlayerProfileTest.java b/Plan/src/test/java/com/djrapitops/plan/data/PlayerProfileTest.java index 528111c236..0827fd9688 100644 --- a/Plan/src/test/java/com/djrapitops/plan/data/PlayerProfileTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/PlayerProfileTest.java @@ -4,13 +4,13 @@ import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.TestInit; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.mocks.SystemMockUtil; import java.util.ArrayList; import java.util.List; @@ -18,13 +18,15 @@ import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.assertTrue; -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) +@RunWith(MockitoJUnitRunner.Silent.class) public class PlayerProfileTest { - @Before - public void setUp() throws Exception { - TestInit.init(); + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @BeforeClass + public static void setUpClass() throws Exception { + SystemMockUtil.setUp(temporaryFolder.getRoot()).enableConfigSystem(); } @Test diff --git a/Plan/src/test/java/com/djrapitops/plan/data/SessionTest.java b/Plan/src/test/java/com/djrapitops/plan/data/SessionTest.java deleted file mode 100644 index 02396a7c18..0000000000 --- a/Plan/src/test/java/com/djrapitops/plan/data/SessionTest.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.data; - -import com.djrapitops.plan.data.container.Session; -import org.junit.Before; -import org.junit.Ignore; - -/** - * @author Rsl1122 - */ -@Ignore -public class SessionTest { - - private Session session; - - @Before - public void setUp() { - } - - // TODO Rewrite -} diff --git a/Plan/src/test/java/com/djrapitops/plan/data/UserInfoTest.java b/Plan/src/test/java/com/djrapitops/plan/data/UserInfoTest.java deleted file mode 100644 index c7af8e2c23..0000000000 --- a/Plan/src/test/java/com/djrapitops/plan/data/UserInfoTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.djrapitops.plan.data; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.data.container.UserInfo; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.TestInit; - -/** - * @author Rsl1122 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) -@Ignore -public class UserInfoTest { - // TODO Rewrite - - private UserInfo session; - private Plan plan; - - @Before - public void setUp() throws Exception { - TestInit.init(); - } - - @Test - @Ignore - public void test() { - // TODO Rewrite - } -} diff --git a/Plan/src/test/java/com/djrapitops/plan/data/cache/DataCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/DataCacheTest.java deleted file mode 100644 index 5c86cf1e25..0000000000 --- a/Plan/src/test/java/com/djrapitops/plan/data/cache/DataCacheTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.data.cache; - -import com.djrapitops.plan.system.cache.DataCache; -import com.djrapitops.plan.system.database.databases.Database; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) -public class DataCacheTest { - - private Database db; - private DataCache dataCache; - - private int callsToSaveCommandUse; - private int callsToSaveUserData; - private int callsToSaveMultiple; - - @Before - public void setUp() { - - } - - @After - public void tearDown() { - - } - - @Ignore - @Test - public void testHandler() { - // TODO - } -} diff --git a/Plan/src/test/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java index 2403afb503..9e7771bad3 100644 --- a/Plan/src/test/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/cache/GeolocationCacheTest.java @@ -2,13 +2,14 @@ import com.djrapitops.plan.system.cache.CacheSystem; import com.djrapitops.plan.system.cache.GeolocationCache; -import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.TestInit; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.mocks.SystemMockUtil; import java.util.HashMap; import java.util.Map; @@ -18,15 +19,23 @@ /** * @author Fuzzlemann */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) +@RunWith(MockitoJUnitRunner.Silent.class) public class GeolocationCacheTest { private final Map ipsToCountries = new HashMap<>(); + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @BeforeClass + public static void setUpClass() throws Exception { + SystemMockUtil.setUp(temporaryFolder.getRoot()) + .enableConfigSystem() + .enableCacheSystem(); + } + @Before - public void setUp() throws Exception { - TestInit.init(); + public void setUp() { CacheSystem.getInstance().getGeolocationCache().clearCache(); ipsToCountries.put("8.8.8.8", "United States"); diff --git a/Plan/src/test/java/com/djrapitops/plan/data/cache/SessionCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/SessionCacheTest.java deleted file mode 100644 index 44b7e0f132..0000000000 --- a/Plan/src/test/java/com/djrapitops/plan/data/cache/SessionCacheTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.data.cache; - -import com.djrapitops.plan.system.cache.SessionCache; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.TestInit; - -/** - * @author Rsl1122 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) -public class SessionCacheTest { - - private SessionCache test; - - @Before - public void setUp() throws Exception { - TestInit.init(); - } - - @Test - @Ignore - public void test() { - // TODO Rewrite - } -} diff --git a/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java index ac7f835b55..f0f8f2cf27 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java @@ -4,10 +4,51 @@ */ package com.djrapitops.plan.system; +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.EnableException; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.mocks.BukkitMockUtil; + /** * Test for BukkitSystem. * * @author Rsl1122 */ +@RunWith(MockitoJUnitRunner.class) public class BukkitSystemTest { + + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + private static Plan planMock; + private BukkitSystem bukkitSystem; + + @BeforeClass + public static void setUpClass() throws Exception { + BukkitMockUtil mockUtil = BukkitMockUtil.setUp() + .withDataFolder(temporaryFolder.getRoot()) + .withLogging() + .withPluginDescription() + .withResourceFetchingFromJar() + .withServer(); + planMock = mockUtil.getPlanMock(); + } + + @After + public void tearDown() { + if (bukkitSystem != null) { + bukkitSystem.disable(); + } + } + + @Test + public void testEnable() throws EnableException { + bukkitSystem = new BukkitSystem(planMock); + bukkitSystem.enable(); + } } \ No newline at end of file diff --git a/Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java b/Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java new file mode 100644 index 0000000000..e213cd692f --- /dev/null +++ b/Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java @@ -0,0 +1,83 @@ +/* + * 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; + +import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.database.BukkitDBSystem; +import com.djrapitops.plan.system.settings.Settings; +import org.junit.*; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.mocks.BungeeMockUtil; + +/** + * Test for BukkitSystem. + * + * @author Rsl1122 + */ +@RunWith(MockitoJUnitRunner.Silent.class) +public class BungeeSystemTest { + + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + private static PlanBungee planMock; + @Rule + public ExpectedException thrown = ExpectedException.none(); + private BungeeSystem bungeeSystem; + + @Before + public void setUp() throws Exception { + BungeeMockUtil mockUtil = BungeeMockUtil.setUp() + .withDataFolder(temporaryFolder.getRoot()) + .withLogging() + .withPluginDescription() + .withResourceFetchingFromJar() + .withProxy(); + planMock = mockUtil.getPlanMock(); + } + + @After + public void tearDown() { + if (bungeeSystem != null) { + bungeeSystem.disable(); + } + } + + @Test + public void testEnable() throws EnableException { + bungeeSystem = new BungeeSystem(planMock); + + Settings.BUNGEE_IP.setTemporaryValue("8.8.8.8"); + Settings.DB_TYPE.setTemporaryValue("sqlite"); + bungeeSystem.setDatabaseSystem(new BukkitDBSystem()); + + bungeeSystem.enable(); + } + + @Test + public void testEnableDefaultIP() throws EnableException { + thrown.expect(EnableException.class); + thrown.expectMessage("IP setting still 0.0.0.0 - Configure AlternativeIP/IP that connects to the Proxy server."); + + bungeeSystem = new BungeeSystem(planMock); + + Settings.DB_TYPE.setTemporaryValue("sqlite"); + bungeeSystem.setDatabaseSystem(new BukkitDBSystem()); + + bungeeSystem.enable(); + } + + @Test + public void testEnableNoMySQL() throws EnableException { + thrown.expect(EnableException.class); + thrown.expectMessage("Database failed to initialize"); + + bungeeSystem = new BungeeSystem(planMock); + bungeeSystem.enable(); + } +} \ No newline at end of file diff --git a/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java index e490fea969..b80c95144e 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java @@ -1,15 +1,13 @@ package com.djrapitops.plan.system.cache; import com.djrapitops.plan.data.container.Session; -import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; -import org.junit.Ignore; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.MockUtils; -import utilities.TestInit; +import org.junit.rules.TemporaryFolder; +import utilities.TestConstants; +import utilities.mocks.SystemMockUtil; import java.util.Optional; import java.util.UUID; @@ -17,24 +15,28 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) public class SessionCacheTest { - private final UUID uuid = MockUtils.getPlayerUUID(); + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); private SessionCache sessionCache; private Session session; + private final UUID uuid = TestConstants.PLAYER_ONE_UUID; + + @BeforeClass + public static void setUpClass() throws Exception { + SystemMockUtil.setUp(temporaryFolder.getRoot()) + .enableProcessingQueue(); + } @Before - public void setUp() throws Exception { - TestInit t = TestInit.init(); + public void setUp() { sessionCache = new SessionCache(null); session = new Session(12345L, "World1", "SURVIVAL"); sessionCache.cacheSession(uuid, session); } @Test - @Ignore("Ignored, Requires more mocks") public void testAtomity() { SessionCache reloaded = new SessionCache(null); Optional cachedSession = SessionCache.getCachedSession(uuid); diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java index fe549aa12d..e4ca8f7df2 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java @@ -19,86 +19,74 @@ import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.ManageUtils; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.analysis.MathUtils; -import com.djrapitops.plan.utilities.file.FileUtil; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.api.utility.log.Log; +import org.junit.*; +import org.junit.rules.TemporaryFolder; import org.junit.rules.Timeout; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.MockUtils; +import org.mockito.junit.MockitoJUnitRunner; import utilities.RandomData; import utilities.TestConstants; -import utilities.TestInit; +import utilities.TestErrorManager; +import utilities.mocks.SystemMockUtil; -import java.io.File; -import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; import java.sql.SQLException; import java.util.*; import static org.junit.Assert.*; -import static org.powermock.api.mockito.PowerMockito.when; /** * @author Rsl1122 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({JavaPlugin.class}) +@RunWith(MockitoJUnitRunner.Silent.class) public class SQLiteTest { - private final UUID uuid = MockUtils.getPlayerUUID(); private final List worlds = Arrays.asList("TestWorld", "TestWorld2"); - private final UUID uuid2 = MockUtils.getPlayer2UUID(); - private Plan plan; - private SQLDB db; - private SQLDB backup; - private int rows; - + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + private static SQLDB db; + private final UUID playerUUID = TestConstants.PLAYER_ONE_UUID; + private final UUID player2UUID = TestConstants.PLAYER_TWO_UUID; @Rule - public Timeout globalTimeout = Timeout.seconds(7); // 5 seconds max per method tested - - @Before - public void setUp() throws Exception { - TestInit t = TestInit.init(); - plan = t.getPlanMock(); + public Timeout globalTimeout = Timeout.seconds(5); + + @BeforeClass + public static void setUpClass() throws Exception { + db = new SQLiteDB(); + SystemMockUtil.setUp(temporaryFolder.getRoot()) + .enableConfigSystem() + .enableDatabaseSystem(db) + .enableServerInfoSystem(); + StaticHolder.saveInstance(SQLDB.class, Plan.class); + StaticHolder.saveInstance(SQLiteTest.class, Plan.class); + + Log.setErrorManager(new TestErrorManager()); + Log.setDebugMode("console"); + Settings.DEV_MODE.setTemporaryValue(true); - db = new SQLiteDB("debug" + MiscUtils.getTime()); db.init(); - - when(plan.getDB()).thenReturn(db); - - db.getServerTable().saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20)); - - File f = new File(plan.getDataFolder(), "Errors.txt"); - rows = FileUtil.lines(f).size(); } - @After - public void tearDown() throws IOException { - db.close(); - if (backup != null) { - backup.close(); - } - - File f = new File(plan.getDataFolder(), "Errors.txt"); - - List lines = FileUtil.lines(f); - int rowsAgain = lines.size(); - if (rowsAgain > 0) { - for (String line : lines) { - System.out.println(line); - } + @AfterClass + public static void tearDownClass() { + if (db != null) { + db.close(); } + } - assertTrue("Errors were caught.", rows == rowsAgain); + @Before + public void setUp() throws DBException, SQLException { + db.remove().everything(); + ServerTable serverTable = db.getServerTable(); + serverTable.saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20)); + assertEquals(ServerInfo.getServerUUID(), TestConstants.SERVER_UUID); } @Test @@ -108,8 +96,6 @@ public void testInit() throws DBInitException { @Test public void testNoExceptionWhenCommitEmpty() throws Exception { - db.init(); - db.commit(db.getConnection()); db.commit(db.getConnection()); db.commit(db.getConnection()); @@ -231,7 +217,7 @@ private void saveUserOne() throws SQLException { } private void saveUserOne(SQLDB database) throws SQLException { - database.getUsersTable().registerUser(uuid, 123456789L, "Test"); + database.getUsersTable().registerUser(playerUUID, 123456789L, "Test"); } private void saveUserTwo() throws SQLException { @@ -239,7 +225,7 @@ private void saveUserTwo() throws SQLException { } private void saveUserTwo(SQLDB database) throws SQLException { - database.getUsersTable().registerUser(uuid2, 123456789L, "Test"); + database.getUsersTable().registerUser(player2UUID, 123456789L, "Test"); } @Test @@ -250,9 +236,9 @@ public void testActionsTable() throws SQLException { Action save = new Action(234567890L, Actions.FIRST_SESSION, "Additional Info"); Action expected = new Action(234567890L, Actions.FIRST_SESSION, "Additional Info", 1); - actionsTable.insertAction(uuid, save); + actionsTable.insertAction(playerUUID, save); - List actions = actionsTable.getActions(uuid); + List actions = actionsTable.getActions(playerUUID); assertEquals(expected, actions.get(0)); } @@ -266,11 +252,11 @@ public void testIPTable() throws SQLException, DBInitException { long time = MiscUtils.getTime(); GeoInfo expected = new GeoInfo(expectedIP, expectedGeoLoc, time); - geoInfoTable.saveGeoInfo(uuid, expected); - geoInfoTable.saveGeoInfo(uuid, expected); + geoInfoTable.saveGeoInfo(playerUUID, expected); + geoInfoTable.saveGeoInfo(playerUUID, expected); commitTest(); - List getInfo = geoInfoTable.getGeoInfo(uuid); + List getInfo = geoInfoTable.getGeoInfo(playerUUID); assertEquals(1, getInfo.size()); GeoInfo actual = getInfo.get(0); assertEquals(expected, actual); @@ -287,15 +273,15 @@ public void testNicknamesTable() throws SQLException, DBInitException { NicknamesTable nickTable = db.getNicknamesTable(); String expected = "TestNickname"; - nickTable.saveUserName(uuid, expected); - nickTable.saveUserName(uuid, expected); + nickTable.saveUserName(playerUUID, expected); + nickTable.saveUserName(playerUUID, expected); commitTest(); - List nicknames = nickTable.getNicknames(uuid); + List nicknames = nickTable.getNicknames(playerUUID); assertEquals(1, nicknames.size()); assertEquals(expected, nicknames.get(0)); - Map> allNicknames = nickTable.getAllNicknames(uuid); + Map> allNicknames = nickTable.getAllNicknames(playerUUID); assertEquals(nicknames, allNicknames.get(ServerInfo.getServerUUID())); } @@ -357,8 +343,8 @@ private WorldTimes createWorldTimes() { private List createKills() { List kills = new ArrayList<>(); - kills.add(new PlayerKill(uuid2, "Iron Sword", 4321L)); - kills.add(new PlayerKill(uuid2, "Gold Sword", 5321L)); + kills.add(new PlayerKill(TestConstants.PLAYER_TWO_UUID, "Iron Sword", 4321L)); + kills.add(new PlayerKill(TestConstants.PLAYER_TWO_UUID, "Gold Sword", 5321L)); return kills; } @@ -377,20 +363,20 @@ public void testSessionPlaytimeSaving() throws SQLException, DBInitException { assertEquals(expectedLength, session.getWorldTimes().getTotal()); SessionsTable sessionsTable = db.getSessionsTable(); - sessionsTable.saveSession(uuid, session); + sessionsTable.saveSession(playerUUID, session); commitTest(); - assertEquals(expectedLength, sessionsTable.getPlaytime(uuid)); - assertEquals(0L, sessionsTable.getPlaytime(uuid, 30000L)); + assertEquals(expectedLength, sessionsTable.getPlaytime(playerUUID)); + assertEquals(0L, sessionsTable.getPlaytime(playerUUID, 30000L)); UUID serverUUID = TestConstants.SERVER_UUID; long playtimeOfServer = sessionsTable.getPlaytimeOfServer(serverUUID); assertEquals(expectedLength, playtimeOfServer); assertEquals(0L, sessionsTable.getPlaytimeOfServer(serverUUID, 30000L)); - assertEquals(1, sessionsTable.getSessionCount(uuid)); - assertEquals(0, sessionsTable.getSessionCount(uuid, 30000L)); + assertEquals(1, sessionsTable.getSessionCount(playerUUID)); + assertEquals(0, sessionsTable.getSessionCount(playerUUID, 30000L)); } @Test @@ -404,11 +390,11 @@ public void testSessionSaving() throws SQLException, DBInitException { session.setPlayerKills(createKills()); SessionsTable sessionsTable = db.getSessionsTable(); - sessionsTable.saveSession(uuid, session); + sessionsTable.saveSession(playerUUID, session); commitTest(); - Map> sessions = sessionsTable.getSessions(uuid); + Map> sessions = sessionsTable.getSessions(playerUUID); for (Map.Entry> entry : sessions.entrySet()) { UUID key = entry.getKey(); @@ -429,27 +415,27 @@ public void testSessionSaving() throws SQLException, DBInitException { assertEquals(session, savedSessions.get(0)); Map lastSeen = sessionsTable.getLastSeenForAllPlayers(); - assertTrue(lastSeen.containsKey(uuid)); - assertFalse(lastSeen.containsKey(uuid2)); - assertEquals(22345L, (long) lastSeen.get(uuid)); + assertTrue(lastSeen.containsKey(playerUUID)); + assertFalse(lastSeen.containsKey(TestConstants.PLAYER_TWO_UUID)); + assertEquals(22345L, (long) lastSeen.get(playerUUID)); } @Test public void testUserInfoTableRegisterUnRegistered() throws SQLException, DBInitException { UserInfoTable userInfoTable = db.getUserInfoTable(); - assertFalse(userInfoTable.isRegistered(uuid)); + assertFalse(userInfoTable.isRegistered(playerUUID)); UsersTable usersTable = db.getUsersTable(); - assertFalse(usersTable.isRegistered(uuid)); + assertFalse(usersTable.isRegistered(playerUUID)); - userInfoTable.registerUserInfo(uuid, 123456789L); + userInfoTable.registerUserInfo(playerUUID, 123456789L); commitTest(); - assertTrue(usersTable.isRegistered(uuid)); - assertTrue(userInfoTable.isRegistered(uuid)); + assertTrue(usersTable.isRegistered(playerUUID)); + assertTrue(userInfoTable.isRegistered(playerUUID)); - UserInfo userInfo = userInfoTable.getUserInfo(uuid); - assertEquals(uuid, userInfo.getUuid()); + UserInfo userInfo = userInfoTable.getUserInfo(playerUUID); + assertEquals(playerUUID, userInfo.getUuid()); assertEquals(123456789L, (long) usersTable.getRegisterDates().get(0)); assertEquals(123456789L, userInfo.getRegistered()); assertEquals(1, userInfoTable.getServerUserCount(ServerInfo.getServerUUID())); @@ -462,19 +448,19 @@ public void testUserInfoTableRegisterUnRegistered() throws SQLException, DBInitE public void testUserInfoTableRegisterRegistered() throws SQLException, DBInitException { saveUserOne(); UsersTable usersTable = db.getUsersTable(); - assertTrue(usersTable.isRegistered(uuid)); + assertTrue(usersTable.isRegistered(playerUUID)); UserInfoTable userInfoTable = db.getUserInfoTable(); - assertFalse(userInfoTable.isRegistered(uuid)); + assertFalse(userInfoTable.isRegistered(playerUUID)); - userInfoTable.registerUserInfo(uuid, 223456789L); + userInfoTable.registerUserInfo(playerUUID, 223456789L); commitTest(); - assertTrue(usersTable.isRegistered(uuid)); - assertTrue(userInfoTable.isRegistered(uuid)); + assertTrue(usersTable.isRegistered(playerUUID)); + assertTrue(userInfoTable.isRegistered(playerUUID)); - UserInfo userInfo = userInfoTable.getUserInfo(uuid); - assertEquals(uuid, userInfo.getUuid()); + UserInfo userInfo = userInfoTable.getUserInfo(playerUUID); + assertEquals(playerUUID, userInfo.getUuid()); assertEquals(123456789L, (long) usersTable.getRegisterDates().get(0)); assertEquals(223456789L, userInfo.getRegistered()); assertEquals("Test", userInfo.getName()); @@ -487,31 +473,31 @@ public void testUserInfoTableRegisterRegistered() throws SQLException, DBInitExc @Test public void testUserInfoTableUpdateBannedOpped() throws SQLException, DBInitException { UserInfoTable userInfoTable = db.getUserInfoTable(); - userInfoTable.registerUserInfo(uuid, 223456789L); - assertTrue(userInfoTable.isRegistered(uuid)); + userInfoTable.registerUserInfo(playerUUID, 223456789L); + assertTrue(userInfoTable.isRegistered(playerUUID)); - userInfoTable.updateOpStatus(uuid, true); - userInfoTable.updateBanStatus(uuid, true); + userInfoTable.updateOpStatus(playerUUID, true); + userInfoTable.updateBanStatus(playerUUID, true); commitTest(); - UserInfo userInfo = userInfoTable.getUserInfo(uuid); + UserInfo userInfo = userInfoTable.getUserInfo(playerUUID); assertTrue(userInfo.isBanned()); assertTrue(userInfo.isOpped()); - userInfoTable.updateOpStatus(uuid, false); - userInfoTable.updateBanStatus(uuid, true); + userInfoTable.updateOpStatus(playerUUID, false); + userInfoTable.updateBanStatus(playerUUID, true); commitTest(); - userInfo = userInfoTable.getUserInfo(uuid); + userInfo = userInfoTable.getUserInfo(playerUUID); assertTrue(userInfo.isBanned()); assertFalse(userInfo.isOpped()); - userInfoTable.updateOpStatus(uuid, true); - userInfoTable.updateBanStatus(uuid, false); + userInfoTable.updateOpStatus(playerUUID, true); + userInfoTable.updateBanStatus(playerUUID, false); commitTest(); - userInfo = userInfoTable.getUserInfo(uuid); + userInfo = userInfoTable.getUserInfo(playerUUID); assertFalse(userInfo.isBanned()); assertTrue(userInfo.isOpped()); @@ -523,30 +509,30 @@ public void testUsersTableUpdateName() throws SQLException, DBInitException { UsersTable usersTable = db.getUsersTable(); - assertEquals(uuid, usersTable.getUuidOf("Test")); - usersTable.updateName(uuid, "NewName"); + assertEquals(playerUUID, usersTable.getUuidOf("Test")); + usersTable.updateName(playerUUID, "NewName"); commitTest(); assertNull(usersTable.getUuidOf("Test")); - assertEquals("NewName", usersTable.getPlayerName(uuid)); - assertEquals(uuid, usersTable.getUuidOf("NewName")); + assertEquals("NewName", usersTable.getPlayerName(playerUUID)); + assertEquals(playerUUID, usersTable.getUuidOf("NewName")); } @Test public void testUsersTableKickSaving() throws SQLException, DBInitException { saveUserOne(); UsersTable usersTable = db.getUsersTable(); - assertEquals(0, usersTable.getTimesKicked(uuid)); + assertEquals(0, usersTable.getTimesKicked(playerUUID)); int random = new Random().nextInt(20); for (int i = 0; i < random + 1; i++) { - usersTable.kicked(uuid); + usersTable.kicked(playerUUID); } commitTest(); - assertEquals(random + 1, usersTable.getTimesKicked(uuid)); + assertEquals(random + 1, usersTable.getTimesKicked(playerUUID)); } @Test @@ -560,7 +546,7 @@ public void testRemovalSingleUser() throws SQLException, DBException { GeoInfoTable geoInfoTable = db.getGeoInfoTable(); ActionsTable actionsTable = db.getActionsTable(); - userInfoTable.registerUserInfo(uuid, 223456789L); + userInfoTable.registerUserInfo(playerUUID, 223456789L); saveTwoWorlds(); Session session = new Session(12345L, "", ""); @@ -568,21 +554,21 @@ public void testRemovalSingleUser() throws SQLException, DBException { session.setWorldTimes(createWorldTimes()); session.setPlayerKills(createKills()); - sessionsTable.saveSession(uuid, session); - nicknamesTable.saveUserName(uuid, "TestNick"); - geoInfoTable.saveGeoInfo(uuid, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); - actionsTable.insertAction(uuid, new Action(1324L, Actions.FIRST_SESSION, "Add")); + sessionsTable.saveSession(playerUUID, session); + nicknamesTable.saveUserName(playerUUID, "TestNick"); + geoInfoTable.saveGeoInfo(playerUUID, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); + actionsTable.insertAction(playerUUID, new Action(1324L, Actions.FIRST_SESSION, "Add")); - assertTrue(usersTable.isRegistered(uuid)); + assertTrue(usersTable.isRegistered(playerUUID)); - db.remove().player(uuid); + db.remove().player(playerUUID); - assertFalse(usersTable.isRegistered(uuid)); - assertFalse(userInfoTable.isRegistered(uuid)); - assertTrue(nicknamesTable.getNicknames(uuid).isEmpty()); - assertTrue(geoInfoTable.getGeoInfo(uuid).isEmpty()); - assertTrue(sessionsTable.getSessions(uuid).isEmpty()); - assertTrue(actionsTable.getActions(uuid).isEmpty()); + assertFalse(usersTable.isRegistered(playerUUID)); + assertFalse(userInfoTable.isRegistered(playerUUID)); + assertTrue(nicknamesTable.getNicknames(playerUUID).isEmpty()); + assertTrue(geoInfoTable.getGeoInfo(playerUUID).isEmpty()); + assertTrue(sessionsTable.getSessions(playerUUID).isEmpty()); + assertTrue(actionsTable.getActions(playerUUID).isEmpty()); } @Test @@ -600,14 +586,14 @@ public void testRemovalEverything() throws SQLException, DBException { db.remove().everything(); - assertFalse(usersTable.isRegistered(uuid)); - assertFalse(usersTable.isRegistered(uuid2)); - assertFalse(userInfoTable.isRegistered(uuid)); + assertFalse(usersTable.isRegistered(playerUUID)); + assertFalse(usersTable.isRegistered(TestConstants.PLAYER_TWO_UUID)); + assertFalse(userInfoTable.isRegistered(playerUUID)); - assertTrue(nicknamesTable.getNicknames(uuid).isEmpty()); - assertTrue(geoInfoTable.getGeoInfo(uuid).isEmpty()); - assertTrue(sessionsTable.getSessions(uuid).isEmpty()); - assertTrue(actionsTable.getActions(uuid).isEmpty()); + assertTrue(nicknamesTable.getNicknames(playerUUID).isEmpty()); + assertTrue(geoInfoTable.getGeoInfo(playerUUID).isEmpty()); + assertTrue(sessionsTable.getSessions(playerUUID).isEmpty()); + assertTrue(actionsTable.getActions(playerUUID).isEmpty()); assertTrue(db.getCommandUseTable().getCommandUse().isEmpty()); assertTrue(db.getWorldTable().getWorlds().isEmpty()); assertTrue(tpsTable.getTPSData().isEmpty()); @@ -629,7 +615,7 @@ private void saveAllData(SQLDB database) throws SQLException { saveUserOne(database); saveUserTwo(database); - userInfoTable.registerUserInfo(uuid, 223456789L); + userInfoTable.registerUserInfo(playerUUID, 223456789L); saveTwoWorlds(database); Session session = new Session(12345L, "", ""); @@ -637,12 +623,12 @@ private void saveAllData(SQLDB database) throws SQLException { session.setWorldTimes(createWorldTimes()); session.setPlayerKills(createKills()); - sessionsTable.saveSession(uuid, session); - nicknamesTable.saveUserName(uuid, "TestNick"); - geoInfoTable.saveGeoInfo(uuid, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); - actionsTable.insertAction(uuid, new Action(1324L, Actions.FIRST_SESSION, "Add")); + sessionsTable.saveSession(playerUUID, session); + nicknamesTable.saveUserName(playerUUID, "TestNick"); + geoInfoTable.saveGeoInfo(playerUUID, new GeoInfo("1.2.3.4", "TestLoc", 223456789L)); + actionsTable.insertAction(playerUUID, new Action(1324L, Actions.FIRST_SESSION, "Add")); - assertTrue(usersTable.isRegistered(uuid)); + assertTrue(usersTable.isRegistered(playerUUID)); CommandUseTable commandUseTable = database.getCommandUseTable(); commandUseTable.commandUsed("plan"); @@ -727,7 +713,7 @@ public void testSessionTableGetInfoOfServer() throws SQLException, DBInitExcepti session.setPlayerKills(createKills()); SessionsTable sessionsTable = db.getSessionsTable(); - sessionsTable.saveSession(uuid, session); + sessionsTable.saveSession(playerUUID, session); commitTest(); @@ -736,7 +722,7 @@ public void testSessionTableGetInfoOfServer() throws SQLException, DBInitExcepti session.setPlayerKills(new ArrayList<>()); session.setWorldTimes(new WorldTimes(new HashMap<>())); - List sSessions = sessions.get(uuid); + List sSessions = sessions.get(playerUUID); assertFalse(sessions.isEmpty()); assertNotNull(sSessions); assertFalse(sSessions.isEmpty()); @@ -750,12 +736,12 @@ public void testKillTableGetKillsOfServer() throws SQLException, DBInitException KillsTable killsTable = db.getKillsTable(); List expected = createKills(); - killsTable.savePlayerKills(uuid, 1, expected); + killsTable.savePlayerKills(playerUUID, 1, expected); commitTest(); Map> playerKills = killsTable.getPlayerKills(); - List kills = playerKills.get(uuid); + List kills = playerKills.get(playerUUID); assertFalse(playerKills.isEmpty()); assertNotNull(kills); assertFalse(kills.isEmpty()); @@ -780,14 +766,14 @@ public void testBackupAndRestore() throws SQLException, DBInitException { TPSTable tpsTable = backup.getTpsTable(); SecurityTable securityTable = backup.getSecurityTable(); - assertTrue(usersTable.isRegistered(uuid)); - assertTrue(usersTable.isRegistered(uuid2)); - assertTrue(userInfoTable.isRegistered(uuid)); + assertTrue(usersTable.isRegistered(playerUUID)); + assertTrue(usersTable.isRegistered(TestConstants.PLAYER_TWO_UUID)); + assertTrue(userInfoTable.isRegistered(playerUUID)); - assertFalse(nicknamesTable.getNicknames(uuid).isEmpty()); - assertFalse(ipsTable.getGeoInfo(uuid).isEmpty()); - assertFalse(sessionsTable.getSessions(uuid).isEmpty()); - assertFalse(actionsTable.getActions(uuid).isEmpty()); + assertFalse(nicknamesTable.getNicknames(playerUUID).isEmpty()); + assertFalse(ipsTable.getGeoInfo(playerUUID).isEmpty()); + assertFalse(sessionsTable.getSessions(playerUUID).isEmpty()); + assertFalse(actionsTable.getActions(playerUUID).isEmpty()); assertFalse(backup.getCommandUseTable().getCommandUse().isEmpty()); assertFalse(backup.getWorldTable().getWorlds().isEmpty()); assertFalse(tpsTable.getTPSData().isEmpty()); @@ -800,12 +786,12 @@ public void testSaveWorldTimes() throws SQLException { saveUserOne(); WorldTimes worldTimes = createWorldTimes(); WorldTimesTable worldTimesTable = db.getWorldTimesTable(); - worldTimesTable.saveWorldTimes(uuid, 1, worldTimes); + worldTimesTable.saveWorldTimes(playerUUID, 1, worldTimes); Session session = new Session(1, 12345L, 23456L, 0, 0); Map sessions = new HashMap<>(); sessions.put(1, session); - worldTimesTable.addWorldTimesToSessions(uuid, sessions); + worldTimesTable.addWorldTimesToSessions(playerUUID, sessions); assertEquals(worldTimes, session.getWorldTimes()); } @@ -823,7 +809,7 @@ public void testSaveAllWorldTimes() throws SQLException { Map> sessionMap = new HashMap<>(); List sessions = new ArrayList<>(); sessions.add(session); - sessionMap.put(uuid, sessions); + sessionMap.put(playerUUID, sessions); map.put(ServerInfo.getServerUUID(), sessionMap); worldTimesTable.saveWorldTimes(map); @@ -846,7 +832,7 @@ public void testSaveSessionsWorldTimes() throws SQLException { Map> sessionMap = new HashMap<>(); List sessions = new ArrayList<>(); sessions.add(session); - sessionMap.put(uuid, sessions); + sessionMap.put(playerUUID, sessions); UUID serverUUID = ServerInfo.getServerUUID(); map.put(serverUUID, sessionMap); @@ -854,18 +840,18 @@ public void testSaveSessionsWorldTimes() throws SQLException { Map>> allSessions = sessionsTable.getAllSessions(true); - assertEquals(worldTimes, allSessions.get(serverUUID).get(uuid).get(0).getWorldTimes()); + assertEquals(worldTimes, allSessions.get(serverUUID).get(playerUUID).get(0).getWorldTimes()); } @Test public void testRegisterProcessorRegisterException() throws SQLException { - assertFalse(db.getUsersTable().isRegistered(uuid)); - assertFalse(db.getUserInfoTable().isRegistered(uuid)); + assertFalse(db.getUsersTable().isRegistered(playerUUID)); + assertFalse(db.getUserInfoTable().isRegistered(playerUUID)); for (int i = 0; i < 200; i++) { - new RegisterProcessor(uuid, 500L, 1000L, "name", 4).process(); + new RegisterProcessor(playerUUID, 500L, 1000L, "name", 4).process(); } - assertTrue(db.getUsersTable().isRegistered(uuid)); - assertTrue(db.getUserInfoTable().isRegistered(uuid)); + assertTrue(db.getUsersTable().isRegistered(playerUUID)); + assertTrue(db.getUserInfoTable().isRegistered(playerUUID)); } @Test diff --git a/Plan/src/test/java/com/djrapitops/plan/system/settings/PermissionsTest.java b/Plan/src/test/java/com/djrapitops/plan/system/settings/PermissionsTest.java deleted file mode 100644 index 00f024a911..0000000000 --- a/Plan/src/test/java/com/djrapitops/plan/system/settings/PermissionsTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.system.settings; - -import org.junit.Test; -import utilities.TestUtils; - -import static org.junit.Assert.assertEquals; - -/** - * @author Rsl1122 - */ -public class PermissionsTest { - - @Test - public void testGetPermission() throws NoSuchFieldException, IllegalAccessException { - for (Permissions type : Permissions.values()) { - String exp = TestUtils.getStringFieldValue(type, "permission"); - - assertEquals(exp, type.getPermission()); - assertEquals(exp, type.getPerm()); - } - } -} \ No newline at end of file diff --git a/Plan/src/test/java/com/djrapitops/plan/system/settings/SettingsTest.java b/Plan/src/test/java/com/djrapitops/plan/system/settings/SettingsTest.java deleted file mode 100644 index 4edc42aa21..0000000000 --- a/Plan/src/test/java/com/djrapitops/plan/system/settings/SettingsTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.djrapitops.plan.system.settings; - -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.TestInit; - -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.*; - -/** - * @author Rsl1122 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) -public class SettingsTest { - - @Before - public void setUp() throws Exception { - TestInit.init(); - } - - @Test - public void testIsTrue() { - assertTrue("COMBINE_COMMAND_ALIASES supposed to be true by default", Settings.COMBINE_COMMAND_ALIASES.isTrue()); - } - - @Test - public void testSetValue() { - Settings gatherCommands = Settings.LOG_UNKNOWN_COMMANDS; - - gatherCommands.setTemporaryValue(false); - assertFalse(gatherCommands.isTrue()); - - gatherCommands.setTemporaryValue(true); - assertTrue(gatherCommands.isTrue()); - } - - @Test - public void testToString() { - assertEquals("SQLite", Settings.DB_TYPE.toString()); - } - - @Test - public void testGetNumber() { - assertEquals(8804, Settings.WEBSERVER_PORT.getNumber()); - } - - @Test - public void testGetStringList() { - List exp = Collections.singletonList("ExampleTown"); - List result = Settings.HIDE_TOWNS.getStringList(); - - assertEquals(exp, result); - } - - @Test - public void testGetPath() { - assertEquals("WebServer.Port", Settings.WEBSERVER_PORT.getPath()); - } -} diff --git a/Plan/src/test/java/com/djrapitops/plan/system/webserver/WebServerTest.java b/Plan/src/test/java/com/djrapitops/plan/system/webserver/WebServerTest.java index 39d27ca26c..8889b155a1 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/webserver/WebServerTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/webserver/WebServerTest.java @@ -1,30 +1,36 @@ package com.djrapitops.plan.system.webserver; -import com.djrapitops.plan.Plan; import com.sun.net.httpserver.HttpExchange; -import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.MockUtils; -import utilities.TestInit; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.mocks.SystemMockUtil; +import utilities.mocks.objects.MockUtils; import java.io.IOException; import java.util.HashMap; -@RunWith(PowerMockRunner.class) -@PrepareForTest({JavaPlugin.class}) +@RunWith(MockitoJUnitRunner.Silent.class) public class WebServerTest { private WebServer webServer; private RequestHandler requestHandler; + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @BeforeClass + public static void setUpClass() throws Exception { + SystemMockUtil.setUp(temporaryFolder.getRoot()) + .enableConfigSystem(); + } + @Before - public void setUp() throws Exception { - TestInit testInit = TestInit.init(); - Plan plugin = testInit.getPlanMock(); + public void setUp() { webServer = new WebServer(); requestHandler = new RequestHandler(webServer); } diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/ConditionTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/ConditionTest.java deleted file mode 100644 index 8c5188e6d2..0000000000 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/ConditionTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.djrapitops.plan.utilities; - -import com.djrapitops.plugin.command.ISender; -import com.djrapitops.plugin.command.bukkit.BukkitCMDSender; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.MockUtils; -import utilities.RandomData; -import utilities.TestInit; - -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertTrue; - -/** - * @author Fuzzlemann - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) -public class ConditionTest { - - @Before - public void setUp() throws Exception { - TestInit.init(); - } - - @Test - public void testTrueCheck() { - String message = RandomData.randomString(10); - - assertTrue(Condition.isTrue(true, message)); - } - - @Test - public void testTrueAtISenderCheck() { - String message = RandomData.randomString(10); - ISender sender = new BukkitCMDSender(MockUtils.mockPlayer()); - - assertTrue(Condition.isTrue(true, message, sender)); - assertFalse(Condition.isTrue(false, message, sender)); - } - - @Test - public void testErrorCheck() { - String message = RandomData.randomString(10); - - assertTrue(Condition.errorIfFalse(true, message)); - assertFalse(Condition.errorIfFalse(false, message)); - } -} diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java index 8a59521be2..1ea1b4bb9d 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java @@ -3,15 +3,15 @@ import com.djrapitops.plugin.api.TimeAmount; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.MockUtils; +import org.mockito.junit.MockitoJUnitRunner; import utilities.RandomData; -import utilities.TestInit; +import utilities.mocks.SystemMockUtil; +import utilities.mocks.objects.MockUtils; import java.text.SimpleDateFormat; import java.util.Date; @@ -22,13 +22,16 @@ /** * @author Rsl1122 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) +@RunWith(MockitoJUnitRunner.Silent.class) public class FormatUtilsTest { - @Before - public void setUp() throws Exception { - TestInit.init(); + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @BeforeClass + public static void setUpClass() throws Exception { + SystemMockUtil.setUp(temporaryFolder.getRoot()) + .enableConfigSystem(); } @Test diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index 14f774611a..a1a44985df 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -6,44 +6,56 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.database.databases.sql.SQLiteDB; import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.bukkit.BukkitCMDSender; -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.MockUtils; +import org.mockito.junit.MockitoJUnitRunner; import utilities.RandomData; import utilities.TestConstants; -import utilities.TestInit; +import utilities.mocks.SystemMockUtil; +import utilities.mocks.objects.MockUtils; import java.util.List; import java.util.UUID; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.powermock.api.mockito.PowerMockito.when; /** * @author Rsl1122 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({JavaPlugin.class, Bukkit.class}) +@RunWith(MockitoJUnitRunner.Silent.class) public class MiscUtilsTest { private SQLDB db; + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @BeforeClass + public static void setUpClass() throws Exception { + StaticHolder.saveInstance(MiscUtils.class, Plan.class); + SystemMockUtil.setUp(temporaryFolder.getRoot()) + .enableConfigSystem() + .enableDatabaseSystem() + .enableServerInfoSystem(); + + Database.getActive().save().serverInfoForThisServer(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20)); + } + @Before public void setUp() { - StaticHolder.saveInstance(MiscUtils.class, Plan.class); + db = (SQLDB) Database.getActive(); } @Test @@ -58,9 +70,7 @@ public void testGetPlayerDisplayNameArgsPerm() { } @Test - public void testGetPlayerDisplayNameArgsNoPerm() throws Exception { - TestInit.init(); - + public void testGetPlayerDisplayNameArgsNoPerm() { String[] args = new String[]{"Rsl1122", "Test"}; ISender sender = new BukkitCMDSender(MockUtils.mockPlayer2()); @@ -116,8 +126,6 @@ public void testGetPlayerDisplayNameConsole() { @Test public void testGetMatchingNames() throws Exception { - setupDatabase(); - String exp1 = "TestName"; String exp2 = "TestName2"; @@ -138,16 +146,14 @@ public void testGetMatchingNames() throws Exception { @Test public void testGetMatchingNickNames() throws Exception { - setupDatabase(); - UUID uuid = UUID.randomUUID(); String userName = RandomData.randomString(10); db.getUsersTable().registerUser(uuid, 0L, userName); - db.getUsersTable().registerUser(MockUtils.getPlayerUUID(), 1L, "Not random"); + db.getUsersTable().registerUser(TestConstants.PLAYER_ONE_UUID, 1L, "Not random"); String nickname = "2" + RandomData.randomString(10); db.getNicknamesTable().saveUserName(uuid, nickname); - db.getNicknamesTable().saveUserName(MockUtils.getPlayerUUID(), "No nick"); + db.getNicknamesTable().saveUserName(TestConstants.PLAYER_ONE_UUID, "No nick"); String search = "2"; @@ -157,18 +163,4 @@ public void testGetMatchingNickNames() throws Exception { assertEquals(1, result.size()); assertEquals(userName, result.get(0)); } - - private void setupDatabase() throws Exception { - TestInit.init(); - - TestInit t = TestInit.init(); - Plan plan = t.getPlanMock(); - - db = new SQLiteDB("debug" + MiscUtils.getTime()); - db.init(); - - db.getServerTable().saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20)); - - when(plan.getDB()).thenReturn(db); - } } diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java index 5513a1686e..e4e0205426 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/analysis/AnalysisUtilsTest.java @@ -5,13 +5,7 @@ */ package com.djrapitops.plan.utilities.analysis; -import org.bukkit.plugin.java.JavaPlugin; -import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import utilities.TestInit; import java.util.Arrays; import java.util.Collections; @@ -22,15 +16,8 @@ /** * @author Rsl1122 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) public class AnalysisUtilsTest { - @Before - public void setUp() throws Exception { - TestInit.init(); - } - @Test public void testGetNewPlayers() { List registered = Arrays.asList(5L, 1L); diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/export/HastebinTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/export/HastebinTest.java index 3637d6fb67..6069be9c3e 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/export/HastebinTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/export/HastebinTest.java @@ -5,16 +5,16 @@ import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.utility.log.Log; import com.google.common.collect.Iterables; -import org.bukkit.plugin.java.JavaPlugin; import org.json.simple.parser.ParseException; import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.junit.MockitoJUnitRunner; import utilities.RandomData; -import utilities.TestInit; +import utilities.mocks.SystemMockUtil; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; @@ -25,17 +25,23 @@ /** * @author Fuzzlemann */ -@PowerMockIgnore("javax.net.ssl.*") -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) +@RunWith(MockitoJUnitRunner.Silent.class) public class HastebinTest { private final AtomicBoolean testLink = new AtomicBoolean(false); - @Before - public void checkAvailability() throws Exception { - TestInit.init(); + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @BeforeClass + public static void setUpClass() throws Exception { + SystemMockUtil.setUp(temporaryFolder.getRoot()) + .enableConfigSystem() + .enableDatabaseSystem(); + } + @Before + public void checkAvailability() { Thread thread = new Thread(() -> { StaticHolder.saveInstance(this.getClass(), PlanPlugin.getInstance().getClass()); try { @@ -75,14 +81,12 @@ public void testSplitting() { } @Test - public void testUpload() throws Exception { + public void testUpload() { if (!testLink.get()) { Log.info("Hastebin not available, skipping testUpload()"); return; } - TestInit.init(); - String link = Hastebin.safeUpload(RandomData.randomString(10)); assertNotNull(link); diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlUtilsTest.java index 4e886fbba8..8052eacc18 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/html/HtmlUtilsTest.java @@ -6,11 +6,7 @@ package com.djrapitops.plan.utilities.html; import com.google.common.collect.ImmutableMap; -import org.bukkit.plugin.java.JavaPlugin; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; import utilities.RandomData; import java.io.Serializable; @@ -21,8 +17,8 @@ /** * @author Rsl1122 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(JavaPlugin.class) +//@RunWith(PowerMockRunner.class) +//@PrepareForTest(JavaPlugin.class) public class HtmlUtilsTest { @Test diff --git a/Plan/src/test/java/utilities/DBTestSuite.java b/Plan/src/test/java/utilities/DBTestSuite.java deleted file mode 100644 index 90c6748854..0000000000 --- a/Plan/src/test/java/utilities/DBTestSuite.java +++ /dev/null @@ -1,51 +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 utilities; - -import com.djrapitops.plan.system.database.MySQLTest; -import com.djrapitops.plan.system.database.SQLiteTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -import java.io.File; - -/** - * @author Fuzzlemann - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({SQLiteTest.class, MySQLTest.class}) -public class DBTestSuite { - @BeforeClass - public static void setUp() { - clean(); - } - - @AfterClass - public static void tearDown() { - clean(); - } - - private static void clean() { - File testFolder = TestInit.getTestFolder(); - - if (!testFolder.exists() || !testFolder.isDirectory()) { - return; - } - - File[] files = testFolder.listFiles(); - - if (files == null) { - return; - } - - for (File f : files) { - if (!f.delete()) { - f.deleteOnExit(); - } - } - } -} diff --git a/Plan/src/test/java/utilities/TestConstants.java b/Plan/src/test/java/utilities/TestConstants.java index 5e7260a373..f112a64c75 100644 --- a/Plan/src/test/java/utilities/TestConstants.java +++ b/Plan/src/test/java/utilities/TestConstants.java @@ -13,6 +13,11 @@ */ public class TestConstants { - public static final UUID SERVER_UUID = UUID.fromString("9a27457b-f1a2-4b71-be7f-daf2170a1b66"); + public static final UUID SERVER_UUID = UUID.fromString("e4ec2edd-e0ed-3c58-a87d-8a9021899479"); + public static final UUID PLAYER_ONE_UUID = UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"); + public static final UUID PLAYER_TWO_UUID = UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80"); + + public static final int BUKKIT_MAX_PLAYERS = 20; + public static final int BUNGEE_MAX_PLAYERS = 100; } \ No newline at end of file diff --git a/Plan/src/test/java/utilities/TestErrorManager.java b/Plan/src/test/java/utilities/TestErrorManager.java new file mode 100644 index 0000000000..e27914b14f --- /dev/null +++ b/Plan/src/test/java/utilities/TestErrorManager.java @@ -0,0 +1,20 @@ +/* + * 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 utilities; + +import com.djrapitops.plugin.api.utility.log.errormanager.ErrorManager; + +/** + * ErrorManager for tests that should throw the exceptions that occur. + * + * @author Rsl1122 + */ +public class TestErrorManager extends ErrorManager { + + @Override + public void toLog(String s, Throwable throwable, Class aClass) { + throw new IllegalStateException(throwable); + } +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/TestInit.java b/Plan/src/test/java/utilities/TestInit.java deleted file mode 100644 index add0e98d8a..0000000000 --- a/Plan/src/test/java/utilities/TestInit.java +++ /dev/null @@ -1,285 +0,0 @@ -package utilities; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.info.server.BukkitServerInfo; -import com.djrapitops.plan.system.info.server.ServerProperties; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.settings.locale.Locale; -import com.djrapitops.plan.utilities.file.FileUtil; -import com.djrapitops.plugin.IPlugin; -import com.djrapitops.plugin.StaticHolder; -import com.djrapitops.plugin.api.config.Config; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.settings.ColorScheme; -import com.djrapitops.plugin.task.RunnableFactory; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.Conversation; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; -import org.bukkit.plugin.Plugin; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Set; -import java.util.logging.Logger; - -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Rsl1122 - */ -public class TestInit { - - private Plan planMock; - - /** - * Init locale with empty messages. - *

    - * Does not load any messages from anywhere because that would cause exceptions. - */ - public static void initEmptyLocale() { - new Locale(); - } - - /** - * Init locale with mocked Plan. - *

    - * requires getDataFolder mock. - * - * @param plan Mocked Plan - */ - public static void initLocale(Plan plan) { - new Locale().loadLocale(); - } - - public static TestInit init() throws Exception { - TestInit t = new TestInit(); - t.setUp(); - return t; - } - - static File getTestFolder() { - File testFolder = new File("temporaryTestFolder"); - testFolder.mkdir(); - return testFolder; - } - - private void setUp() throws Exception { - planMock = PowerMockito.mock(Plan.class); - - StaticHolder.register(Plan.class, planMock); - StaticHolder.register(planMock); - - // Hacks to make APF find classes - StaticHolder.register(IPlugin.class, planMock); - StaticHolder.saveInstance(this.getClass(), Plan.class); - StaticHolder.saveInstance(PowerMockRunner.class, Plan.class); - - Log.setDebugMode("console"); - - File testFolder = getTestFolder(); - when(planMock.getDataFolder()).thenReturn(testFolder); - - // Files - File config = new File(getClass().getResource("/config.yml").getPath()); - when(planMock.getResource("config.yml")).thenReturn(new FileInputStream(config)); - File analysis = new File(getClass().getResource("/web/server.html").getPath()); - when(planMock.getResource("/web/server.html")).thenReturn(new FileInputStream(analysis)); - File player = new File(getClass().getResource("/web/player.html").getPath()); - when(planMock.getResource("/web/player.html")).thenReturn(new FileInputStream(player)); - - File tempConfigFile = new File(planMock.getDataFolder(), "config.yml"); - Config iConfig = new Config(tempConfigFile, FileUtil.lines(planMock, "config.yml")) { - @Override - public void save() { - } - }; - Server mockServer = mockServer(); - - when(planMock.getServer()).thenReturn(mockServer); - - // Test log settings - when(planMock.getLogger()).thenReturn(Logger.getGlobal()); - Settings.DEBUG.setTemporaryValue(true); - - ServerProperties serverProperties = new ServerProperties(mockServer); - -// when(planMock.getVariable()).thenReturn(serverProperties); - BukkitServerInfo bukkitServerInfo = PowerMockito.mock(BukkitServerInfo.class); - -// DataCache dataCache = new DataCache(planMock) { -// @Override -// public String getName(UUID uuid) { -// return ""; -// } -// }; -// when(planMock.getDataCache()).thenReturn(dataCache); - - ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK); - when(planMock.getColorScheme()).thenReturn(cs); - initLocale(null); - - RunnableFactory.activateTestMode(); - } - - private Server mockServer() { - Server mockServer = PowerMockito.mock(Server.class); - - OfflinePlayer[] ops = new OfflinePlayer[]{MockUtils.mockPlayer(), MockUtils.mockPlayer2()}; - - when(mockServer.getIp()).thenReturn("0.0.0.0"); - when(mockServer.getMaxPlayers()).thenReturn(20); - when(mockServer.getName()).thenReturn("Bukkit"); - when(mockServer.getOfflinePlayers()).thenReturn(ops); - ConsoleCommandSender sender = mockServerCmdSender(); - when(mockServer.getConsoleSender()).thenReturn(sender); - return mockServer; - } - - private ConsoleCommandSender mockServerCmdSender() { - return new ConsoleCommandSender() { - @Override - public void sendMessage(String s) { - System.out.println("Log: " + s); - } - - @Override - public void sendMessage(String[] strings) { - for (String string : strings) { - sendMessage(string); - } - } - - @Override - public Server getServer() { - return null; - } - - @Override - public String getName() { - return null; - } - - @Override - public Spigot spigot() { - return null; - } - - @Override - public boolean isConversing() { - return false; - } - - @Override - public void acceptConversationInput(String s) { - - } - - @Override - public boolean beginConversation(Conversation conversation) { - return false; - } - - @Override - public void abandonConversation(Conversation conversation) { - - } - - @Override - public void abandonConversation(Conversation conversation, ConversationAbandonedEvent conversationAbandonedEvent) { - - } - - @Override - public void sendRawMessage(String s) { - - } - - @Override - public boolean isPermissionSet(String s) { - return false; - } - - @Override - public boolean isPermissionSet(Permission permission) { - return false; - } - - @Override - public boolean hasPermission(String s) { - return false; - } - - @Override - public boolean hasPermission(Permission permission) { - return false; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, int i) { - return null; - } - - @Override - public void removeAttachment(PermissionAttachment permissionAttachment) { - - } - - @Override - public void recalculatePermissions() { - - } - - @Override - public Set getEffectivePermissions() { - return null; - } - - @Override - public boolean isOp() { - return false; - } - - @Override - public void setOp(boolean b) { - - } - }; - } - - private YamlConfiguration mockConfig() throws IOException, InvalidConfigurationException { - File configFile = new File(getClass().getResource("/config.yml").getPath()); - YamlConfiguration configuration = new YamlConfiguration(); - configuration.load(configFile.getAbsolutePath()); - return configuration; - } - - public Plan getPlanMock() { - return planMock; - } -} diff --git a/Plan/src/test/java/utilities/TestUtils.java b/Plan/src/test/java/utilities/TestUtils.java deleted file mode 100644 index a4e032861e..0000000000 --- a/Plan/src/test/java/utilities/TestUtils.java +++ /dev/null @@ -1,18 +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 utilities; - -import java.lang.reflect.Field; - -/** - * @author Fuzzlemann - */ -public class TestUtils { - public static String getStringFieldValue(Enum enumeration, String modifier) throws NoSuchFieldException, IllegalAccessException { - Field field = enumeration.getClass().getDeclaredField(modifier); - field.setAccessible(true); - return (String) field.get(enumeration); - } -} diff --git a/Plan/src/test/java/utilities/BukkitMockUtil.java b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java similarity index 59% rename from Plan/src/test/java/utilities/BukkitMockUtil.java rename to Plan/src/test/java/utilities/mocks/BukkitMockUtil.java index 22d0176f1e..02de351352 100644 --- a/Plan/src/test/java/utilities/BukkitMockUtil.java +++ b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java @@ -2,13 +2,18 @@ * 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 utilities; +package utilities.mocks; import com.djrapitops.plan.Plan; import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.task.RunnableFactory; +import org.bukkit.Server; import org.bukkit.plugin.InvalidDescriptionException; import org.bukkit.plugin.PluginDescriptionFile; import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.TestConstants; +import utilities.mocks.objects.FakeConsoleCmdSender; import java.io.File; import java.io.FileInputStream; @@ -23,21 +28,28 @@ * * @author Rsl1122 */ -public class BukkitMockUtil { +public class BukkitMockUtil extends MockUtil { private Plan planMock; private BukkitMockUtil() { } - public static BukkitMockUtil init() { + public static BukkitMockUtil setUp() { + RunnableFactory.activateTestMode(); return new BukkitMockUtil().mockPlugin(); } - public BukkitMockUtil mockPlugin() { + private BukkitMockUtil mockPlugin() { planMock = Mockito.mock(Plan.class); + super.planMock = planMock; StaticHolder.register(Plan.class, planMock); StaticHolder.register(planMock); + + StaticHolder.saveInstance(MockitoJUnitRunner.class, Plan.class); + + doCallRealMethod().when(planMock).getVersion(); + doCallRealMethod().when(planMock).getColorScheme(); return this; } @@ -52,9 +64,6 @@ public BukkitMockUtil withLogging() { return this; } - private File getFile(String fileName) { - return new File(getClass().getResource(fileName).getPath()); - } public BukkitMockUtil withPluginDescription() { try { @@ -68,22 +77,23 @@ public BukkitMockUtil withPluginDescription() { } public BukkitMockUtil withResourceFetchingFromJar() throws Exception { - withPluginFile("config.yml"); - withPluginFile("web/server.html"); - withPluginFile("web/player.html"); + withPluginFiles(); return this; } - private void withPluginFile(String fileName) throws Exception { - if (planMock.getDataFolder() == null) { - throw new IllegalStateException("withDataFolder needs to be called before setting files"); - } - try { - File file = getFile("/" + fileName); - when(planMock.getResource(fileName)).thenReturn(new FileInputStream(file)); - } catch (NullPointerException e) { - System.out.println("File is missing! " + fileName); - } + public BukkitMockUtil withServer() { + Server serverMock = Mockito.mock(Server.class); + when(serverMock.getIp()).thenReturn(""); + when(serverMock.getName()).thenReturn("Bukkit"); + when(serverMock.getPort()).thenReturn(25565); + when(serverMock.getVersion()).thenReturn("1.12.2"); + when(serverMock.getBukkitVersion()).thenReturn("32423"); + when(serverMock.getMaxPlayers()).thenReturn(TestConstants.BUKKIT_MAX_PLAYERS); + FakeConsoleCmdSender sender = new FakeConsoleCmdSender(); + when(serverMock.getConsoleSender()).thenReturn(sender); + + when(planMock.getServer()).thenReturn(serverMock); + return this; } public Plan getPlanMock() { diff --git a/Plan/src/test/java/utilities/mocks/BungeeMockUtil.java b/Plan/src/test/java/utilities/mocks/BungeeMockUtil.java new file mode 100644 index 0000000000..cf3d64b873 --- /dev/null +++ b/Plan/src/test/java/utilities/mocks/BungeeMockUtil.java @@ -0,0 +1,102 @@ +/* + * 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 utilities.mocks; + +import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.task.RunnableFactory; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyConfig; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.plugin.PluginDescription; +import net.md_5.bungee.api.plugin.PluginManager; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.TestConstants; +import utilities.mocks.objects.FakeBungeeConsole; + +import java.io.File; +import java.util.HashSet; +import java.util.logging.Logger; + +import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.Mockito.when; + +/** + * Mocking Utility for Bungee version of Plan (PlanBungee). + * + * @author Rsl1122 + */ +public class BungeeMockUtil extends MockUtil { + + private PlanBungee planMock; + + private BungeeMockUtil() { + } + + public static BungeeMockUtil setUp() { + RunnableFactory.activateTestMode(); + return new BungeeMockUtil().mockPlugin(); + } + + private BungeeMockUtil mockPlugin() { + planMock = Mockito.mock(PlanBungee.class); + super.planMock = planMock; + StaticHolder.register(PlanBungee.class, planMock); + StaticHolder.register(planMock); + + StaticHolder.saveInstance(MockitoJUnitRunner.class, PlanBungee.class); + + doCallRealMethod().when(planMock).getVersion(); + doCallRealMethod().when(planMock).getColorScheme(); + return this; + } + + public BungeeMockUtil withDataFolder(File tempFolder) { + when(planMock.getDataFolder()).thenReturn(tempFolder); + return this; + } + + public BungeeMockUtil withResourceFetchingFromJar() throws Exception { + withPluginFiles(); + return this; + } + + public BungeeMockUtil withLogging() { + doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString()); + when(planMock.getLogger()).thenReturn(Logger.getGlobal()); + return this; + } + + public BungeeMockUtil withProxy() { + ProxyServer proxyMock = Mockito.mock(ProxyServer.class); + when(proxyMock.getVersion()).thenReturn("1.12.2"); + + CommandSender console = new FakeBungeeConsole(); + when(proxyMock.getConsole()).thenReturn(console); + + ProxyConfig proxyConfig = Mockito.mock(ProxyConfig.class); + when(proxyConfig.getPlayerLimit()).thenReturn(TestConstants.BUNGEE_MAX_PLAYERS); + when(proxyMock.getConfig()).thenReturn(proxyConfig); + + PluginManager pm = Mockito.mock(PluginManager.class); + when(proxyMock.getPluginManager()).thenReturn(pm); + + when(planMock.getProxy()).thenReturn(proxyMock); + return this; + } + + public BungeeMockUtil withPluginDescription() { + File pluginYml = getFile("/bungee.yml"); + HashSet empty = new HashSet<>(); + PluginDescription pluginDescription = new PluginDescription("Plan", "", "9.9.9", "Rsl1122", empty, empty, pluginYml, ""); + when(planMock.getDescription()).thenReturn(pluginDescription); + return this; + } + + public PlanBungee getPlanMock() { + return planMock; + } +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/mocks/MockUtil.java b/Plan/src/test/java/utilities/mocks/MockUtil.java new file mode 100644 index 0000000000..a7505de3e8 --- /dev/null +++ b/Plan/src/test/java/utilities/mocks/MockUtil.java @@ -0,0 +1,50 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package utilities.mocks; + +import com.djrapitops.plan.PlanPlugin; + +import java.io.File; +import java.io.FileInputStream; + +import static org.mockito.Mockito.when; + +/** + * Abstract MockUtil for methods that can be used for both Bungee and Bukkit. + * + * @author Rsl1122 + */ +public abstract class MockUtil { + + protected PlanPlugin planMock; + + protected File getFile(String fileName) { + return new File(getClass().getResource(fileName).getPath()); + } + + protected void withPluginFile(String fileName) throws Exception { + if (planMock.getDataFolder() == null) { + throw new IllegalStateException("withDataFolder needs to be called before setting files"); + } + try { + File file = getFile("/" + fileName); + when(planMock.getResource(fileName)).thenReturn(new FileInputStream(file)); + } catch (NullPointerException e) { + System.out.println("File is missing! " + fileName); + } + } + + protected void withPluginFiles() throws Exception { + withPluginFile("bungeeconfig.yml"); + withPluginFile("config.yml"); + withPluginFile("web/server.html"); + withPluginFile("web/player.html"); + withPluginFile("web/network.html"); + withPluginFile("web/error.html"); + withPluginFile("themes/theme.yml"); + withPluginFile("DefaultServerInfoFile.yml"); + } + +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/mocks/SystemMockUtil.java b/Plan/src/test/java/utilities/mocks/SystemMockUtil.java new file mode 100644 index 0000000000..af9ef4bced --- /dev/null +++ b/Plan/src/test/java/utilities/mocks/SystemMockUtil.java @@ -0,0 +1,72 @@ +/* + * 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 utilities.mocks; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.BukkitSystem; +import com.djrapitops.plan.system.database.DBSystem; +import com.djrapitops.plan.system.database.databases.sql.SQLDB; + +import java.io.File; + +/** + * Utility for mocking only certain parts of systems. + * + * @author Rsl1122 + */ +public class SystemMockUtil { + + private BukkitSystem bukkitSystem; + + public static SystemMockUtil setUp(File dataFolder) throws Exception { + return new SystemMockUtil().initializeBukkitSystem(dataFolder); + } + + public SystemMockUtil enableConfigSystem() throws Exception { + bukkitSystem.getFileSystem().enable(); + bukkitSystem.getConfigSystem().enable(); + return this; + } + + public SystemMockUtil enableCacheSystem() throws Exception { + bukkitSystem.getCacheSystem().enable(); + return this; + } + + private SystemMockUtil initializeBukkitSystem(File dataFolder) throws Exception { + Plan planMock = BukkitMockUtil.setUp() + .withDataFolder(dataFolder) + .withLogging() + .withResourceFetchingFromJar() + .withPluginDescription() + .withServer() + .getPlanMock(); + bukkitSystem = new BukkitSystem(planMock); + return this; + } + + public SystemMockUtil enableProcessingQueue() { + bukkitSystem.getProcessingQueue().enable(); + return this; + } + + public SystemMockUtil enableDatabaseSystem() throws EnableException { + bukkitSystem.getDatabaseSystem().enable(); + return this; + } + + public SystemMockUtil enableServerInfoSystem() throws EnableException { + bukkitSystem.getServerInfo().enable(); + return this; + } + + public SystemMockUtil enableDatabaseSystem(SQLDB db) throws EnableException { + DBSystem dbSystem = bukkitSystem.getDatabaseSystem(); + dbSystem.setActiveDatabase(db); + dbSystem.enable(); + return this; + } +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/mocks/objects/FakeBungeeConsole.java b/Plan/src/test/java/utilities/mocks/objects/FakeBungeeConsole.java new file mode 100644 index 0000000000..82d84cc09f --- /dev/null +++ b/Plan/src/test/java/utilities/mocks/objects/FakeBungeeConsole.java @@ -0,0 +1,79 @@ +/* + * 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 utilities.mocks.objects; + +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.BaseComponent; + +import java.util.Collection; + +/** + * Fake console to return as mock for Bungee. + *

    + * Logs with System.out.print. + * + * @author Rsl1122 + */ +public class FakeBungeeConsole implements CommandSender { + + @Override + public String getName() { + return null; + } + + @Override + public void sendMessage(String s) { + System.out.println(s); + } + + @Override + public void sendMessages(String... strings) { + for (String string : strings) { + sendMessage(string); + } + } + + @Override + public void sendMessage(BaseComponent... baseComponents) { + for (BaseComponent baseComponent : baseComponents) { + sendMessage(baseComponent); + } + } + + @Override + public void sendMessage(BaseComponent baseComponent) { + sendMessage(baseComponent.toPlainText()); + } + + @Override + public Collection getGroups() { + return null; + } + + @Override + public void addGroups(String... strings) { + + } + + @Override + public void removeGroups(String... strings) { + + } + + @Override + public boolean hasPermission(String s) { + return true; + } + + @Override + public void setPermission(String s, boolean b) { + + } + + @Override + public Collection getPermissions() { + return null; + } +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/mocks/objects/FakeConsoleCmdSender.java b/Plan/src/test/java/utilities/mocks/objects/FakeConsoleCmdSender.java new file mode 100644 index 0000000000..6c69f21633 --- /dev/null +++ b/Plan/src/test/java/utilities/mocks/objects/FakeConsoleCmdSender.java @@ -0,0 +1,147 @@ +/* + * 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 utilities.mocks.objects; + +import org.bukkit.Server; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.conversations.Conversation; +import org.bukkit.conversations.ConversationAbandonedEvent; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.plugin.Plugin; + +import java.util.Set; + +/** + * Fake ConsoleCommandSender + * + * @author Rsl1122 + */ +public class FakeConsoleCmdSender implements ConsoleCommandSender { + + @Override + public void sendMessage(String s) { + System.out.println("Log: " + s); + } + + @Override + public void sendMessage(String[] strings) { + for (String string : strings) { + sendMessage(string); + } + } + + @Override + public Server getServer() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public Spigot spigot() { + return null; + } + + @Override + public boolean isConversing() { + return false; + } + + @Override + public void acceptConversationInput(String s) { + + } + + @Override + public boolean beginConversation(Conversation conversation) { + return false; + } + + @Override + public void abandonConversation(Conversation conversation) { + + } + + @Override + public void abandonConversation(Conversation conversation, ConversationAbandonedEvent conversationAbandonedEvent) { + + } + + @Override + public void sendRawMessage(String s) { + + } + + @Override + public boolean isPermissionSet(String s) { + return false; + } + + @Override + public boolean isPermissionSet(Permission permission) { + return false; + } + + @Override + public boolean hasPermission(String s) { + return false; + } + + @Override + public boolean hasPermission(Permission permission) { + return false; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin) { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, int i) { + return null; + } + + @Override + public void removeAttachment(PermissionAttachment permissionAttachment) { + + } + + @Override + public void recalculatePermissions() { + + } + + @Override + public Set getEffectivePermissions() { + return null; + } + + @Override + public boolean isOp() { + return false; + } + + @Override + public void setOp(boolean b) { + + } + +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/MockUtils.java b/Plan/src/test/java/utilities/mocks/objects/MockUtils.java similarity index 87% rename from Plan/src/test/java/utilities/MockUtils.java rename to Plan/src/test/java/utilities/mocks/objects/MockUtils.java index 2a3265c499..43bb31d2d7 100644 --- a/Plan/src/test/java/utilities/MockUtils.java +++ b/Plan/src/test/java/utilities/mocks/objects/MockUtils.java @@ -1,4 +1,4 @@ -package utilities; +package utilities.mocks.objects; import com.sun.net.httpserver.*; import org.bukkit.GameMode; @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; import java.io.*; import java.net.InetSocketAddress; @@ -17,11 +16,13 @@ import java.util.*; import java.util.zip.GZIPInputStream; -import static org.powermock.api.mockito.PowerMockito.when; +import static org.mockito.Mockito.when; /** * @author Rsl1122 + * @deprecated To Be Refactored into multiple classes. */ +@Deprecated public class MockUtils { public static World mockWorld() { @@ -31,7 +32,7 @@ public static World mockWorld() { } public static Player mockPlayer() { - Player p = PowerMockito.mock(Player.class); + Player p = Mockito.mock(Player.class); when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); when(p.getFirstPlayed()).thenReturn(1234567L); @@ -45,12 +46,8 @@ public static Player mockPlayer() { return p; } - public static UUID getPlayerUUID() { - return UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"); - } - public static Player mockPlayer2() { - Player p = PowerMockito.mock(Player.class); + Player p = Mockito.mock(Player.class); when(p.getGameMode()).thenReturn(GameMode.SPECTATOR); when(p.getUniqueId()).thenReturn(UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80")); when(p.getFirstPlayed()).thenReturn(3423434L); @@ -64,19 +61,8 @@ public static Player mockPlayer2() { return p; } - public static UUID getPlayer2UUID() { - return UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80"); - } - - public static Set getUUIDs() { - Set uuids = new HashSet<>(); - uuids.add(getPlayerUUID()); - uuids.add(getPlayer2UUID()); - return uuids; - } - public static Player mockBrokenPlayer() { - Player p = PowerMockito.mock(Player.class); + Player p = Mockito.mock(Player.class); when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); when(p.getFirstPlayed()).thenReturn(1234567L); @@ -90,11 +76,11 @@ public static Player mockBrokenPlayer() { } public static CommandSender mockConsoleSender() { - return PowerMockito.mock(CommandSender.class); + return Mockito.mock(CommandSender.class); } public static HttpServer mockHTTPServer() { - HttpServer httpServer = PowerMockito.mock(HttpServer.class); + HttpServer httpServer = Mockito.mock(HttpServer.class); when(httpServer.getAddress()).thenReturn(new InetSocketAddress(80)); when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received")); return httpServer; diff --git a/Plan/test/main/java/test/utilities/DBTestSuite.java b/Plan/test/main/java/test/utilities/DBTestSuite.java deleted file mode 100644 index 231efdd86c..0000000000 --- a/Plan/test/main/java/test/utilities/DBTestSuite.java +++ /dev/null @@ -1,51 +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 test.utilities; - -import com.djrapitops.plan.system.database.MySQLTest; -import com.djrapitops.plan.system.database.SQLiteTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -import java.io.File; - -/** - * @author Fuzzlemann - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({SQLiteTest.class, MySQLTest.class}) -public class DBTestSuite { - @BeforeClass - public static void setUp() { - clean(); - } - - @AfterClass - public static void tearDown() { - clean(); - } - - private static void clean() { - File testFolder = TestInit.getTestFolder(); - - if (!testFolder.exists() || !testFolder.isDirectory()) { - return; - } - - File[] files = testFolder.listFiles(); - - if (files == null) { - return; - } - - for (File f : files) { - if (!f.delete()) { - f.deleteOnExit(); - } - } - } -} diff --git a/Plan/test/main/java/test/utilities/MockUtils.java b/Plan/test/main/java/test/utilities/MockUtils.java deleted file mode 100644 index 7e11296def..0000000000 --- a/Plan/test/main/java/test/utilities/MockUtils.java +++ /dev/null @@ -1,216 +0,0 @@ -package test.utilities; - -import com.sun.net.httpserver.*; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; - -import java.io.*; -import java.net.InetSocketAddress; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.Charset; -import java.util.*; -import java.util.zip.GZIPInputStream; - -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Rsl1122 - */ -public class MockUtils { - - public static World mockWorld() { - World mockWorld = Mockito.mock(World.class); - when(mockWorld.toString()).thenReturn("World"); - return mockWorld; - } - - public static Player mockPlayer() { - Player p = PowerMockito.mock(Player.class); - when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); - when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); - when(p.getFirstPlayed()).thenReturn(1234567L); - World mockWorld = mockWorld(); - when(p.getLocation()).thenReturn(new Location(mockWorld, 0, 0, 0)); - when(p.isOp()).thenReturn(true); - when(p.isBanned()).thenReturn(true); - when(p.isOnline()).thenReturn(true); - when(p.getName()).thenReturn("TestName"); - when(p.hasPermission("plan.inspect.other")).thenReturn(true); - return p; - } - - public static UUID getPlayerUUID() { - return UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"); - } - - public static Player mockPlayer2() { - Player p = PowerMockito.mock(Player.class); - when(p.getGameMode()).thenReturn(GameMode.SPECTATOR); - when(p.getUniqueId()).thenReturn(UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80")); - when(p.getFirstPlayed()).thenReturn(3423434L); - World mockWorld = mockWorld(); - when(p.getLocation()).thenReturn(new Location(mockWorld, 1, 0, 1)); - when(p.isOp()).thenReturn(false); - when(p.isBanned()).thenReturn(false); - when(p.isOnline()).thenReturn(false); - when(p.hasPermission("plan.inspect.other")).thenReturn(false); - when(p.getName()).thenReturn("TestName2"); - return p; - } - - public static UUID getPlayer2UUID() { - return UUID.fromString("ec94a954-1fa1-445b-b09b-9b698519af80"); - } - - public static Set getUUIDs() { - Set uuids = new HashSet<>(); - uuids.add(getPlayerUUID()); - uuids.add(getPlayer2UUID()); - return uuids; - } - - public static Player mockBrokenPlayer() { - Player p = PowerMockito.mock(Player.class); - when(p.getGameMode()).thenReturn(GameMode.SURVIVAL); - when(p.getUniqueId()).thenReturn(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db")); - when(p.getFirstPlayed()).thenReturn(1234567L); - World mockWorld = mockWorld(); - when(p.getLocation()).thenReturn(new Location(mockWorld, 0, 0, 0)); - when(p.isOp()).thenReturn(true); - when(p.isBanned()).thenThrow(Exception.class); - when(p.isOnline()).thenReturn(true); - when(p.getName()).thenReturn("TestName"); - return p; - } - - public static CommandSender mockConsoleSender() { - return PowerMockito.mock(CommandSender.class); - } - - public static HttpServer mockHTTPServer() { - HttpServer httpServer = PowerMockito.mock(HttpServer.class); - when(httpServer.getAddress()).thenReturn(new InetSocketAddress(80)); - when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received")); - return httpServer; - } - - public static HttpExchange getHttpExchange(String requestMethod, String requestURI, String body, Map> responseHeaders) { - return new HttpExchange() { - private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - @Override - public Headers getRequestHeaders() { - Headers headers = new Headers(); - headers.put("Authorization", new ArrayList<>()); - return headers; - } - - @Override - public Headers getResponseHeaders() { - Headers headers = new Headers(); - headers.putAll(responseHeaders); - return headers; - } - - @Override - public URI getRequestURI() { - try { - return new URI(requestURI); - } catch (URISyntaxException e) { - return null; - } - } - - @Override - public String getRequestMethod() { - return requestMethod; - } - - @Override - public HttpContext getHttpContext() { - return null; - } - - @Override - public void close() { - - } - - @Override - public InputStream getRequestBody() { - return new ByteArrayInputStream(body.getBytes(Charset.forName("UTF-8"))); - } - - @Override - public OutputStream getResponseBody() { - return outputStream; - } - - @Override - public InetSocketAddress getRemoteAddress() { - return null; - } - - @Override - public InetSocketAddress getLocalAddress() { - return null; - } - - @Override - public String getProtocol() { - return null; - } - - @Override - public Object getAttribute(String name) { - return null; - } - - @Override - public void sendResponseHeaders(int i, long l) { - - } - - @Override - public int getResponseCode() { - return 0; - } - - @Override - public void setAttribute(String s, Object o) { - - } - - @Override - public void setStreams(InputStream inputStream, OutputStream outputStream) { - - } - - @Override - public HttpPrincipal getPrincipal() { - return null; - } - }; - } - - public static String getResponseStream(HttpExchange requestExchange) throws IOException { - InputStream in = new GZIPInputStream( - new ByteArrayInputStream(( - (ByteArrayOutputStream) requestExchange.getResponseBody() - ).toByteArray()) - ); - try (Scanner scanner = new Scanner(in)) { - StringBuilder s = new StringBuilder(); - while (scanner.hasNextLine()) { - s.append(scanner.nextLine()).append("\n"); - } - return s.toString(); - } - } -} diff --git a/Plan/test/main/java/test/utilities/RandomData.java b/Plan/test/main/java/test/utilities/RandomData.java deleted file mode 100644 index 812ec3070c..0000000000 --- a/Plan/test/main/java/test/utilities/RandomData.java +++ /dev/null @@ -1,77 +0,0 @@ -package test.utilities; - -import com.djrapitops.plan.data.WebUser; -import com.djrapitops.plan.data.container.Session; -import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.data.container.UserInfo; -import com.djrapitops.plan.utilities.PassEncryptUtil; -import com.djrapitops.plan.utilities.analysis.Point; -import org.apache.commons.lang3.RandomStringUtils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; - -public class RandomData { - - private static final Random r = new Random(); - - public static int randomInt(int rangeStart, int rangeEnd) { - return ThreadLocalRandom.current().nextInt(rangeStart, rangeEnd); - } - - public static String randomString(int size) { - return RandomStringUtils.randomAlphanumeric(size); - } - - public static List randomWebUsers() throws PassEncryptUtil.CannotPerformOperationException { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - test.add(new WebUser(randomString(5), PassEncryptUtil.createHash(randomString(7)), r.nextInt())); - } - return test; - } - - public static List randomTPS() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - int randInt = r.nextInt(); - long randLong = r.nextLong(); - test.add(new TPS(randLong, randLong, randInt, randLong, randLong, randInt, randInt)); - } - return test; - } - - public static List randomSessions() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - test.add(new Session(1, r.nextLong(), r.nextLong(), 0, 0)); - } - return test; - } - - public static List randomPoints() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - test.add(new Point(r.nextLong(), r.nextLong())); - } - return test; - } - - public static T randomEnum(Class clazz) { - int x = r.nextInt(clazz.getEnumConstants().length); - return clazz.getEnumConstants()[x]; - } - - public static List randomUserData() { - List test = new ArrayList<>(); - for (int i = 0; i < 20; i++) { - UserInfo info = new UserInfo(UUID.randomUUID(), randomString(10), r.nextLong(), r.nextBoolean(), r.nextBoolean()); - info.setLastSeen(r.nextLong()); - test.add(info); - } - return test; - } -} diff --git a/Plan/test/main/java/test/utilities/TestInit.java b/Plan/test/main/java/test/utilities/TestInit.java deleted file mode 100644 index ac6a253f16..0000000000 --- a/Plan/test/main/java/test/utilities/TestInit.java +++ /dev/null @@ -1,291 +0,0 @@ -package test.utilities; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.system.info.server.BukkitServerInfo; -import com.djrapitops.plan.system.info.server.ServerProperties; -import com.djrapitops.plan.system.settings.Settings; -import com.djrapitops.plan.system.settings.locale.Locale; -import com.djrapitops.plan.utilities.file.FileUtil; -import com.djrapitops.plugin.IPlugin; -import com.djrapitops.plugin.StaticHolder; -import com.djrapitops.plugin.api.config.Config; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.settings.ColorScheme; -import com.djrapitops.plugin.task.RunnableFactory; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.conversations.Conversation; -import org.bukkit.conversations.ConversationAbandonedEvent; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; -import org.bukkit.plugin.Plugin; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Set; -import java.util.UUID; -import java.util.logging.Logger; - -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Rsl1122 - */ -public class TestInit { - - private static final UUID serverUUID = UUID.fromString("9a27457b-f1a2-4b71-be7f-daf2170a1b66"); - private Plan planMock; - - /** - * Init locale with empty messages. - *

    - * Does not load any messages from anywhere because that would cause exceptions. - */ - public static void initEmptyLocale() { - new Locale(); - } - - /** - * Init locale with mocked Plan. - *

    - * requires getDataFolder mock. - * - * @param plan Mocked Plan - */ - public static void initLocale(Plan plan) { - new Locale().loadLocale(); - } - - public static TestInit init() throws Exception { - TestInit t = new TestInit(); - t.setUp(); - return t; - } - - static File getTestFolder() { - File testFolder = new File("temporaryTestFolder"); - testFolder.mkdir(); - return testFolder; - } - - public static UUID getServerUUID() { - return serverUUID; - } - - private void setUp() throws Exception { - planMock = PowerMockito.mock(Plan.class); - - StaticHolder.register(Plan.class, planMock); - StaticHolder.register(planMock); - - // Hacks to make APF find classes - StaticHolder.register(IPlugin.class, planMock); - StaticHolder.saveInstance(this.getClass(), Plan.class); - StaticHolder.saveInstance(PowerMockRunner.class, Plan.class); - - Log.setDebugMode("console"); - - File testFolder = getTestFolder(); - when(planMock.getDataFolder()).thenReturn(testFolder); - - // Files - File config = new File(getClass().getResource("/config.yml").getPath()); - when(planMock.getResource("config.yml")).thenReturn(new FileInputStream(config)); - File analysis = new File(getClass().getResource("/web/server.html").getPath()); - when(planMock.getResource("/web/server.html")).thenReturn(new FileInputStream(analysis)); - File player = new File(getClass().getResource("/web/player.html").getPath()); - when(planMock.getResource("/web/player.html")).thenReturn(new FileInputStream(player)); - - File tempConfigFile = new File(planMock.getDataFolder(), "config.yml"); - Config iConfig = new Config(tempConfigFile, FileUtil.lines(planMock, "config.yml")) { - @Override - public void save() { - } - }; - Server mockServer = mockServer(); - - when(planMock.getServer()).thenReturn(mockServer); - - // Test log settings - when(planMock.getLogger()).thenReturn(Logger.getGlobal()); - Settings.DEBUG.setTemporaryValue(true); - - ServerProperties serverProperties = new ServerProperties(mockServer); - -// when(planMock.getVariable()).thenReturn(serverProperties); - BukkitServerInfo bukkitServerInfo = PowerMockito.mock(BukkitServerInfo.class); - -// DataCache dataCache = new DataCache(planMock) { -// @Override -// public String getName(UUID uuid) { -// return ""; -// } -// }; -// when(planMock.getDataCache()).thenReturn(dataCache); - - ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK); - when(planMock.getColorScheme()).thenReturn(cs); - initLocale(null); - - RunnableFactory.activateTestMode(); - } - - private Server mockServer() { - Server mockServer = PowerMockito.mock(Server.class); - - OfflinePlayer[] ops = new OfflinePlayer[]{MockUtils.mockPlayer(), MockUtils.mockPlayer2()}; - - when(mockServer.getIp()).thenReturn("0.0.0.0"); - when(mockServer.getMaxPlayers()).thenReturn(20); - when(mockServer.getName()).thenReturn("Bukkit"); - when(mockServer.getOfflinePlayers()).thenReturn(ops); - ConsoleCommandSender sender = mockServerCmdSender(); - when(mockServer.getConsoleSender()).thenReturn(sender); - return mockServer; - } - - private ConsoleCommandSender mockServerCmdSender() { - return new ConsoleCommandSender() { - @Override - public void sendMessage(String s) { - System.out.println("Log: " + s); - } - - @Override - public void sendMessage(String[] strings) { - for (String string : strings) { - sendMessage(string); - } - } - - @Override - public Server getServer() { - return null; - } - - @Override - public String getName() { - return null; - } - - @Override - public Spigot spigot() { - return null; - } - - @Override - public boolean isConversing() { - return false; - } - - @Override - public void acceptConversationInput(String s) { - - } - - @Override - public boolean beginConversation(Conversation conversation) { - return false; - } - - @Override - public void abandonConversation(Conversation conversation) { - - } - - @Override - public void abandonConversation(Conversation conversation, ConversationAbandonedEvent conversationAbandonedEvent) { - - } - - @Override - public void sendRawMessage(String s) { - - } - - @Override - public boolean isPermissionSet(String s) { - return false; - } - - @Override - public boolean isPermissionSet(Permission permission) { - return false; - } - - @Override - public boolean hasPermission(String s) { - return false; - } - - @Override - public boolean hasPermission(Permission permission) { - return false; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) { - return null; - } - - @Override - public PermissionAttachment addAttachment(Plugin plugin, int i) { - return null; - } - - @Override - public void removeAttachment(PermissionAttachment permissionAttachment) { - - } - - @Override - public void recalculatePermissions() { - - } - - @Override - public Set getEffectivePermissions() { - return null; - } - - @Override - public boolean isOp() { - return false; - } - - @Override - public void setOp(boolean b) { - - } - }; - } - - private YamlConfiguration mockConfig() throws IOException, InvalidConfigurationException { - File configFile = new File(getClass().getResource("/config.yml").getPath()); - YamlConfiguration configuration = new YamlConfiguration(); - configuration.load(configFile.getAbsolutePath()); - return configuration; - } - - public Plan getPlanMock() { - return planMock; - } -} diff --git a/Plan/test/main/java/test/utilities/TestUtils.java b/Plan/test/main/java/test/utilities/TestUtils.java deleted file mode 100644 index 3f56869668..0000000000 --- a/Plan/test/main/java/test/utilities/TestUtils.java +++ /dev/null @@ -1,18 +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 test.utilities; - -import java.lang.reflect.Field; - -/** - * @author Fuzzlemann - */ -public class TestUtils { - public static String getStringFieldValue(Enum enumeration, String modifier) throws NoSuchFieldException, IllegalAccessException { - Field field = enumeration.getClass().getDeclaredField(modifier); - field.setAccessible(true); - return (String) field.get(enumeration); - } -} From 0d4c065b52f72f4b39b238857cc1fa65afe2b77b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 27 Jan 2018 17:37:42 +0200 Subject: [PATCH 067/166] PluginBridge now split into Bukkit & Bungee for future compatibility. --- Plan/dependency-reduced-pom.xml | 67 ++++++------------- .../djrapitops/pluginbridge/plan/Bridge.java | 43 +++++++++--- .../plan/aac/PlayerHackKickListener.java | 18 +++-- .../PlayerVersionListener.java | 17 ++--- .../viaversion/PlayerVersionListener.java | 18 ++--- 5 files changed, 77 insertions(+), 86 deletions(-) diff --git a/Plan/dependency-reduced-pom.xml b/Plan/dependency-reduced-pom.xml index 8176eeb324..3ce6703bcd 100644 --- a/Plan/dependency-reduced-pom.xml +++ b/Plan/dependency-reduced-pom.xml @@ -6,7 +6,7 @@ 4.2.0-SNAPSHOT ${basedir}/src/main/java - ${basedir}/test/main/java + ${basedir}/src/test/java clean package install @@ -254,60 +254,37 @@ - - org.powermock - powermock - 1.6.6 - pom - compile - - - org.powermock - powermock-api-mockito - 1.6.6 - compile - - - org.powermock - powermock-module-junit4 - 1.6.6 - compile - - - org.powermock - powermock-module-junit4-rule - 1.6.6 - compile - - - org.powermock - powermock-classloading-xstream - 1.6.6 - compile - org.mockito mockito-core - 1.10.19 - compile - - - org.powermock - powermock-api-easymock - 1.6.6 - compile + 2.13.0 + test + + + byte-buddy + net.bytebuddy + + + byte-buddy-agent + net.bytebuddy + + + objenesis + org.objenesis + + - org.easymock - easymock - 3.4 - compile + org.xerial + sqlite-jdbc + 3.21.0 + test junit junit 4.12 - compile + test org.hamcrest diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java index d1b3369ce3..fa3d175bd6 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java @@ -2,6 +2,7 @@ import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.pluginbridge.plan.aac.AdvancedAntiCheatHook; import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook; @@ -51,7 +52,38 @@ private Bridge() { } public static void hook(HookHandler h) { - Hook[] hooks = new Hook[]{ + Hook[] hooks = getHooks(h); + hookInto(hooks); + } + + private static void hookInto(Hook[] hooks) { + for (Hook hook : hooks) { + try { + hook.hook(); + } catch (Exception | NoClassDefFoundError e) { + if (Settings.DEV_MODE.isTrue()) { + Log.toLog("PluginBridge", e); + } + } + } + } + + private static Hook[] getHooks(HookHandler h) { + Hook[] hooks; + if (Check.isBukkitAvailable()) { + hooks = getBukkitHooks(h); + } else { + hooks = getBungeeHooks(h); + } + return hooks; + } + + private static Hook[] getBungeeHooks(HookHandler h) { + return new Hook[0]; + } + + private static Hook[] getBukkitHooks(HookHandler h) { + return new Hook[]{ new AdvancedAntiCheatHook(h), new AdvancedAchievementsHook(h), new ASkyBlockHook(h), @@ -70,14 +102,5 @@ public static void hook(HookHandler h) { new VaultHook(h), new ViaVersionHook(h) }; - for (Hook hook : hooks) { - try { - hook.hook(); - } catch (Exception | NoClassDefFoundError e) { - if (Settings.DEV_MODE.isTrue()) { - Log.toLog("PluginBridge", e); - } - } - } } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java index 6ff6f5c25c..6a13676175 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/PlayerHackKickListener.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.utility.log.Log; import me.konsolas.aac.api.AACAPIProvider; @@ -42,15 +42,13 @@ public void onKick(PlayerViolationCommandEvent event) { int violations = AACAPIProvider.getAPI().getViolationLevel(player, hackType); HackObject hackObject = new HackObject(uuid, time, hackType, violations); - new Processor(uuid) { - @Override - public void process() { - try { - new HackerTable((SQLDB) Database.getActive()).insertHackRow(hackObject); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } + + Processor.queue(() -> { + try { + new HackerTable((SQLDB) Database.getActive()).insertHackRow(hackObject); + } catch (SQLException e) { + Log.toLog(this.getClass().getName(), e); } - }.queue(); + }); } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java index e4450638ea..53bdc97a3c 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/PlayerVersionListener.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.pluginbridge.plan.viaversion.ProtocolTable; import org.bukkit.entity.Player; @@ -40,15 +40,12 @@ public void onJoin(PlayerJoinEvent event) { ProtocolVersion protocolVersion = ProtocolSupportAPI.getProtocolVersion(player); int playerVersion = protocolVersion.getId(); Plan plan = Plan.getInstance(); - new Processor(uuid) { - @Override - public void process() { - try { - new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion); - } catch (SQLException e) { - Log.toLog(this.getClass().getName(), e); - } + Processor.queue(() -> { + try { + new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion); + } catch (SQLException e) { + Log.toLog(this.getClass().getName(), e); } - }.queue(); + }); } } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java index cefea553b1..18f41ec996 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/PlayerVersionListener.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; -import com.djrapitops.plan.system.processing.processors.Processor; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plugin.api.utility.log.Log; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -36,16 +36,12 @@ public PlayerVersionListener(ViaAPI viaAPI) { public void onJoin(PlayerJoinEvent event) { UUID uuid = event.getPlayer().getUniqueId(); int playerVersion = viaAPI.getPlayerVersion(uuid); - new Processor(uuid) { - @Override - public void process() { - try { - - new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion); - } catch (SQLException e) { - Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e); - } + Processor.queue(() -> { + try { + new ProtocolTable((SQLDB) Database.getActive()).saveProtocolVersion(uuid, playerVersion); + } catch (SQLException e) { + Log.toLog(this.getClass().getName() + ":PlanViaVersionJoinListener", e); } - }.queue(); + }); } } From 1f0d74b127a59b9fccbf0d4bedd5f19390b55d17 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 27 Jan 2018 20:17:58 +0200 Subject: [PATCH 068/166] Improved local execution of InfoRequests --- .../commands/manage/ManageSetupCommand.java | 8 ++++- .../plan/system/info/BukkitInfoSystem.java | 15 +++------ .../plan/system/info/BungeeInfoSystem.java | 2 +- .../plan/system/info/InfoSystem.java | 2 +- .../system/info/connection/ConnectionOut.java | 6 ++-- .../info/connection/ConnectionSystem.java | 6 +++- .../connection/InfoRequestPageHandler.java | 5 +++ .../request/CacheAnalysisPageRequest.java | 17 +++++++--- .../info/request/CacheInspectPageRequest.java | 17 +++++++--- .../CacheInspectPluginsTabRequest.java | 33 +++++++++++++------ .../CacheNetworkPageContentRequest.java | 17 +++++++--- .../request/GenerateAnalysisPageRequest.java | 15 +++++++-- .../request/GenerateInspectPageRequest.java | 16 +++++++-- .../GenerateInspectPluginsTabRequest.java | 16 +++++---- .../plan/system/info/request/InfoRequest.java | 2 ++ .../info/request/SaveDBSettingsRequest.java | 5 +++ .../info/request/SendDBSettingsRequest.java | 5 +++ .../response/api/BadRequestResponse.java | 4 +-- .../response/cache/ResponseCache.java | 14 -------- .../parts/InspectPagePluginsContent.java | 6 ++-- .../plan/data/cache/ResponseCacheTest.java | 9 ----- .../database/{ => databases}/MySQLTest.java | 2 +- .../database/{ => databases}/SQLiteTest.java | 3 +- 23 files changed, 142 insertions(+), 83 deletions(-) rename Plan/src/test/java/com/djrapitops/plan/system/database/{ => databases}/MySQLTest.java (91%) rename Plan/src/test/java/com/djrapitops/plan/system/database/{ => databases}/SQLiteTest.java (99%) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 8f328762bb..7bbe1c148a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -1,7 +1,9 @@ package com.djrapitops.plan.command.commands.manage; import com.djrapitops.plan.Plan; +import com.djrapitops.plan.api.exceptions.connection.BadRequestException; import com.djrapitops.plan.api.exceptions.connection.ForbiddenException; +import com.djrapitops.plan.api.exceptions.connection.UnauthorizedServerException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.settings.Permissions; @@ -68,9 +70,13 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { InfoSystem.getInstance().requestSetUp(address); - sender.sendMessage("§eConnection successful, Plan may restart in a few seconds, if it doesn't something has gone wrong."); + sender.sendMessage("§aConnection successful, Plan may restart in a few seconds.."); } catch (ForbiddenException e) { sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it."); + } catch (BadRequestException e) { + sender.sendMessage("§eConnection succeeded, but Receiving server was a Bukkit server. Use Bungee address instead."); + } catch (UnauthorizedServerException e) { + sender.sendMessage("§eConnection succeeded, but Receiving server didn't authorize this server. Contact Discord for support"); } catch (WebException e) { Log.toLog(this.getClass().getName(), e); sender.sendMessage("§cConnection to Bungee WebServer failed: More info on console"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java index ca97ce4829..c588fb8c8e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java @@ -8,12 +8,10 @@ import com.djrapitops.plan.system.info.connection.BukkitConnectionSystem; import com.djrapitops.plan.system.info.request.CacheNetworkPageContentRequest; import com.djrapitops.plan.system.info.request.InfoRequest; -import com.djrapitops.plan.system.info.request.InfoRequestWithVariables; +import com.djrapitops.plan.system.info.request.SetupRequest; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.utilities.html.HtmlStructure; -import java.util.HashMap; - /** * InfoSystem for Bukkit servers. * @@ -26,16 +24,11 @@ public BukkitInfoSystem() { } @Override - protected void runLocally(InfoRequest infoRequest) throws WebException { - if (infoRequest instanceof CacheNetworkPageContentRequest) { + public void runLocally(InfoRequest infoRequest) throws WebException { + if (infoRequest instanceof SetupRequest) { return; } - infoRequest.placeDataToDatabase(); - if (infoRequest instanceof InfoRequestWithVariables) { - infoRequest.handleRequest(((InfoRequestWithVariables) infoRequest).getVariables()); - } else { - infoRequest.handleRequest(new HashMap<>()); - } + infoRequest.runLocally(); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java index 98ddd5d375..22b93e5fcd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java @@ -28,7 +28,7 @@ public BungeeInfoSystem() { } @Override - protected void runLocally(InfoRequest infoRequest) throws WebException { + public void runLocally(InfoRequest infoRequest) throws WebException { // runLocally is called when ConnectionSystem has no servers. throw new NoServersException("No servers were available to process this request."); } 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 7ac3af6013..626e140f75 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 @@ -73,7 +73,7 @@ public void sendRequest(InfoRequest infoRequest) throws WebException { } } - protected abstract void runLocally(InfoRequest infoRequest) throws WebException; + public abstract void runLocally(InfoRequest infoRequest) throws WebException; @Override public void enable() throws EnableException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index 3e74d7fbaa..616a15c84d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -53,7 +53,7 @@ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, Strin /** * Constructor. * - * @param toServer Full address to another Plan webserver. (http://something:port) + * @param toServer Full address to another Plan webserver. (http://something:port) * @param serverUUID UUID of server this outbound connection. * @param infoRequest Type of the action this connection wants to be performed. */ @@ -120,9 +120,9 @@ public void sendRequest() throws WebException { case 200: return; case 400: - throw new WebFailException("Bad Request: " + url.toString() + " | " + parameters); + throw new BadRequestException("Bad Request: " + url.toString() + " | " + parameters); case 403: - throw new ForbiddenException(url.toString() + " returned 403."); + throw new ForbiddenException(url.toString() + " returned 403 | " + parameters); case 404: throw new NotFoundException(url.toString() + " returned a 404, ensure that your server is connected to an up to date Plan server."); case 412: diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 94d1c29cf7..49c56831ae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -77,7 +77,11 @@ public void sendInfoRequest(InfoRequest infoRequest) throws WebException { } public void sendInfoRequest(InfoRequest infoRequest, Server toServer) throws WebException { - new ConnectionOut(toServer, ServerInfo.getServerUUID(), infoRequest).sendRequest(); + if (ServerInfo.getServerUUID().equals(toServer.getUuid())) { + InfoSystem.getInstance().runLocally(infoRequest); + } else { + new ConnectionOut(toServer, ServerInfo.getServerUUID(), infoRequest).sendRequest(); + } } public ConnectionLog getConnectionLog() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java index 3d1584634e..770295be98 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java @@ -11,6 +11,7 @@ import com.djrapitops.plan.system.webserver.pages.PageHandler; import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.api.BadRequestResponse; import com.djrapitops.plan.utilities.NullCheck; import java.util.List; @@ -30,6 +31,10 @@ public Response getResponse(Request request, List target) throws WebExce return DefaultResponses.NOT_FOUND.get(); } + if (!request.getRequestMethod().equals("POST")) { + return new BadRequestResponse("POST should be used for Info calls."); + } + String requestName = target.get(0); InfoRequest infoRequest = ConnectionSystem.getInstance().getInfoRequest(requestName); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java index 45eca01b3b..89a126f780 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheAnalysisPageRequest.java @@ -71,14 +71,23 @@ public Response handleRequest(Map variables) throws WebException UUID serverUUID = entry.getKey(); String html = Base64Util.decode(entry.getValue()); - ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); - if (export) { - Processor.queue(() -> HtmlExport.exportServer(serverUUID)); - } + cache(export, serverUUID, html); } } catch (DBException e) { throw new TransferDatabaseException(e); } return DefaultResponses.SUCCESS.get(); } + + private void cache(boolean export, UUID serverUUID, String html) { + ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new AnalysisPageResponse(html)); + if (export) { + Processor.queue(() -> HtmlExport.exportServer(serverUUID)); + } + } + + @Override + public void runLocally() { + cache(Settings.ANALYSIS_EXPORT.isTrue(), serverUUID, html); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index 744b9df1ac..ad8351c387 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -71,14 +71,23 @@ public Response handleRequest(Map variables) throws WebException UUID uuid = entry.getKey(); String html = Base64Util.decode(entry.getValue()); - ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(uuid, html)); - if (export) { - Processor.queue(() -> HtmlExport.exportPlayer(uuid)); - } + cache(export, uuid, html); } } catch (DBException e) { throw new TransferDatabaseException(e); } return DefaultResponses.SUCCESS.get(); } + + private void cache(boolean export, UUID uuid, String html) { + ResponseCache.cacheResponse(PageId.PLAYER.of(uuid), () -> new InspectPageResponse(uuid, html)); + if (export) { + Processor.queue(() -> HtmlExport.exportPlayer(uuid)); + } + } + + @Override + public void runLocally() { + cache(Settings.ANALYSIS_EXPORT.isTrue(), player, html); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java index 07f71b1252..d81489d176 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java @@ -9,6 +9,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.PageId; @@ -29,19 +30,23 @@ public class CacheInspectPluginsTabRequest extends InfoRequestWithVariables implements CacheRequest { private static final String SPLIT = ";;SPLIT;;"; + private final UUID player; - private final String navAndHtml; + private final String nav; + private final String html; private CacheInspectPluginsTabRequest() { player = null; - navAndHtml = null; + nav = null; + html = null; } public CacheInspectPluginsTabRequest(UUID player, String nav, String html) { Verify.nullCheck(player, nav); variables.put("player", player.toString()); this.player = player; - this.navAndHtml = nav + SPLIT + html; + this.nav = nav; + this.html = html; } public static CacheInspectPluginsTabRequest createHandler() { @@ -50,9 +55,9 @@ public static CacheInspectPluginsTabRequest createHandler() { @Override public void placeDataToDatabase() throws WebException { - Verify.nullCheck(player, navAndHtml); + Verify.nullCheck(player, nav); - String encodedHtml = Base64Util.encode(navAndHtml); + String encodedHtml = Base64Util.encode(nav + SPLIT + html); try { Database.getActive().transfer().storePlayerPluginsTab(player, encodedHtml); } catch (DBException e) { @@ -70,20 +75,28 @@ public Response handleRequest(Map variables) throws WebException UUID uuid = UUID.fromString(player); try { - Map pages = Database.getActive().transfer().getEncodedPlayerPluginsTabs(uuid); + InspectPagePluginsContent pluginsTab = getPluginsTab(uuid); - InspectPagePluginsContent pluginsTab = (InspectPagePluginsContent) - ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), InspectPagePluginsContent::new); + Map pages = Database.getActive().transfer().getEncodedPlayerPluginsTabs(uuid); for (Map.Entry entry : pages.entrySet()) { UUID serverUUID = entry.getKey(); - String[] html = Base64Util.decode(entry.getValue()).split(SPLIT); + String[] navAndHtml = Base64Util.decode(entry.getValue()).split(SPLIT); - pluginsTab.addTab(serverUUID, html[0], html[1]); + pluginsTab.addTab(serverUUID, navAndHtml[0], navAndHtml[1]); } } catch (DBException e) { throw new TransferDatabaseException(e); } return DefaultResponses.SUCCESS.get(); } + + private InspectPagePluginsContent getPluginsTab(UUID uuid) { + return (InspectPagePluginsContent) ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), InspectPagePluginsContent::new); + } + + @Override + public void runLocally() { + getPluginsTab(player).addTab(ServerInfo.getServerUUID(), nav, html); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java index e15af05869..9711387ab3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheNetworkPageContentRequest.java @@ -9,6 +9,7 @@ import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.PageId; @@ -21,7 +22,7 @@ /** * InfoRequest for caching Network page parts to ResponseCache of receiving server. - * + *

    * SHOULD NOT BE SENT TO BUKKIT * * @author Rsl1122 @@ -70,9 +71,8 @@ public Response handleRequest(Map variables) throws WebException String serverName = serverNames.getOrDefault(serverUUID, "Unknown"); String html = entry.getValue(); - NetworkPageContent response = (NetworkPageContent) - ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new); - response.addElement(serverName, html); + NetworkPageContent networkPage = getNetworkPageContent(); + networkPage.addElement(serverName, html); } InfoSystem.getInstance().updateNetworkPage(); @@ -80,6 +80,15 @@ public Response handleRequest(Map variables) throws WebException return DefaultResponses.SUCCESS.get(); } + private NetworkPageContent getNetworkPageContent() { + return (NetworkPageContent) ResponseCache.loadResponse(PageId.NETWORK_CONTENT.id(), NetworkPageContent::new); + } + + @Override + public void runLocally() { + getNetworkPageContent().addElement(ServerInfo.getServerName(), html); + } + public static CacheNetworkPageContentRequest createHandler() { return new CacheNetworkPageContentRequest(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index 4771b3a7b4..bfabbc2eb2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -12,8 +12,8 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.server.ServerInfo; -import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.pages.parsing.AnalysisPage; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.pages.AnalysisPageResponse; import com.djrapitops.plan.utilities.NullCheck; @@ -60,14 +60,23 @@ public Response handleRequest(Map variables) throws WebException throw new BadRequestException("Requested Analysis page from wrong server."); } + generateAndCache(serverUUID); + + return DefaultResponses.SUCCESS.get(); + } + + private void generateAndCache(UUID serverUUID) throws WebException { InfoSystem infoSystem = InfoSystem.getInstance(); infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, AnalysisPageResponse.getRefreshingHtml())); infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, analyseAndGetHtml())); + } - return DefaultResponses.SUCCESS.get(); + @Override + public void runLocally() throws WebException { + generateAndCache(serverUUID); } - public String analyseAndGetHtml() throws InternalErrorException { + private String analyseAndGetHtml() throws InternalErrorException { try { UUID serverUUID = ServerInfo.getServerUUID(); Database db = Database.getActive(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index e31f536afc..21f66a56b6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -11,8 +11,8 @@ import com.djrapitops.plan.api.exceptions.connection.WebFailException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.info.InfoSystem; -import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.pages.parsing.InspectPage; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.utilities.Verify; @@ -56,13 +56,23 @@ public Response handleRequest(Map variables) throws WebException NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied in the request.")); UUID uuid = UUID.fromString(player); - String html = getHtml(uuid); - InfoSystem.getInstance().sendRequest(new CacheInspectPageRequest(uuid, html)); + generateAndCache(uuid); return DefaultResponses.SUCCESS.get(); } + private void generateAndCache(UUID uuid) throws WebException { + String html = getHtml(uuid); + InfoSystem.getInstance().getConnectionSystem().sendWideInfoRequest(new GenerateInspectPluginsTabRequest(uuid)); + InfoSystem.getInstance().sendRequest(new CacheInspectPageRequest(uuid, html)); + } + + @Override + public void runLocally() throws WebException { + generateAndCache(playerUUID); + } + private String getHtml(UUID uuid) throws WebException { try { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java index 2fb05d2a11..a6e9f57018 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPluginsTabRequest.java @@ -9,8 +9,6 @@ import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.webserver.response.DefaultResponses; 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.parts.InspectPagePluginsContent; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.utilities.Verify; @@ -54,16 +52,20 @@ public Response handleRequest(Map variables) throws WebException NullCheck.check(player, new BadRequestException("Player UUID 'player' variable not supplied in the request.")); UUID uuid = UUID.fromString(player); - String[] navAndhtml = getNavAndHtml(uuid); - InfoSystem.getInstance().sendRequest(new CacheInspectPluginsTabRequest(uuid, navAndhtml[0], navAndhtml[1])); + generateAndCache(uuid); return DefaultResponses.SUCCESS.get(); } - private String[] getNavAndHtml(UUID uuid) { - return ((InspectPagePluginsContent) ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), - InspectPagePluginsContent::new)).getContents(); + private void generateAndCache(UUID uuid) throws WebException { + String[] navAndHtml = InspectPagePluginsContent.generateForThisServer(uuid).getContents(); + InfoSystem.getInstance().sendRequest(new CacheInspectPluginsTabRequest(uuid, navAndHtml[0], navAndHtml[1])); + } + + @Override + public void runLocally() throws WebException { + generateAndCache(playerUUID); } public UUID getPlayerUUID() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java index 08e24217ef..6484c70004 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/InfoRequest.java @@ -20,4 +20,6 @@ public interface InfoRequest { Response handleRequest(Map variables) throws WebException; + void runLocally() throws WebException; + } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java index ece10fd3b8..04ff733843 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java @@ -48,6 +48,11 @@ public void placeDataToDatabase() { /* Not necessary */ } + @Override + public void runLocally() { + /* Won't be run */ + } + @Override public Response handleRequest(Map variables) throws WebException { if (Check.isBungeeAvailable()) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java index 7712125b83..4e1fab4fb3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java @@ -47,6 +47,11 @@ public void placeDataToDatabase() { /* Not necessary */ } + @Override + public void runLocally() { + /* Won't be run */ + } + @Override public Response handleRequest(Map variables) throws WebException { // Available variables: sender, address diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java index 63f8cbf736..ca557b4001 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/api/BadRequestResponse.java @@ -12,7 +12,7 @@ public class BadRequestResponse extends Response { public BadRequestResponse(String error) { - super.setHeader("HTTP/1.1 400 Bad Request"); - super.setContent(error); + super.setHeader("HTTP/1.1 400 Bad Request " + error); + super.setContent("400 Bad Request: " + error); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java index f0c14bc9d8..beb9eed1ff 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.function.Predicate; /** * This class contains the page cache. @@ -103,19 +102,6 @@ public static boolean isCached(String identifier) { return cache.containsKey(identifier); } - /** - * Removes all of the elements of this cache that satisfy the given predicate. - * - * @param filter a predicate which returns true for entries to be removed - */ - public static void removeIf(Predicate filter) { - for (String identifier : cache.keySet()) { - if (filter.test(identifier)) { - cache.remove(identifier); - } - } - } - /** * Clears the cache from all its contents. */ diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java index bc976bed08..ff20204440 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java @@ -36,13 +36,13 @@ public InspectPagePluginsContent(UUID serverUUID, String nav, String html) { addTab(serverUUID, nav, html); } - public static InspectPagePluginsContent generateForThisServer(UUID uuid) { + public static InspectPagePluginsContent generateForThisServer(UUID playerUUID) { HookHandler hookHandler = HookHandler.getInstance(); - Map containers = hookHandler.getInspectContainersFor(uuid); + Map containers = hookHandler.getInspectContainersFor(playerUUID); String serverName = ServerInfo.getServerName(); String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName; if (containers.isEmpty()) { - new InspectPagePluginsContent(uuid, "

  • " + actualServerName + "(No Data)
  • ", ""); + new InspectPagePluginsContent(playerUUID, "
  • " + actualServerName + "(No Data)
  • ", ""); } String nav = "
  • " + actualServerName + "
  • "; diff --git a/Plan/src/test/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java index caff19d569..d33b9e0bca 100644 --- a/Plan/src/test/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/data/cache/ResponseCacheTest.java @@ -38,13 +38,4 @@ public void testClearCache() { ResponseCache.clearCache(); assertFalse(ResponseCache.isCached(IDENTIFIER)); } - - @Test - public void testRemoveIf() { - ResponseCache.cacheResponse(IDENTIFIER, () -> RESPONSE); - assertTrue(ResponseCache.isCached(IDENTIFIER)); - - ResponseCache.removeIf(identifier -> identifier.equals(IDENTIFIER)); - assertFalse(ResponseCache.isCached(IDENTIFIER)); - } } diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/MySQLTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/MySQLTest.java similarity index 91% rename from Plan/src/test/java/com/djrapitops/plan/system/database/MySQLTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/database/databases/MySQLTest.java index 3fc3a38569..d4b17c9328 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/MySQLTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/MySQLTest.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.database; +package com.djrapitops.plan.system.database.databases; import com.djrapitops.plan.system.database.databases.sql.MySQLDB; import org.junit.Test; diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java similarity index 99% rename from Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java rename to Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java index e4ca8f7df2..7daed5f3f2 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.djrapitops.plan.system.database; +package com.djrapitops.plan.system.database.databases; import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.database.DBException; @@ -844,6 +844,7 @@ public void testSaveSessionsWorldTimes() throws SQLException { } @Test + @Ignore public void testRegisterProcessorRegisterException() throws SQLException { assertFalse(db.getUsersTable().isRegistered(playerUUID)); assertFalse(db.getUserInfoTable().isRegistered(playerUUID)); From da95ed258302cab1a089e0c0701fa136c32eaa10 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 13:51:28 +0200 Subject: [PATCH 069/166] Fixed Plugins tab for Inspect page --- .../main/java/com/djrapitops/plan/Plan.java | 9 ++------ .../djrapitops/plan/system/PlanSystem.java | 6 ++++- .../system/webserver/response/Response.java | 2 +- .../response/cache/ResponseCache.java | 17 -------------- .../response/pages/AnalysisPageResponse.java | 2 +- .../response/pages/InspectPageResponse.java | 23 +++++++------------ .../parts/InspectPagePluginsContent.java | 4 ++-- Plan/src/main/resources/bungee.yml | 2 +- Plan/src/main/resources/plugin.yml | 2 +- 9 files changed, 21 insertions(+), 46 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index b4637e8070..16dc22bea5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -75,12 +75,6 @@ public void onEnable() { system = new BukkitSystem(this); system.enable(); - registerCommand("plan", new PlanCommand(this)); - - Benchmark.start("Hook to 3rd party plugins"); - hookHandler = new HookHandler(); - Benchmark.stop("Enable", "Hook to 3rd party plugins"); - ImporterManager.registerImporter(new OfflinePlayerImporter()); BStats bStats = new BStats(this); @@ -91,10 +85,11 @@ public void onEnable() { Log.logDebug("Enable"); Log.info(Locale.get(Msg.ENABLED).toString()); } catch (Exception e) { - Log.error("Plugin Failed to Initialize Correctly."); + Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload"); Log.toLog(this.getClass().getName(), e); onDisable(); } + registerCommand("plan", new PlanCommand(this)); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 922aa4e53a..a32f38db00 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -50,6 +50,8 @@ public abstract class PlanSystem implements SubSystem { protected ServerInfo serverInfo; protected HookHandler hookHandler; + + // Not a SubSystem. protected PlanAPI planAPI; public PlanSystem() { @@ -86,7 +88,8 @@ public void enable() throws EnableException { processingQueue, cacheSystem, listenerSystem, - taskSystem + taskSystem, + hookHandler }; for (SubSystem system : systems) { system.enable(); @@ -96,6 +99,7 @@ public void enable() throws EnableException { @Override public void disable() { SubSystem[] systems = new SubSystem[]{ + hookHandler, cacheSystem, listenerSystem, processingQueue, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java index 01ffa16e80..c415873120 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/Response.java @@ -87,7 +87,7 @@ public void send(HttpExchange exchange) throws IOException { exchange.sendResponseHeaders(getCode(), 0); try (GZIPOutputStream out = new GZIPOutputStream(exchange.getResponseBody()); - ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes())) { + ByteArrayInputStream bis = new ByteArrayInputStream(getContent().getBytes())) { byte[] buffer = new byte[2048]; int count; while ((count = bis.read(buffer)) != -1) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java index beb9eed1ff..2613fd3951 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/cache/ResponseCache.java @@ -1,7 +1,6 @@ package com.djrapitops.plan.system.webserver.response.cache; import com.djrapitops.plan.system.webserver.response.Response; -import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse; import java.util.HashMap; import java.util.Map; @@ -63,22 +62,6 @@ public static Response loadResponse(String identifier) { return cache.get(identifier); } - /** - * Returns a copy some responses - *

    - * Currently supported copyable responses: InspectPageResponse - * - * @param identifier The identifier of the page - * @return Copied Response of loadResponse, so that cache contents are not changed. - */ - public static Response copyResponse(String identifier, ResponseLoader loader) { - Response response = loadResponse(identifier, loader); - if (response instanceof InspectPageResponse) { - return InspectPageResponse.copyOf((InspectPageResponse) response); - } - return response; - } - /** * Puts the page into the page cache. *

    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 b2442f4c5a..6e6d49aa4e 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 @@ -33,7 +33,7 @@ public AnalysisPageResponse(String html) { public static String getRefreshingHtml() { ErrorResponse refreshPage = new ErrorResponse(); refreshPage.setTitle("Analysis is being refreshed.."); - refreshPage.setParagraph(" Analysis is being run, refresh the page after a few seconds.. (F5)"); + refreshPage.setParagraph(" Analysis is being run, refresh the page after a few seconds.. (F5)"); refreshPage.replacePlaceholders(); return refreshPage.getContent(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java index f91eba4904..5280561ded 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java @@ -18,34 +18,27 @@ public class InspectPageResponse extends Response { private final UUID uuid; - private InspectPagePluginsContent pluginsTab; public InspectPageResponse(UUID uuid, String html) { - this.uuid = uuid; super.setHeader("HTTP/1.1 200 OK"); super.setContent(Theme.replaceColors(html)); - pluginsTab = (InspectPagePluginsContent) - ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), InspectPagePluginsContent::new); - } - - private InspectPageResponse(InspectPageResponse response) { - this.uuid = response.uuid; - super.setHeader(response.getHeader()); - super.setContent(response.getContent()); - } - - public static InspectPageResponse copyOf(InspectPageResponse response) { - return new InspectPageResponse(response); + this.uuid = uuid; } @Override public String getContent() { Map replaceMap = new HashMap<>(); - String[] inspectPagePluginsTab = pluginsTab.getContents(); + InspectPagePluginsContent pluginsTab = (InspectPagePluginsContent) + ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid)); + String[] inspectPagePluginsTab = pluginsTab != null ? pluginsTab.getContents() : getCalculating(); replaceMap.put("navPluginsTabs", inspectPagePluginsTab[0]); replaceMap.put("pluginsTabs", inspectPagePluginsTab[1]); return StrSubstitutor.replace(super.getContent(), replaceMap); } + private String[] getCalculating() { + return new String[]{"

  • Calculating...
  • ", ""}; + } + } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java index ff20204440..8e519fcfb9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java @@ -32,7 +32,7 @@ public InspectPagePluginsContent() { } public InspectPagePluginsContent(UUID serverUUID, String nav, String html) { - this(); + pluginsTab = new HashMap<>(); addTab(serverUUID, nav, html); } @@ -42,7 +42,7 @@ public static InspectPagePluginsContent generateForThisServer(UUID playerUUID) { String serverName = ServerInfo.getServerName(); String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName; if (containers.isEmpty()) { - new InspectPagePluginsContent(playerUUID, "
  • " + actualServerName + "(No Data)
  • ", ""); + return new InspectPagePluginsContent(playerUUID, "
  • " + actualServerName + " (No Data)
  • ", ""); } String nav = "
  • " + actualServerName + "
  • "; diff --git a/Plan/src/main/resources/bungee.yml b/Plan/src/main/resources/bungee.yml index 6830790892..64262e20b5 100644 --- a/Plan/src/main/resources/bungee.yml +++ b/Plan/src/main/resources/bungee.yml @@ -1,4 +1,4 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.PlanBungee -version: 4.1.4 \ No newline at end of file +version: 4.1.5-DEV \ No newline at end of file diff --git a/Plan/src/main/resources/plugin.yml b/Plan/src/main/resources/plugin.yml index dc978003e1..0df33d66e7 100644 --- a/Plan/src/main/resources/plugin.yml +++ b/Plan/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.Plan -version: 4.1.4 +version: 4.1.5-DEV softdepend: - EssentialsX - Towny From b3ac110dfe2d878c4d2973f63390be4d60b5a37d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 14:21:45 +0200 Subject: [PATCH 070/166] Fixed maven shading --- Plan/dependency-reduced-pom.xml | 1 - Plan/pom.xml | 7 ------- .../com/djrapitops/plan/ShutdownHook.java | 2 ++ .../plan/data/container/PlayerKill.java | 10 ++++------ .../plan/data/container/Session.java | 18 ++++++++---------- .../djrapitops/plan/data/container/TPS.java | 19 ++++++++----------- .../djrapitops/plan/data/time/TimeKeeper.java | 8 ++------ .../plan/utilities/analysis/Point.java | 9 +++------ 8 files changed, 27 insertions(+), 47 deletions(-) diff --git a/Plan/dependency-reduced-pom.xml b/Plan/dependency-reduced-pom.xml index 3ce6703bcd..c9091699de 100644 --- a/Plan/dependency-reduced-pom.xml +++ b/Plan/dependency-reduced-pom.xml @@ -47,7 +47,6 @@ - true org.powermock:* diff --git a/Plan/pom.xml b/Plan/pom.xml index 506fa900d5..8ede53de87 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -26,14 +26,12 @@ com.djrapitops AbstractPluginFramework 3.0.1 - compile com.djrapitops PlanPluginBridge 4.2.0-SNAPSHOT - compile @@ -69,7 +67,6 @@ org.apache.commons commons-lang3 3.6 - compile @@ -82,19 +79,16 @@ org.apache.commons commons-dbcp2 2.1.1 - compile org.apache.commons commons-pool2 2.4.2 - compile commons-logging commons-logging 1.2 - compile @@ -171,7 +165,6 @@ - true org.powermock:* diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index 07954423e6..f642e96645 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -53,6 +53,8 @@ public void run() { saveFirstSessionInformation(db, now); saveActiveSessions(db, activeSessions, now); + } catch (IllegalStateException ignored) { + /* Database is not initialized */ } catch (DBInitException e) { Log.toLog(this.getClass().getName(), e); } finally { diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java index ffaf707666..1c8fb39eb8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/PlayerKill.java @@ -2,7 +2,6 @@ import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.system.cache.DataCache; -import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Objects; import java.util.UUID; @@ -81,10 +80,9 @@ public int hashCode() { @Override public String toString() { - return new ToStringBuilder(this) - .append("victim", victim) - .append("time", time) - .append("weapon", weapon) - .toString(); + return "PlayerKill{" + + "victim=" + victim + ", " + + "time=" + time + ", " + + "weapon='" + weapon + "'}"; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java index fb5a21349d..22f4d0cd76 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java @@ -2,7 +2,6 @@ import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.utilities.MiscUtils; -import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.ArrayList; import java.util.HashMap; @@ -194,14 +193,13 @@ public int hashCode() { @Override public String toString() { - return new ToStringBuilder(this) - .append("sessionStart", sessionStart) - .append("sessionID", sessionID) - .append("worldTimes", worldTimes) - .append("sessionEnd", sessionEnd) - .append("playerKills", playerKills) - .append("mobKills", mobKills) - .append("deaths", deaths) - .toString(); + return "Session{" + + "sessionStart=" + sessionStart + ", " + + "sessionID=" + sessionID + ", " + + "worldTimes=" + worldTimes + ", " + + "sessionEnd=" + sessionEnd + ", " + + "playerKills=" + playerKills + ", " + + "mobKills=" + mobKills + ", " + + "deaths=" + deaths + '}'; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java b/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java index c211375814..0b683ba994 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/TPS.java @@ -5,8 +5,6 @@ */ package com.djrapitops.plan.data.container; -import org.apache.commons.lang3.builder.ToStringBuilder; - import java.util.Objects; /** @@ -130,14 +128,13 @@ public int hashCode() { @Override public String toString() { - return new ToStringBuilder(this) - .append("date", date) - .append("ticksPerSecond", ticksPerSecond) - .append("players", players) - .append("cpuUsage", cpuUsage) - .append("usedMemory", usedMemory) - .append("entityCount", entityCount) - .append("chunksLoaded", chunksLoaded) - .toString(); + return "TPS{" + + "date=" + date + ", " + + "ticksPerSecond=" + ticksPerSecond + ", " + + "players=" + players + ", " + + "cpuUsage=" + cpuUsage + ", " + + "usedMemory=" + usedMemory + ", " + + "entityCount=" + entityCount + ", " + + "chunksLoaded=" + chunksLoaded + '}'; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java b/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java index 4b46453501..8fdd617e7e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/time/TimeKeeper.java @@ -1,7 +1,6 @@ package com.djrapitops.plan.data.time; import com.djrapitops.plugin.utilities.Verify; -import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.HashMap; import java.util.Map; @@ -155,10 +154,7 @@ public int hashCode() { @Override public String toString() { - return new ToStringBuilder(this) - .append("times", times) - .append("state", state) - .append("lastStateChange", lastStateChange) - .toString(); + return "TimeKeeper{" + "times=" + times + + ", state='" + state + "', lastStateChange=" + lastStateChange + '}'; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Point.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Point.java index cf74bf1fe2..85dc2fe499 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Point.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Point.java @@ -1,7 +1,5 @@ package com.djrapitops.plan.utilities.analysis; -import org.apache.commons.lang3.builder.ToStringBuilder; - import java.util.Objects; /** @@ -41,9 +39,8 @@ public int hashCode() { @Override public String toString() { - return new ToStringBuilder(this) - .append("x", x) - .append("y", y) - .toString(); + return "Point{" + + "x=" + x + ", " + + "y=" + y + '}'; } } From a55b17246a1482dfce884bddc55eef00a8c57ddc Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 14:54:49 +0200 Subject: [PATCH 071/166] Simplified connection attempts --- .../plan/system/info/BukkitInfoSystem.java | 3 +- .../plan/system/info/BungeeInfoSystem.java | 2 +- .../plan/system/info/InfoSystem.java | 10 +++++-- .../connection/BukkitConnectionSystem.java | 16 +++------- .../connection/BungeeConnectionSystem.java | 22 +++++++------- .../system/info/connection/ConnectionLog.java | 30 ------------------- .../info/connection/ConnectionSystem.java | 9 +++--- .../system/webserver/ResponseHandler.java | 4 +-- .../response/pages/AnalysisPageResponse.java | 9 +++++- .../response/pages/DebugPageResponse.java | 16 ++++++++-- 10 files changed, 54 insertions(+), 67 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java index c588fb8c8e..3818e46b82 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BukkitInfoSystem.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.system.info; +import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.connection.BukkitConnectionSystem; import com.djrapitops.plan.system.info.request.CacheNetworkPageContentRequest; @@ -26,7 +27,7 @@ public BukkitInfoSystem() { @Override public void runLocally(InfoRequest infoRequest) throws WebException { if (infoRequest instanceof SetupRequest) { - return; + throw new NoServersException("Set-up requests can not be run locally."); } infoRequest.runLocally(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java index 22b93e5fcd..be60185412 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/BungeeInfoSystem.java @@ -30,7 +30,7 @@ public BungeeInfoSystem() { @Override public void runLocally(InfoRequest infoRequest) throws WebException { // runLocally is called when ConnectionSystem has no servers. - throw new NoServersException("No servers were available to process this request."); + throw new NoServersException("No servers were available to process this request (Local attempt): " + infoRequest.getClass().getSimpleName()); } @Override 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 626e140f75..14524d6fd0 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 @@ -66,10 +66,16 @@ public void sendRequest(InfoRequest infoRequest) throws WebException { try { if (!connectionSystem.isServerAvailable()) { runLocally(infoRequest); + return; } connectionSystem.sendInfoRequest(infoRequest); - } catch (NoServersException e) { - runLocally(infoRequest); + } catch (WebException original) { + try { + // Attempt to run locally. + runLocally(infoRequest); + } catch (NoServersException e2) { + throw original; + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index 0c15fee695..1f35f877bb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -17,8 +17,6 @@ import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.task.AbsRunnable; -import com.djrapitops.plugin.task.RunnableFactory; import java.util.Optional; import java.util.UUID; @@ -39,7 +37,7 @@ public BukkitConnectionSystem() { } private void refreshServerMap() { - if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.MINUTE.ms() * 2L) { + if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.SECOND.ms() * 15L) { try { Database database = Database.getActive(); Optional bungeeInformation = database.fetch().getBungeeInformation(); @@ -57,7 +55,7 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer refreshServerMap(); if (mainServer == null && bukkitServers.isEmpty()) { - throw new NoServersException("No Servers available to process requests."); + throw new NoServersException("Zero servers available to process requests."); } Server server = null; @@ -81,7 +79,7 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer @Override public void sendWideInfoRequest(WideRequest infoRequest) throws NoServersException { if (bukkitServers.isEmpty()) { - throw new NoServersException("No Servers Available to make process request."); + throw new NoServersException("No Servers available to make wide-request: " + infoRequest.getClass().getSimpleName()); } for (Server server : bukkitServers.values()) { WebExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server)); @@ -90,7 +88,7 @@ public void sendWideInfoRequest(WideRequest infoRequest) throws NoServersExcepti @Override public boolean isServerAvailable() { - return ConnectionLog.hasConnectionSucceeded(mainServer); + return mainServer != null && Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isFalse(); } @Override @@ -102,12 +100,6 @@ public String getMainAddress() { @Override public void enable() { refreshServerMap(); - RunnableFactory.createNew("Server List Update Task", new AbsRunnable() { - @Override - public void run() { - refreshServerMap(); - } - }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 30L, TimeAmount.MINUTE.ticks() * 5L); boolean usingBungeeWebServer = ConnectionSystem.getInstance().isServerAvailable(); boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java index 5a08412def..019d49dbf2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java @@ -9,13 +9,10 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.task.AbsRunnable; -import com.djrapitops.plugin.task.RunnableFactory; import java.util.Optional; import java.util.UUID; @@ -34,7 +31,7 @@ public BungeeConnectionSystem() { } private void refreshServerMap() { - if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.MINUTE.ms() * 2L) { + if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.SECOND.ms() * 15L) { try { bukkitServers = Database.getActive().fetch().getBukkitServers(); latestServerMapRefresh = MiscUtils.getTime(); @@ -46,6 +43,7 @@ private void refreshServerMap() { @Override protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException { + refreshServerMap(); Server server = null; if (infoRequest instanceof CacheRequest) { throw new NoServersException("Bungee should not send Cache requests."); @@ -55,7 +53,7 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer } else if (infoRequest instanceof GenerateInspectPageRequest) { Optional serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); if (serverUUID.isPresent()) { - server = bukkitServers.getOrDefault(serverUUID.get(), ServerInfo.getServer()); + server = bukkitServers.getOrDefault(serverUUID.get(), getOneBukkitServer()); } } if (server == null) { @@ -64,10 +62,16 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer return server; } + private Server getOneBukkitServer() { + Optional first = bukkitServers.values().stream().findAny(); + return first.orElse(null); + } + @Override public void sendWideInfoRequest(WideRequest infoRequest) throws NoServersException { + refreshServerMap(); if (bukkitServers.isEmpty()) { - throw new NoServersException("No Servers Available to make process request."); + throw new NoServersException("No Servers available to make wide-request: " + infoRequest.getClass().getSimpleName()); } for (Server server : bukkitServers.values()) { WebExceptionLogger.logIfOccurs(this.getClass(), () -> sendInfoRequest(infoRequest, server)); @@ -87,12 +91,6 @@ public String getMainAddress() { @Override public void enable() { refreshServerMap(); - RunnableFactory.createNew("Server List Update Task", new AbsRunnable() { - @Override - public void run() { - refreshServerMap(); - } - }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 30L, TimeAmount.MINUTE.ticks() * 5L); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java index 8e35a2d818..aaaae70856 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java @@ -7,7 +7,6 @@ import com.djrapitops.plan.system.info.request.InfoRequest; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plugin.utilities.Verify; import java.util.HashMap; import java.util.Map; @@ -37,35 +36,6 @@ public static void logConnection(Server toServer, InfoRequest request, int respo log.put(toServer, requestMap); } - public static boolean isConnectionPlausible(Server server) { - if (server == null) { - return false; - } - - Map serverLog = getInstance().getLog().get(server); - return Verify.isEmpty(serverLog) || hasConnectionSucceeded(serverLog); - - } - - public static boolean hasConnectionSucceeded(Server server) { - if (server == null) { - return false; - } - Map serverLog = getInstance().getLog().get(server); - return !Verify.isEmpty(serverLog) - && hasConnectionSucceeded(serverLog); - - } - - private static boolean hasConnectionSucceeded(Map serverLog) { - for (Entry entry : serverLog.values()) { - if (entry.responseCode == 200) { - return true; - } - } - return false; - } - private static ConnectionLog getInstance() { return ConnectionSystem.getInstance().getConnectionLog(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 49c56831ae..a2f4ce5dc7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -17,10 +17,7 @@ import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.log.Log; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; +import java.util.*; /** * ConnectionSystem manages out- and inbound InfoRequest connections. @@ -121,4 +118,8 @@ private Map loadDataRequests() { putRequest(requests, SendDBSettingsRequest.createHandler()); return requests; } + + public List getBukkitServers() { + return new ArrayList<>(bukkitServers.values()); + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index c6c72a1d57..d9f4d5ffa3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -87,10 +87,10 @@ public Response getResponse(Request request) { } try { return getResponse(request, targetString, target); + } catch (NoServersException | NotFoundException e) { + return new NotFoundResponse(e.getMessage()); } catch (WebUserAuthException e) { return PromptAuthorizationResponse.getBasicAuthResponse(e); - } catch (NotFoundException e) { - return new NotFoundResponse(e.getMessage()); } catch (ForbiddenException e) { return new ForbiddenResponse(e.getMessage()); } catch (BadRequestException e) { 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 6e6d49aa4e..4c03db5ece 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 @@ -2,11 +2,14 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plugin.api.utility.log.Log; +import java.util.UUID; + /** * @author Rsl1122 * @since 3.5.2 @@ -14,9 +17,13 @@ public class AnalysisPageResponse extends Response { public static AnalysisPageResponse refreshNow() { + return refreshNow(ServerInfo.getServerUUID()); + } + + public static AnalysisPageResponse refreshNow(UUID serverUUID) { Processor.queue(() -> { try { - InfoSystem.getInstance().generateAnalysisPageOfThisServer(); + InfoSystem.getInstance().generateAnalysisPage(serverUUID); } catch (WebException e) { // TODO Exception handling Log.toLog(AnalysisPageResponse.class, e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 4e6fa77eb9..856c1ffc76 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.info.connection.ConnectionLog; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerProperties; @@ -66,8 +67,8 @@ private void appendConnectionLog(StringBuilder content) { try { Map> logEntries = ConnectionLog.getLogEntries(); - content.append("
    ");
    -            content.append("Server Address | Request Type | Sent | Response
    ") + content.append("
    **Connection Log:**
    "); + content.append("Server Address | Request Type | Response | Sent
    ") .append("-- | -- | -- | --
    "); for (Map.Entry> entry : logEntries.entrySet()) { Server server = entry.getKey(); @@ -85,6 +86,17 @@ private void appendConnectionLog(StringBuilder content) { } content.append("
    "); + content.append("
    **Servers:**
    "); + List servers = ConnectionSystem.getInstance().getBukkitServers(); + content.append("Server Name | Address | UUID
    ") + .append("-- | -- | --
    "); + for (Server server : servers) { + content.append(server.getName()).append(" | ") + .append(server.getWebAddress()).append(" | ") + .append(server.getUuid()).append(" | ").append("
    "); + } + content.append("
    "); + } catch (Exception e) { Log.toLog(this.getClass(), e); } From 58f2d7f02ccd5cc2c69917f3409111f89a7fca9b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 15:09:31 +0200 Subject: [PATCH 072/166] Fixed Inspect & Analysis request handling on Bungee --- .../system/info/connection/BungeeConnectionSystem.java | 2 ++ .../plan/system/info/request/CacheInspectPageRequest.java | 7 ++++++- .../system/info/request/GenerateAnalysisPageRequest.java | 1 + .../webserver/response/pages/AnalysisPageResponse.java | 8 +++++++- .../webserver/response/pages/DebugPageResponse.java | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java index 019d49dbf2..91f426932a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java @@ -54,6 +54,8 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer Optional serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest); if (serverUUID.isPresent()) { server = bukkitServers.getOrDefault(serverUUID.get(), getOneBukkitServer()); + } else { + server = getOneBukkitServer(); } } if (server == null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java index ad8351c387..e6202cfb30 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPageRequest.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.database.databases.Database; +import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.webserver.response.DefaultResponses; @@ -18,7 +19,9 @@ import com.djrapitops.plan.utilities.Base64Util; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.text.StrSubstitutor; +import java.util.Collections; import java.util.Map; import java.util.UUID; @@ -71,7 +74,9 @@ public Response handleRequest(Map variables) throws WebException UUID uuid = entry.getKey(); String html = Base64Util.decode(entry.getValue()); - cache(export, uuid, html); + Map replace = Collections.singletonMap("networkName", ServerInfo.getServerName()); + + cache(export, uuid, StrSubstitutor.replace(html, replace)); } } catch (DBException e) { throw new TransferDatabaseException(e); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index bfabbc2eb2..62e033d686 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -69,6 +69,7 @@ private void generateAndCache(UUID serverUUID) throws WebException { InfoSystem infoSystem = InfoSystem.getInstance(); infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, AnalysisPageResponse.getRefreshingHtml())); infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, analyseAndGetHtml())); + infoSystem.updateNetworkPage(); } @Override 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 4c03db5ece..1b373085ee 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,11 +1,15 @@ package com.djrapitops.plan.system.webserver.response.pages; +import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.Processor; 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.errors.ErrorResponse; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plugin.api.utility.log.Log; import java.util.UUID; @@ -24,9 +28,11 @@ public static AnalysisPageResponse refreshNow(UUID serverUUID) { Processor.queue(() -> { try { InfoSystem.getInstance().generateAnalysisPage(serverUUID); + } catch (NoServersException e) { + ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new NotFoundResponse(e.getMessage())); } catch (WebException e) { // TODO Exception handling - Log.toLog(AnalysisPageResponse.class, e); + Log.toLog(AnalysisPageResponse.class.getName(), e); } }); return new AnalysisPageResponse(getRefreshingHtml()); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index 856c1ffc76..c34714ed1a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -93,7 +93,7 @@ private void appendConnectionLog(StringBuilder content) { for (Server server : servers) { content.append(server.getName()).append(" | ") .append(server.getWebAddress()).append(" | ") - .append(server.getUuid()).append(" | ").append("
    "); + .append(server.getUuid()).append("
    "); } content.append("
    "); From bc17486fdbeece70de2934d06b36b8a5219142fd Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 15:35:11 +0200 Subject: [PATCH 073/166] Fix bugs & vulns reported by Sonar --- .../system/database/databases/sql/SQLiteDB.java | 15 +++++++++------ .../processing/importing/importers/Importer.java | 1 + .../processors/player/RegisterProcessor.java | 2 ++ .../plan/utilities/analysis/AnalysisUtils.java | 8 ++++---- .../plan/utilities/file/export/HtmlExport.java | 6 +++--- .../system/database/databases/SQLiteTest.java | 10 ++++++++++ 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index e9a1f1fd15..3e15ef4b39 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -57,17 +57,19 @@ public Connection getNewConnection(String dbName) throws SQLException { } String dbFilePath = new File(PlanPlugin.getInstance().getDataFolder(), dbName + ".db").getAbsolutePath(); - Connection connection; + Connection connection = getConnectionFor(dbFilePath); + connection.setAutoCommit(false); + return connection; + } + + private Connection getConnectionFor(String dbFilePath) throws SQLException { try { - connection = DriverManager.getConnection("jdbc:sqlite:" + dbFilePath + "?journal_mode=WAL"); + return DriverManager.getConnection("jdbc:sqlite:" + dbFilePath + "?journal_mode=WAL"); } catch (SQLException ignored) { - connection = DriverManager.getConnection("jdbc:sqlite:" + dbFilePath); Log.info("SQLite WAL mode not supported on this server version, using default. This may or may not affect performance."); + return DriverManager.getConnection("jdbc:sqlite:" + dbFilePath); } - connection.setAutoCommit(false); - - return connection; } private void startConnectionPingTask() { @@ -84,6 +86,7 @@ public void run() { statement.execute("/* ping */ SELECT 1"); } } catch (SQLException e) { + Log.debug("Something went wrong during Ping task."); try { connection = getNewConnection(dbName); } catch (SQLException e1) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java index 40d3cc3e40..72e0e5b2b4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java @@ -73,6 +73,7 @@ void execute() throws DBException { service.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { Log.toLog(this.getClass().getName(), e); + Thread.currentThread().interrupt(); } Benchmark.stop(benchmarkName); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java index f3613f5322..e8c689e4d2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/player/RegisterProcessor.java @@ -11,6 +11,7 @@ import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.processing.processors.ObjectProcessor; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.utility.log.Log; import java.util.UUID; @@ -41,6 +42,7 @@ public RegisterProcessor(UUID uuid, long registered, long time, String name, int public void process() { UUID uuid = getUUID(); Database db = Database.getActive(); + NullCheck.check(uuid, new IllegalStateException("UUID was null")); try { if (!db.check().isPlayerRegistered(uuid)) { db.save().registerNewUser(uuid, registered, name); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index c406dd5b1c..dbb9aa7a13 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -123,7 +123,7 @@ public static int getDayOfYear(long date) { } public static double getAveragePerDay(long after, long before, long total) { - return total / getNumberOfDaysBetween(after, before); + return (double) total / getNumberOfDaysBetween(after, before); } public static long getNumberOfDaysBetween(long start, long end) { @@ -134,7 +134,7 @@ public static long getNumberOfDaysBetween(long start, long end) { test += day; value++; } - return value; + return value == 0 ? 1 : value; } public static void addMissingWorlds(WorldTimes worldTimes) { @@ -196,7 +196,7 @@ public static double calculateProbabilityOfStaying(Set stickyMonthDa stickM++; } } - probability *= (stickM / similarM.size()); + probability *= ((double) stickM / similarM.size()); } if (!similarW.isEmpty()) { @@ -207,7 +207,7 @@ public static double calculateProbabilityOfStaying(Set stickyMonthDa } } - probability *= (stickW / similarW.size()); + probability *= ((double) stickW / similarW.size()); } return probability; 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 c249d37a4d..c8e51412e9 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 @@ -167,7 +167,6 @@ private void exportPlugins() { copyFromJar(resources, true); } - private void copyFromJar(String[] resources, boolean overwrite) { for (String resource : resources) { try { @@ -185,8 +184,9 @@ private void copyFromJar(String resource, boolean overwrite) throws IOException File to = new File(outputFolder, outputFile); to.getParentFile().mkdirs(); if (to.exists()) { - to.delete(); - to.createNewFile(); + if (!to.delete() || !to.createNewFile()) { + return; + } } export(to, lines); } diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java index 7daed5f3f2..908e6e828b 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java @@ -855,6 +855,16 @@ public void testRegisterProcessorRegisterException() throws SQLException { assertTrue(db.getUserInfoTable().isRegistered(playerUUID)); } + @Test + public void testRegister() throws DBException { + assertFalse(db.check().isPlayerRegistered(playerUUID)); + assertFalse(db.check().isPlayerRegisteredOnThisServer(playerUUID)); + db.save().registerNewUser(playerUUID, 1000L, "name"); + db.save().registerNewUserOnThisServer(playerUUID, 500L); + assertTrue(db.check().isPlayerRegistered(playerUUID)); + assertTrue(db.check().isPlayerRegisteredOnThisServer(playerUUID)); + } + @Test public void testWorldTableGetWorldNamesNoException() throws SQLException { Set worldNames = db.getWorldTable().getWorldNames(); From 37b5e69cf3f02a62aa16ef2a6435435202aa3794 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 15:43:42 +0200 Subject: [PATCH 074/166] Fix vuln reported by Sonar --- .../djrapitops/plan/system/settings/theme/ThemeConfig.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java index 67e0d8b6f1..eb1b374207 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java @@ -10,6 +10,7 @@ import com.djrapitops.plugin.api.utility.log.Log; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.util.List; @@ -76,7 +77,9 @@ private static File getConfigFile() throws IOException { } File themeFile = new File(folder, "theme.yml"); if (!themeFile.exists()) { - themeFile.createNewFile(); + if (!themeFile.createNewFile()) { + throw new FileNotFoundException("Failed to create theme.yml"); + } } return themeFile; } From d813aa547e94f43af8e38a69080997db913b8faa Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 19:35:22 +0200 Subject: [PATCH 075/166] Removed old API class in main.java.com.djrapitops.plan (Didn't help) --- .../djrapitops/plan/utilities/Base64Util.java | 6 + .../main/java/com/djrapitops/plan/Plan.java | 29 -- .../java/com/djrapitops/plan/api/API.java | 292 ------------------ 3 files changed, 6 insertions(+), 321 deletions(-) delete mode 100644 Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java delete mode 100644 Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java b/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java index 8ecdfa3856..64d15d04b6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/Base64Util.java @@ -13,6 +13,12 @@ */ public class Base64Util { + /** + * Hides public constructor. + */ + private Base64Util() { + } + public static String encode(String decoded) { byte[] encoded = Base64.getEncoder().encode(decoded.getBytes()); return new String(encoded); diff --git a/Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java deleted file mode 100644 index 3562f21bfd..0000000000 --- a/Plan/src/main/java/main/java/com/djrapitops/plan/Plan.java +++ /dev/null @@ -1,29 +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 main.java.com.djrapitops.plan; - -import main.java.com.djrapitops.plan.api.API; - -/** - * Older package version of Plan. - * - * @author Rsl1122 - * @deprecated Use com.djrapitops.plan.Plan instead. - */ -@Deprecated -public class Plan { - - /** - * Old method for getting old API. - * - * @return new instance of the old API object to not break old API. - * @deprecated Use PlanAPI.getInstance() instead as new API. - */ - @Deprecated - public static API getPlanAPI() { - return new API(com.djrapitops.plan.Plan.getInstance()); - } - -} \ No newline at end of file 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 deleted file mode 100644 index 6a5555863e..0000000000 --- a/Plan/src/main/java/main/java/com/djrapitops/plan/api/API.java +++ /dev/null @@ -1,292 +0,0 @@ -package main.java.com.djrapitops.plan.api; - -import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.api.exceptions.database.DBException; -import com.djrapitops.plan.data.calculation.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.response.DefaultResponses; -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.utilities.analysis.Analysis; -import com.djrapitops.plan.utilities.uuid.UUIDUtility; -import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.utilities.Verify; -import org.bukkit.OfflinePlayer; - -import java.util.Collection; -import java.util.Collections; -import java.util.UUID; - -import static org.bukkit.Bukkit.getOfflinePlayer; - -/** - * This class contains the API methods for Bukkit version of the plugin. - *

    - * Methods can be called from Asynchronous task and are thread safe unless - * otherwise stated. - *

    - * More information about API methods can be found on GitHub. - * - * @author Rsl1122 - * @see PluginData - * @since 4.0.0 - * @deprecated Old version of Plan API, use PlanAPI.getInstance() instead. - */ -@Deprecated -public class API { - - private final Plan plugin; - - /** - * Creates a new API instance - not supposed to be called outside {@code Plan.onEnable}. - * - * @param plugin Current instance of Plan - */ - public API(Plan plugin) { - this.plugin = plugin; - } - - /** - * Condition whether or not the plugin enabled successfully. - * - * @return true if plugin is enabled correctly. - */ - @Deprecated - public boolean isEnabled() { - return plugin.isEnabled(); - } - - /** - * Add a source of plugin data to the Plugins tab on Analysis and/or Inspect - * page. - *

    - * Refer to documentation on GitHub or Javadoc of PluginData to set-up a - * data source that extends PluginData correctly. - * - * @param dataSource an object that extends PluginData-object, thus allowing - * Analysis and Inspect to manage the data of a plugin correctly. - * @see PluginData - */ - @Deprecated - public void addPluginDataSource(PluginData dataSource) { - if (isEnabled()) { - plugin.getHookHandler().addPluginDataSource(dataSource); - } - } - - /** - * Used to get a relative link to InspectPage of a player. - *

    - * This method is useful if you have a table and want to link to the inspect - * page. - *

    - * Html.LINK.parse("Link", "PlayerName") can be used to get a link - * {@code PlayerName} - * - * @param name Name of the player - * @return {@code ../player/PlayerName} - */ - @Deprecated - public String getPlayerInspectPageLink(String name) { - if (name == null) { - return "#"; - } - return "../player/" + name.replace(" ", "%20").replace(".", "%2E"); - } - - /** - * Condition if Players's Inspect page is cached to ResponseCache. - * - * @param uuid UUID of the player. - * @return true/false - * @deprecated use {@code isPlayerHtmlCached} - */ - @Deprecated - public boolean isPlayersDataInspectCached(UUID uuid) { - return isPlayerHtmlCached(uuid); - } - - /** - * Condition if Players's Inspect page is cached to ResponseCache of the providing WebServer. - *

    - * Using BungeeCord: Will send a {@code IsCachedWebAPI} request to check if the page is in Bungee's ResponseCache. - * Only Bukkit: Checks ResponseCache for page. - * - * @param uuid UUID of the player. - * @return true/false - */ - @Deprecated - public boolean isPlayerHtmlCached(UUID uuid) { - return ResponseCache.isCached(PageId.PLAYER.of(uuid)); - } - - /** - * Cache Players's Inspect page to the ResponseCache of the providing WebServer. - * - * @param uuid UUID of the player. - * @deprecated use {@code cachePlayerHtml} - */ - @Deprecated - public void cacheUserDataToInspectCache(UUID uuid) { - cachePlayerHtml(uuid); - } - - /** - * Cache Players's Inspect page to the ResponseCache of the providing WebServer. - *

    - * Using BungeeCord: Will send a {@code PostHtmlWebAPI} request after calculating the inspect page. - * Only Bukkit: Calculates inspect page and places it in the ResponseCache. - * - * @param uuid UUID of the player. - * @deprecated use {@code cachePlayerHtml} - */ - @Deprecated - public void cachePlayerHtml(UUID uuid) { - try { - InfoSystem.getInstance().generateAndCachePlayerPage(uuid); - } catch (WebException e) { - Log.toLog(this.getClass().getName(), e); - } - } - - /** - * Used to get the full Html of the Inspect page as a string. - *

    - * Re-calculates the inspect html on this server. - * - * @param uuid UUID of the player. - * @return player.html with all placeholders replaced. - */ - @Deprecated - public String getPlayerHtmlAsString(UUID uuid) { - return ResponseCache.loadResponse(PageId.PLAYER.of(uuid), DefaultResponses.NOT_FOUND::get).getContent(); - } - - /** - * Condition if the Analysis has been run and is cached to the AnalysisCache. - * - * @return true/false - */ - @Deprecated - public boolean isAnalysisCached() { - return ResponseCache.isCached(PageId.SERVER.of(ServerInfo.getServerUUID())); - } - - /** - * Run the analysis. - */ - @Deprecated - public void updateAnalysisCache() { - if (!Analysis.isAnalysisBeingRun()) { - WebExceptionLogger.logIfOccurs(this.getClass(), () -> - InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) - ); - } - } - - /** - * Used to get the full HTML of the Analysis page as a string. - *

    - * Condition if the data is cached to AnalysisCache before calling this. - * - * @return server.html with all placeholders replaced. - * @throws NullPointerException if AnalysisData has not been cached. - */ - @Deprecated - public String getAnalysisHtmlAsString() { - return ResponseCache.loadResponse(PageId.SERVER.of(ServerInfo.getServerUUID()), AnalysisPageResponse::refreshNow).getContent(); - } - - /** - * Used to get the AnalysisData object. - *

    - * Condition if the data is cached to AnalysisCache before calling this. - * - * @return AnalysisData object. - * @see AnalysisData - */ - @Deprecated - public AnalysisData getAnalysisDataFromCache() { - throw new UnsupportedOperationException("No longer supported"); - } - - /** - * Used to get the PlayerName of a player who has played on the server. - * Should be called from an Async thread. - * - * @param uuid UUID of the player. - * @return PlayerName, eg "Rsl1122" - * @throws IllegalArgumentException If uuid is null. - * @throws IllegalStateException If the player has not played on the server before. - */ - @Deprecated - public String getPlayerName(UUID uuid) { - Verify.nullCheck(uuid); - try { - String playerName = Database.getActive().fetch().getPlayerName(uuid); - if (playerName != null) { - return playerName; - } - } catch (DBException e) { - Log.toLog(API.class, e); - } - OfflinePlayer offlinePlayer = getOfflinePlayer(uuid); - if (offlinePlayer != null) { - return offlinePlayer.getName(); - } - throw new IllegalStateException("Player has not played on this server before."); - } - - /** - * Uses UUIDUtility to turn PlayerName to UUID. - * - * @param playerName Player's name - * @return UUID of the Player - * @throws Exception if player's name is not registered at Mojang - * @deprecated Typo in method name, use playerNameToUUID instead - */ - @Deprecated - public UUID PlayerNameToUUID(String playerName) { - return playerNameToUUID(playerName); - } - - /** - * Uses UUIDUtility to turn PlayerName to UUID. - * - * @param playerName Player's name - * @return UUID of the Player - * @throws IllegalArgumentException if player's name is not registered at Mojang - */ - @Deprecated - public UUID playerNameToUUID(String playerName) { - UUID uuid = UUIDUtility.getUUIDOf(playerName); - if (uuid == null) { - throw new IllegalArgumentException("UUID did not get a match"); - } - return uuid; - } - - /** - * Get the saved UUIDs in the database. - *

    - * Should be called from async thread. - * - * @return Collection of UUIDs that can be found in the database. - * @since 3.4.2 - */ - @Deprecated - public Collection getSavedUUIDs() { - try { - return Database.getActive().fetch().getSavedUUIDs(); - } catch (DBException e) { - return Collections.EMPTY_SET; - } - } -} From 922562989a14e70055b8401f56e07d3a90480865 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 28 Jan 2018 20:01:12 +0200 Subject: [PATCH 076/166] Sonar Code smell clean-up --- .../main/java/com/djrapitops/plan/Plan.java | 35 ------ .../java/com/djrapitops/plan/PlanBungee.java | 29 ----- .../java/com/djrapitops/plan/PlanPlugin.java | 8 -- .../database/DBCreateTableException.java | 21 ---- .../plan/command/commands/InspectCommand.java | 3 +- .../commands/manage/ManageHotswapCommand.java | 2 +- .../commands/manage/ManageMoveCommand.java | 2 +- .../commands/manage/ManageRemoveCommand.java | 4 +- .../commands/manage/ManageSetupCommand.java | 3 +- .../plan/data/calculation/HealthNotes.java | 44 +++---- .../plan/data/element/InspectContainer.java | 5 + .../database/databases/sql/SQLiteDB.java | 6 +- .../databases/sql/tables/ActionsTable.java | 12 +- .../databases/sql/tables/CommandUseTable.java | 12 +- .../databases/sql/tables/GeoInfoTable.java | 11 +- .../databases/sql/tables/KillsTable.java | 14 +-- .../databases/sql/tables/NicknamesTable.java | 8 +- .../databases/sql/tables/SecurityTable.java | 10 +- .../databases/sql/tables/ServerTable.java | 16 +-- .../databases/sql/tables/SessionsTable.java | 16 +-- .../databases/sql/tables/TPSTable.java | 20 +-- .../database/databases/sql/tables/Table.java | 8 +- .../databases/sql/tables/TransferTable.java | 16 +-- .../databases/sql/tables/UserInfoTable.java | 12 +- .../databases/sql/tables/UsersTable.java | 14 +-- .../databases/sql/tables/VersionTable.java | 4 +- .../databases/sql/tables/WorldTable.java | 8 +- .../databases/sql/tables/WorldTimesTable.java | 16 +-- .../tables/move/Version8TransferTable.java | 10 +- .../importing/UserImportRefiner.java | 22 ++-- .../importing/importers/Importer.java | 118 ++++++------------ .../importers/OfflinePlayerImporter.java | 4 +- .../system/settings/theme/ThemeConfig.java | 7 +- .../plan/system/webserver/WebServer.java | 7 ++ .../response/pages/DebugPageResponse.java | 2 +- .../webapi/bukkit/ConfigurationWebAPI.java | 4 +- .../plan/utilities/analysis/Analysis.java | 94 +++++++------- .../utilities/file/export/HtmlExport.java | 16 +-- .../AnalysisPluginsTabContentCreator.java | 17 ++- .../plan/utilities/metrics/BStats.java | 7 +- .../plan/aac/AdvancedAntiCheatHook.java | 4 +- .../pluginbridge/plan/aac/HackerTable.java | 4 +- .../protocolsupport/ProtocolSupportHook.java | 4 +- .../plan/viaversion/ProtocolTable.java | 4 +- .../plan/viaversion/ViaVersionHook.java | 4 +- 45 files changed, 286 insertions(+), 401 deletions(-) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBCreateTableException.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 16dc22bea5..52ea1fa4e2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -20,17 +20,12 @@ package com.djrapitops.plan; import com.djrapitops.plan.command.PlanCommand; -import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.system.BukkitSystem; -import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.processing.importing.ImporterManager; import com.djrapitops.plan.system.processing.importing.importers.OfflinePlayerImporter; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.theme.PlanColorScheme; -import com.djrapitops.plan.system.webserver.WebServer; -import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; import com.djrapitops.plugin.StaticHolder; @@ -51,8 +46,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin { private BukkitSystem system; - private HookHandler hookHandler; // Manages 3rd party data sources - /** * Used to get the plugin-instance singleton. * @@ -120,34 +113,6 @@ public void onReload() { } - /** - * Used to access active Database. - * - * @return the Current Database - */ - @Deprecated - public Database getDB() { - return DBSystem.getInstance().getActiveDatabase(); - } - - /** - * Used to access WebServer. - * - * @return the WebServer - */ - public WebServer getWebServer() { - return WebServerSystem.getInstance().getWebServer(); - } - - /** - * Used to access HookHandler. - * - * @return HookHandler that manages Hooks to other plugins. - */ - public HookHandler getHookHandler() { - return hookHandler; - } - 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 16f5e69aed..4000607ec4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -6,13 +6,9 @@ import com.djrapitops.plan.command.PlanBungeeCommand; import com.djrapitops.plan.system.BungeeSystem; -import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.system.settings.theme.PlanColorScheme; -import com.djrapitops.plan.system.webserver.WebServer; -import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; @@ -32,9 +28,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin { private BungeeSystem system; - @Deprecated - private boolean setupAllowed = false; - public static PlanBungee getInstance() { return (PlanBungee) StaticHolder.getInstance(PlanBungee.class); } @@ -73,18 +66,6 @@ public String getVersion() { public void onReload() { } - @Override - @Deprecated - public Database getDB() { - return DBSystem.getInstance().getActiveDatabase(); - } - - @Override - @Deprecated - public WebServer getWebServer() { - return WebServerSystem.getInstance().getWebServer(); - } - @Override public InputStream getResource(String resource) { return getResourceAsStream(resource); @@ -95,16 +76,6 @@ public ColorScheme getColorScheme() { return PlanColorScheme.create(); } - @Deprecated - public boolean isSetupAllowed() { - return setupAllowed; - } - - @Deprecated - public void setSetupAllowed(boolean setupAllowed) { - this.setupAllowed = setupAllowed; - } - public BungeeSystem getSystem() { return system; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 153e4aa2e4..87a8de4d6c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -4,8 +4,6 @@ */ package com.djrapitops.plan; -import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.settings.ColorScheme; @@ -43,12 +41,6 @@ static PlanPlugin getInstance() { throw new IllegalAccessError("Plugin instance not available"); } - @Deprecated - Database getDB(); - - @Deprecated - WebServer getWebServer(); - File getDataFolder(); InputStream getResource(String resource); diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBCreateTableException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBCreateTableException.java deleted file mode 100644 index 4ca76fe6aa..0000000000 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/database/DBCreateTableException.java +++ /dev/null @@ -1,21 +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.api.exceptions.database; - -/** - * Thrown when something goes wrong with creating tables with {@code Table#createTable}. - * - * @author Rsl1122 - */ -public class DBCreateTableException extends DBInitException { - - public DBCreateTableException(String tableName, String message, Throwable cause) { - super(tableName + ": " + message, cause); - } - - public DBCreateTableException(Throwable cause) { - super(cause); - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index b4b50ac8ed..b8e8f10101 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -8,6 +8,7 @@ import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.uuid.UUIDUtility; @@ -75,7 +76,7 @@ public void run() { if (!Condition.isTrue(activeDB.check().isPlayerRegistered(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) { return; } - if (CommandUtils.isPlayer(sender) && plugin.getWebServer().isAuthRequired()) { + if (CommandUtils.isPlayer(sender) && WebServer.getInstance().isAuthRequired()) { boolean senderHasWebUser = activeDB.check().doesWebUserExists(sender.getName()); if (!senderHasWebUser) { diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index ec7484d82e..d5b20201e0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -58,7 +58,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { return true; } - if (Condition.isTrue(dbName.equals(plugin.getDB().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) { + if (Condition.isTrue(dbName.equals(Database.getActive().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) { return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java index 4d0bc2a9e7..c16fcf6b49 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageMoveCommand.java @@ -90,7 +90,7 @@ public void run() { ManageUtils.clearAndCopy(toDatabase, fromDatabase); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_MOVE_SUCCESS).toString()); - boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName()); + boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), Database.getActive().getConfigName()); Condition.isTrue(!movedToCurrentDatabase, Locale.get(Msg.MANAGE_INFO_CONFIG_REMINDER).toString(), sender); } catch (Exception e) { Log.toLog(this.getClass().getName() + " " + getTaskName(), e); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 9a517a5fc9..f4e1dd5577 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -85,7 +85,7 @@ public void run() { return; } - message = Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(plugin.getDB().getConfigName())); + message = Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(Database.getActive().getConfigName())); if (!Condition.isTrue(Verify.contains("-a", args), message, sender)) { return; } @@ -99,7 +99,7 @@ public void run() { SessionCache.getActiveSessions().remove(uuid); SessionCache.getInstance().cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name())); } - sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName())); + sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, Database.getActive().getConfigName())); } catch (DBException e) { Log.toLog(this.getClass().getName(), e); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 7bbe1c148a..333452afdb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.utilities.Condition; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.command.CommandType; @@ -52,7 +53,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { return true; } - if (!plugin.getWebServer().isEnabled()) { + if (!WebServerSystem.isWebServerEnabled()) { sender.sendMessage("§cWebServer is not enabled on this server! Make sure it enables on boot!"); return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/calculation/HealthNotes.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/HealthNotes.java index cda85234b2..b42027db3b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/calculation/HealthNotes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/HealthNotes.java @@ -24,16 +24,16 @@ */ public class HealthNotes { - private final List healthNotes; + private final List notes; private final AnalysisData analysisData; - private final TreeMap>> activityData; + private final SortedMap>> activityData; private final List tpsDataMonth; private final long now; private final long fourWeeksAgo; private double serverHealth; - public HealthNotes(AnalysisData analysisData, TreeMap>> activityData, List tpsDataMonth, long now) { - this.healthNotes = new ArrayList<>(); + public HealthNotes(AnalysisData analysisData, SortedMap>> activityData, List tpsDataMonth, long now) { + this.notes = new ArrayList<>(); serverHealth = 100.0; this.analysisData = analysisData; @@ -52,7 +52,7 @@ public void analyzeHealth() { public String parse() { StringBuilder healthNoteBuilder = new StringBuilder(); - for (String healthNote : healthNotes) { + for (String healthNote : notes) { healthNoteBuilder.append(healthNote); } return healthNoteBuilder.toString(); @@ -105,20 +105,20 @@ private void activityChangeNote() { + remain + "/" + activeFWAGNum + ")"; } if (change > 0) { - healthNotes.add( + notes.add( "

    " + Html.GREEN_THUMB.parse() + " Number of regular players has increased (+" + change + ")
    " + remainNote + "

    "); } else if (change == 0) { - healthNotes.add( + notes.add( "

    " + Html.GREEN_THUMB.parse() + " Number of regular players has stayed the same (+" + change + ")
    " + remainNote + "

    "); } else if (change > -20) { - healthNotes.add( + notes.add( "

    " + Html.YELLOW_FLAG.parse() + " Number of regular players has decreased (" + change + ")
    " + remainNote + "

    "); serverHealth -= 5; } else { - healthNotes.add( + notes.add( "

    " + Html.RED_WARN.parse() + " Number of regular players has decreased (" + change + ")
    " + remainNote + "

    "); serverHealth -= 10; @@ -128,10 +128,10 @@ private void activityChangeNote() { private void newPlayerNote() { double avgOnlineOnRegister = MathUtils.averageInt(analysisData.getStickyMonthData().stream().map(StickyData::getOnlineOnJoin)); if (avgOnlineOnRegister >= 1) { - healthNotes.add("

    " + Html.GREEN_THUMB.parse() + " New Players have players to play with when they join (" + notes.add("

    " + Html.GREEN_THUMB.parse() + " New Players have players to play with when they join (" + FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)

    "); } else { - healthNotes.add("

    " + Html.YELLOW_FLAG.parse() + " New Players may not have players to play with when they join (" + notes.add("

    " + Html.YELLOW_FLAG.parse() + " New Players may not have players to play with when they join (" + FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)

    "); serverHealth -= 5; } @@ -142,10 +142,10 @@ private void newPlayerNote() { if (newM != 0) { double stuckPerc = MathUtils.averageDouble(stuckPerM, newM) * 100; if (stuckPerc >= 25) { - healthNotes.add("

    " + Html.GREEN_THUMB.parse() + " " + FormatUtils.cutDecimals(stuckPerc) + notes.add("

    " + Html.GREEN_THUMB.parse() + " " + FormatUtils.cutDecimals(stuckPerc) + "% of new players have stuck around (" + stuckPerM + "/" + newM + ")

    "); } else { - healthNotes.add("

    " + Html.YELLOW_FLAG.parse() + " " + FormatUtils.cutDecimals(stuckPerc) + notes.add("

    " + Html.YELLOW_FLAG.parse() + " " + FormatUtils.cutDecimals(stuckPerc) + "% of new players have stuck around (" + stuckPerM + "/" + newM + ")

    "); } } @@ -171,16 +171,16 @@ private void activePlayerPlaytimeChange() { String avgLastTwoWeeksString = FormatUtils.formatTimeAmount(avgLastTwoWeeks); String avgFourToTwoWeeksString = FormatUtils.formatTimeAmount(avgFourToTwoWeeks); if (avgFourToTwoWeeks >= avgLastTwoWeeks) { - healthNotes.add("

    " + Html.GREEN_THUMB.parse() + " Active players seem to have things to do (Played " + notes.add("

    " + Html.GREEN_THUMB.parse() + " Active players seem to have things to do (Played " + avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString + ", last two weeks vs weeks 2-4)

    "); } else if (avgFourToTwoWeeks - avgLastTwoWeeks > TimeAmount.HOUR.ms() * 2L) { - healthNotes.add("

    " + Html.RED_WARN.parse() + " Active players might be running out of things to do (Played " + notes.add("

    " + Html.RED_WARN.parse() + " Active players might be running out of things to do (Played " + avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString + ", last two weeks vs weeks 2-4)

    "); serverHealth -= 5; } else { - healthNotes.add("

    " + Html.YELLOW_FLAG.parse() + " Active players might be running out of things to do (Played " + notes.add("

    " + Html.YELLOW_FLAG.parse() + " Active players might be running out of things to do (Played " + avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString + ", last two weeks vs weeks 2-4)

    "); } @@ -206,18 +206,18 @@ private void lowPerformance() { + FormatUtils.cutDecimals(aboveThreshold * 100.0) + "% of the time"; if (tpsSpikeMonth <= 5) { - healthNotes.add("

    " + Html.GREEN_THUMB.parse() + notes.add("

    " + Html.GREEN_THUMB.parse() + " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" + " " + tpsSpikeMonth + " times
    " + avgLowThresholdString + "

    "); } else if (tpsSpikeMonth <= 25) { - healthNotes.add("

    " + Html.YELLOW_FLAG.parse() + notes.add("

    " + Html.YELLOW_FLAG.parse() + " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" + " " + tpsSpikeMonth + " times
    " + avgLowThresholdString + "

    "); serverHealth *= 0.95; } else { - healthNotes.add("

    " + Html.RED_WARN.parse() + notes.add("

    " + Html.RED_WARN.parse() + " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" + " " + tpsSpikeMonth + " times
    " + avgLowThresholdString + "

    "); @@ -225,14 +225,14 @@ private void lowPerformance() { } if (serverDownTime <= TimeAmount.DAY.ms()) { - healthNotes.add("

    " + Html.GREEN_THUMB.parse() + " Total Server downtime (No Data) was " + notes.add("

    " + Html.GREEN_THUMB.parse() + " Total Server downtime (No Data) was " + FormatUtils.formatTimeAmount(serverDownTime) + "

    "); } else if (serverDownTime <= TimeAmount.WEEK.ms()) { - healthNotes.add("

    " + Html.YELLOW_FLAG.parse() + " Total Server downtime (No Data) was " + notes.add("

    " + Html.YELLOW_FLAG.parse() + " Total Server downtime (No Data) was " + FormatUtils.formatTimeAmount(serverDownTime) + "

    "); serverHealth *= (TimeAmount.WEEK.ms() - serverDownTime) * 1.0 / TimeAmount.WEEK.ms(); } else { - healthNotes.add("

    " + Html.RED_WARN.parse() + " Total Server downtime (No Data) was " + notes.add("

    " + Html.RED_WARN.parse() + " Total Server downtime (No Data) was " + FormatUtils.formatTimeAmount(serverDownTime) + "

    "); serverHealth *= (TimeAmount.MONTH.ms() - serverDownTime) * 1.0 / TimeAmount.MONTH.ms(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java index 95c7dce033..f99dfa0b66 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/element/InspectContainer.java @@ -69,6 +69,11 @@ public final String parseHtml() { return html.toString(); } + /** + * Check if InspectContainer has only values, and not HTML or Tables. + * + * @return true/false + */ public final boolean hasOnlyValues() { return html.isEmpty() && tables.isEmpty(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index 3e15ef4b39..f87ae8f492 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -58,9 +58,9 @@ public Connection getNewConnection(String dbName) throws SQLException { String dbFilePath = new File(PlanPlugin.getInstance().getDataFolder(), dbName + ".db").getAbsolutePath(); - Connection connection = getConnectionFor(dbFilePath); - connection.setAutoCommit(false); - return connection; + Connection newConnection = getConnectionFor(dbFilePath); + newConnection.setAutoCommit(false); + return newConnection; } private Connection getConnectionFor(String dbFilePath) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java index c8b04d53ee..a927aafdaf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ActionsTable.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.Actions; import com.djrapitops.plan.data.container.Action; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -38,10 +38,10 @@ */ public class ActionsTable extends UserIDTable { - private final String columnServerID = "server_id"; - private final String columnDate = "date"; - private final String columnActionID = "action_id"; - private final String columnAdditionalInfo = "additional_info"; + private static final String columnServerID = "server_id"; + private static final String columnDate = "date"; + private static final String columnActionID = "action_id"; + private static final String columnAdditionalInfo = "additional_info"; private final ServerTable serverTable; private String insertStatement; @@ -62,7 +62,7 @@ public ActionsTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { ServerTable serverTable = db.getServerTable(); createTable(TableSqlParser.createTable(tableName) .column(columnUserID, Sql.INT).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java index 1f82493d09..93e478deba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/CommandUseTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; @@ -23,10 +23,10 @@ */ public class CommandUseTable extends Table { - private final String columnCommandId = "id"; - private final String columnCommand = "command"; - private final String columnTimesUsed = "times_used"; - private final String columnServerID = "server_id"; + private static final String columnCommandId = "id"; + private static final String columnCommand = "command"; + private static final String columnTimesUsed = "times_used"; + private static final String columnServerID = "server_id"; private final ServerTable serverTable; private String insertStatement; @@ -42,7 +42,7 @@ public CommandUseTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { ServerTable serverTable = db.getServerTable(); createTable(TableSqlParser.createTable(tableName) .primaryKeyIDColumn(usingMySQL, columnCommandId) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/GeoInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/GeoInfoTable.java index a78a78a543..54da3e2bcc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/GeoInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/GeoInfoTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -21,9 +21,9 @@ */ public class GeoInfoTable extends UserIDTable { - private final String columnIP = "ip"; - private final String columnGeolocation = "geolocation"; - private final String columnLastUsed = "last_used"; + private static final String columnIP = "ip"; + private static final String columnGeolocation = "geolocation"; + private static final String columnLastUsed = "last_used"; private String insertStatement; public GeoInfoTable(SQLDB db) { @@ -39,7 +39,7 @@ public GeoInfoTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnUserID, Sql.INT).notNull() .column(columnIP, Sql.varchar(39)).notNull() @@ -111,7 +111,6 @@ private void updateGeoInfo(UUID uuid, GeoInfo info) throws SQLException { " AND " + columnIP + "=?" + " AND " + columnGeolocation + "=?"; - execute(new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java index 090a54d87a..9ad6f62158 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/KillsTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.PlayerKill; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -21,11 +21,11 @@ */ public class KillsTable extends UserIDTable { - private final String columnKillerUserID = "killer_id"; - private final String columnVictimUserID = "victim_id"; - private final String columnWeapon = "weapon"; - private final String columnDate = "date"; - private final String columnSessionID = "session_id"; + private static final String columnKillerUserID = "killer_id"; + private static final String columnVictimUserID = "victim_id"; + private static final String columnWeapon = "weapon"; + private static final String columnDate = "date"; + private static final String columnSessionID = "session_id"; private final SessionsTable sessionsTable; private String insertStatement; @@ -46,7 +46,7 @@ public KillsTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnKillerUserID, Sql.INT).notNull() .column(columnVictimUserID, Sql.INT).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java index 5ad84c5a47..4e34a202e4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/NicknamesTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; @@ -20,8 +20,8 @@ */ public class NicknamesTable extends UserIDTable { - private final String columnNick = "nickname"; - private final String columnServerID = "server_id"; + private static final String columnNick = "nickname"; + private static final String columnServerID = "server_id"; private final ServerTable serverTable; private String insertStatement; @@ -40,7 +40,7 @@ public NicknamesTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnUserID, Sql.INT).notNull() .column(columnNick, Sql.varchar(75)).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SecurityTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SecurityTable.java index 8070a75183..3ef5bf6a6a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SecurityTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SecurityTable.java @@ -5,7 +5,7 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -28,9 +28,9 @@ */ public class SecurityTable extends Table { - private final String columnUser = "username"; - private final String columnSaltedHash = "salted_pass_hash"; - private final String columnPermLevel = "permission_level"; + private static final String columnUser = "username"; + private static final String columnSaltedHash = "salted_pass_hash"; + private static final String columnPermLevel = "permission_level"; private String insertStatement; public SecurityTable(SQLDB db) { @@ -42,7 +42,7 @@ public SecurityTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnUser, Sql.varchar(100)).notNull().unique() .column(columnSaltedHash, Sql.varchar(100)).notNull().unique() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java index 53e8e36dce..b520fc7e64 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/ServerTable.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; @@ -37,12 +37,12 @@ public class ServerTable extends Table { public final String statementSelectServerID; public final String statementSelectServerNameID; - private final String columnServerID = "id"; - private final String columnServerUUID = "uuid"; - private final String columnServerName = "name"; - private final String columnWebserverAddress = "web_address"; - private final String columnInstalled = "is_installed"; - private final String columnMaxPlayers = "max_players"; + private static final String columnServerID = "id"; + private static final String columnServerUUID = "uuid"; + private static final String columnServerName = "name"; + private static final String columnWebserverAddress = "web_address"; + private static final String columnInstalled = "is_installed"; + private static final String columnMaxPlayers = "max_players"; private String insertStatement; public ServerTable(SQLDB db) { @@ -58,7 +58,7 @@ public ServerTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .primaryKeyIDColumn(usingMySQL, columnServerID) .column(columnServerUUID, Sql.varchar(36)).notNull().unique() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java index b1c15cd2dc..eb9a8e10d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/SessionsTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -24,12 +24,12 @@ */ public class SessionsTable extends UserIDTable { - private final String columnID = "id"; - private final String columnSessionStart = "session_start"; - private final String columnSessionEnd = "session_end"; - private final String columnServerID = "server_id"; - private final String columnMobKills = "mob_kills"; - private final String columnDeaths = "deaths"; + private static final String columnID = "id"; + private static final String columnSessionStart = "session_start"; + private static final String columnSessionEnd = "session_end"; + private static final String columnServerID = "server_id"; + private static final String columnMobKills = "mob_kills"; + private static final String columnDeaths = "deaths"; private final ServerTable serverTable; private String insertStatement; @@ -51,7 +51,7 @@ public SessionsTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(this.tableName) .primaryKeyIDColumn(usingMySQL, columnID) .column(columnUserID, Sql.INT).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java index aed83bb46d..84f87de8b8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -28,14 +28,14 @@ */ public class TPSTable extends Table { - private final String columnServerID = "server_id"; - private final String columnDate = "date"; - private final String columnTPS = "tps"; - private final String columnPlayers = "players_online"; - private final String columnCPUUsage = "cpu_usage"; - private final String columnRAMUsage = "ram_usage"; - private final String columnEntities = "entities"; - private final String columnChunksLoaded = "chunks_loaded"; + private static final String columnServerID = "server_id"; + private static final String columnDate = "date"; + private static final String columnTPS = "tps"; + private static final String columnPlayers = "players_online"; + private static final String columnCPUUsage = "cpu_usage"; + private static final String columnRAMUsage = "ram_usage"; + private static final String columnEntities = "entities"; + private static final String columnChunksLoaded = "chunks_loaded"; private final ServerTable serverTable; private String insertStatement; @@ -58,7 +58,7 @@ public TPSTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnServerID, Sql.INT).notNull() .column(columnDate, Sql.LONG).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java index 9c776105f7..4e23ed6a4b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; @@ -50,13 +50,13 @@ public Table(String name, SQLDB db) { this.usingMySQL = db.isUsingMySQL(); } - public abstract void createTable() throws DBCreateTableException; + public abstract void createTable() throws DBInitException; - protected void createTable(String sql) throws DBCreateTableException { + protected void createTable(String sql) throws DBInitException { try { execute(sql); } catch (SQLException e) { - throw new DBCreateTableException(tableName, "Failed to create table", e); + throw new DBInitException("Failed to create table: " + tableName, e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java index 015ec0a5f3..d49825f8f7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement; @@ -33,16 +33,16 @@ */ public class TransferTable extends Table { - private final String columnSenderID = "sender_server_id"; - private final String columnExpiry = "expiry_date"; - private final String columnInfoType = "type"; - private final String columnContent = "content_64"; - private final String columnExtraVariables = "extra_variables"; + private static final String columnSenderID = "sender_server_id"; + private static final String columnExpiry = "expiry_date"; + private static final String columnInfoType = "type"; + private static final String columnContent = "content_64"; + private static final String columnExtraVariables = "extra_variables"; private final ServerTable serverTable; private final String insertStatement; - private String selectStatement; + private final String selectStatement; public TransferTable(SQLDB db) { super("plan_transfer", db); @@ -64,7 +64,7 @@ public TransferTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnSenderID, Sql.INT).notNull() .column(columnExpiry, Sql.LONG).notNull().defaultValue("0") diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java index d836baa9f5..f497a2a880 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UserInfoTable.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -31,10 +31,10 @@ */ public class UserInfoTable extends UserIDTable { - private final String columnRegistered = "registered"; - private final String columnOP = "opped"; - private final String columnBanned = "banned"; - private final String columnServerID = "server_id"; + private static final String columnRegistered = "registered"; + private static final String columnOP = "opped"; + private static final String columnBanned = "banned"; + private static final String columnServerID = "server_id"; private final ServerTable serverTable; @@ -44,7 +44,7 @@ public UserInfoTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnUserID, Sql.INT).notNull() .column(columnRegistered, Sql.LONG).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java index 476e5e268b..9f85c5b9be 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/UsersTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; @@ -20,11 +20,11 @@ public class UsersTable extends UserIDTable { public final String statementSelectID; - private final String columnID = "id"; - private final String columnUUID = "uuid"; - private final String columnRegistered = "registered"; - private final String columnName = "name"; - private final String columnTimesKicked = "times_kicked"; + private static final String columnID = "id"; + private static final String columnUUID = "uuid"; + private static final String columnRegistered = "registered"; + private static final String columnName = "name"; + private static final String columnTimesKicked = "times_kicked"; private String insertStatement; public UsersTable(SQLDB db) { @@ -37,7 +37,7 @@ public UsersTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .primaryKeyIDColumn(usingMySQL, columnID) .column(columnUUID, Sql.varchar(36)).notNull().unique() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/VersionTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/VersionTable.java index 77525036ca..ae2673875e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/VersionTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/VersionTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; @@ -22,7 +22,7 @@ public VersionTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column("version", Sql.INT).notNull() .toString() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java index 9de92e2b99..a7b7b8b019 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; @@ -26,8 +26,8 @@ public class WorldTable extends Table { public final String statementSelectID; - private final String columnWorldId = "id"; - private final String columnWorldName = "world_name"; + private static final String columnWorldId = "id"; + private static final String columnWorldName = "world_name"; public WorldTable(SQLDB db) { super("plan_worlds", db); @@ -35,7 +35,7 @@ public WorldTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .primaryKeyIDColumn(usingMySQL, columnWorldId) .column(columnWorldName, Sql.varchar(100)).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java index e3a0140b90..a607a4864a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/WorldTimesTable.java @@ -1,6 +1,6 @@ package com.djrapitops.plan.system.database.databases.sql.tables; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.time.GMTimes; import com.djrapitops.plan.data.time.WorldTimes; @@ -27,12 +27,12 @@ */ public class WorldTimesTable extends UserIDTable { - private final String columnSessionID = "session_id"; - private final String columnWorldId = "world_id"; - private final String columnSurvival = "survival_time"; - private final String columnCreative = "creative_time"; - private final String columnAdventure = "adventure_time"; - private final String columnSpectator = "spectator_time"; + private static final String columnSessionID = "session_id"; + private static final String columnWorldId = "world_id"; + private static final String columnSurvival = "survival_time"; + private static final String columnCreative = "creative_time"; + private static final String columnAdventure = "adventure_time"; + private static final String columnSpectator = "spectator_time"; private final WorldTable worldTable; private final SessionsTable sessionsTable; @@ -57,7 +57,7 @@ public WorldTimesTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable(TableSqlParser.createTable(tableName) .column(columnUserID, Sql.INT).notNull() .column(columnWorldId, Sql.INT).notNull() diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java index 3bf1ba7486..fd74bbcb69 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/move/Version8TransferTable.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.database.databases.sql.tables.move; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.info.server.ServerInfo; @@ -48,7 +48,7 @@ private String dropTableSql(String name) { return "DROP TABLE " + name; } - public void alterTablesToV10() throws SQLException, DBCreateTableException { + public void alterTablesToV10() throws SQLException, DBInitException { Benchmark.start("Schema copy from 8 to 10"); copyCommandUsage(); @@ -76,7 +76,7 @@ public void alterTablesToV10() throws SQLException, DBCreateTableException { Benchmark.stop("Schema copy from 8 to 10"); } - private void copyUsers() throws SQLException, DBCreateTableException { + private void copyUsers() throws SQLException, DBInitException { String tempTableName = "temp_users"; UsersTable usersTable = db.getUsersTable(); execute(tableRenameSql("plan_users", tempTableName)); @@ -137,7 +137,7 @@ private void copyUsers() throws SQLException, DBCreateTableException { } } - private void copyCommandUsage() throws SQLException, DBCreateTableException { + private void copyCommandUsage() throws SQLException, DBInitException { String tempTableName = "temp_cmdusg"; CommandUseTable commandUseTable = db.getCommandUseTable(); @@ -156,7 +156,7 @@ private void copyCommandUsage() throws SQLException, DBCreateTableException { execute(dropTableSql(tempTableName)); } - private void copyTPS() throws SQLException, DBCreateTableException { + private void copyTPS() throws SQLException, DBInitException { String tempTableName = "temp_tps"; TPSTable tpsTable = db.getTpsTable(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportRefiner.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportRefiner.java index e99dfa97b0..bc250aa1af 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportRefiner.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/UserImportRefiner.java @@ -27,15 +27,15 @@ public class UserImportRefiner { private final Plan plugin; private final boolean onlineMode; - private final List importers = new Vector<>(); + private final List importers = new ArrayList<>(); - private final Map worlds = new Hashtable<>(); + private final Map worlds = new HashMap<>(); - private final Map uuidsMissing = new Hashtable<>(); - private final Map namesMissing = new Hashtable<>(); + private final Map uuidsMissing = new HashMap<>(); + private final Map namesMissing = new HashMap<>(); - private final Map foundUUIDs = new Hashtable<>(); - private final Map foundNames = new Hashtable<>(); + private final Map foundUUIDs = new HashMap<>(); + private final Map foundNames = new HashMap<>(); public UserImportRefiner(Plan plugin, List importers) { this.plugin = plugin; @@ -92,7 +92,7 @@ private void processMissingIdentifiers() { Benchmark.start(benchmarkName); - List invalidData = new Vector<>(); + List invalidData = new ArrayList<>(); importers.parallelStream().forEach(importer -> { String name = importer.getName(); @@ -161,7 +161,7 @@ private void addMissingUUIDsOverFetcher() { } private void addMissingUUIDsOverOfflinePlayer() { - Map result = new Hashtable<>(); + Map result = new HashMap<>(); for (String name : uuidsMissing.values()) { String uuid = getUuidByOfflinePlayer(name); @@ -177,7 +177,7 @@ private void addMissingUUIDsOverOfflinePlayer() { } private void addFoundUUIDs(Map foundUUIDs) { - List found = new Vector<>(); + List found = new ArrayList<>(); uuidsMissing.entrySet().parallelStream().forEach((entry) -> { UserImportData importer = entry.getKey(); @@ -218,7 +218,7 @@ private void processMissingNames() { } private void addMissingNames() { - Map result = new Hashtable<>(); + Map result = new HashMap<>(); namesMissing.values().parallelStream().forEach(uuid -> { String name = getNameByOfflinePlayer(uuid); @@ -230,7 +230,7 @@ private void addMissingNames() { } private void addFoundNames(Map foundNames) { - List found = new Vector<>(); + List found = new ArrayList<>(); namesMissing.entrySet().parallelStream().forEach(entry -> { UserImportData importer = entry.getKey(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java index 72e0e5b2b4..a63cc5588b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/Importer.java @@ -12,6 +12,7 @@ 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.database.databases.operation.SaveOperations; import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.importing.ServerImportData; import com.djrapitops.plan.system.processing.importing.UserImportData; @@ -49,23 +50,17 @@ public final void processImport() { ExecutorService service = Executors.newCachedThreadPool(); - new ImportExecutorHelper() { - @Override - void execute() { - Benchmark.start(serverBenchmarkName); - processServerData(); - Benchmark.stop(serverBenchmarkName); - } - }.submit(service); - - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - Benchmark.start(userDataBenchmarkName); - processUserData(); - Benchmark.stop(userDataBenchmarkName); - } - }.submit(service); + submitTo(service, () -> { + Benchmark.start(serverBenchmarkName); + processServerData(); + Benchmark.stop(serverBenchmarkName); + }); + + submitTo(service, () -> { + Benchmark.start(userDataBenchmarkName); + processUserData(); + Benchmark.stop(userDataBenchmarkName); + }); service.shutdown(); @@ -96,27 +91,16 @@ private void processServerData() { return; } - Plan plugin = Plan.getInstance(); UUID uuid = ServerInfo.getServerUUID(); - Database db = plugin.getDB(); + Database db = Database.getActive(); ExecutorService service = Executors.newCachedThreadPool(); Benchmark.start(insertDataIntoDatabaseBenchmarkName); - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - db.save().insertTPS(ImmutableMap.of(uuid, serverImportData.getTpsData())); - } - }.submit(service); - - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - db.save().insertCommandUsage(ImmutableMap.of(uuid, serverImportData.getCommandUsages())); - } - }.submit(service); + SaveOperations save = db.save(); + submitTo(service, () -> save.insertTPS(ImmutableMap.of(uuid, serverImportData.getTpsData()))); + submitTo(service, () -> save.insertCommandUsage(ImmutableMap.of(uuid, serverImportData.getCommandUsages()))); service.shutdown(); @@ -148,25 +132,23 @@ private void processUserData() throws DBException { return; } - Plan plugin = Plan.getInstance(); - - UserImportRefiner userImportRefiner = new UserImportRefiner(plugin, userImportData); + UserImportRefiner userImportRefiner = new UserImportRefiner(Plan.getInstance(), userImportData); userImportData = userImportRefiner.refineData(); UUID serverUUID = ServerInfo.getServerUUID(); - Database db = plugin.getDB(); + Database db = Database.getActive(); Set existingUUIDs = db.fetch().getSavedUUIDs(); Set existingUserInfoTableUUIDs = db.fetch().getSavedUUIDs(serverUUID); Benchmark.start(insertDataIntoCollectionsBenchmarkName); - Map users = new Hashtable<>(); - List userInfo = new Vector<>(); - Map> nickNames = new Hashtable<>(); - Map> sessions = new Hashtable<>(); - Map> geoInfo = new Hashtable<>(); - Map timesKicked = new Hashtable<>(); + Map users = new HashMap<>(); + List userInfo = new ArrayList<>(); + Map> nickNames = new HashMap<>(); + Map> sessions = new HashMap<>(); + Map> geoInfo = new HashMap<>(); + Map timesKicked = new HashMap<>(); userImportData.parallelStream().forEach(data -> { UUID uuid = data.getUuid(); @@ -192,42 +174,14 @@ private void processUserData() throws DBException { Benchmark.start(insertDataIntoDatabaseBenchmarkName); - db.save().insertUsers(users); - - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - db.save().insertSessions(ImmutableMap.of(serverUUID, sessions), true); - } - }.submit(service); - - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - db.save().kickAmount(timesKicked); - } - }.submit(service); - - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - db.save().insertUserInfo(ImmutableMap.of(serverUUID, userInfo)); - } - }.submit(service); + SaveOperations save = db.save(); - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - db.save().insertNicknames(ImmutableMap.of(serverUUID, nickNames)); - } - }.submit(service); - - new ImportExecutorHelper() { - @Override - void execute() throws DBException { - db.save().insertAllGeoInfo(geoInfo); - } - }.submit(service); + save.insertUsers(users); + submitTo(service, () -> save.insertSessions(ImmutableMap.of(serverUUID, sessions), true)); + submitTo(service, () -> save.kickAmount(timesKicked)); + submitTo(service, () -> save.insertUserInfo(ImmutableMap.of(serverUUID, userInfo))); + submitTo(service, () -> save.insertNicknames(ImmutableMap.of(serverUUID, nickNames))); + submitTo(service, () -> save.insertAllGeoInfo(geoInfo)); service.shutdown(); @@ -242,6 +196,10 @@ void execute() throws DBException { Benchmark.stop(benchmarkName); } + private void submitTo(ExecutorService service, ImportExecutorHelper helper) { + helper.submit(service); + } + private UserInfo toUserInfo(UserImportData userImportData) { UUID uuid = userImportData.getUuid(); String name = userImportData.getName(); @@ -274,10 +232,10 @@ private List convertGeoInfo(UserImportData userImportData) { }).collect(Collectors.toList()); } - private abstract class ImportExecutorHelper { - abstract void execute() throws DBException; + private interface ImportExecutorHelper { + void execute() throws DBException; - void submit(ExecutorService service) { + default void submit(ExecutorService service) { service.submit(new Runnable() { @Override public void run() { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/OfflinePlayerImporter.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/OfflinePlayerImporter.java index c61bb1b88a..527aeb8e7e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/OfflinePlayerImporter.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/importing/importers/OfflinePlayerImporter.java @@ -9,10 +9,10 @@ import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; -import java.util.Vector; /** * @author Fuzzlemann @@ -32,7 +32,7 @@ public ServerImportData getServerImportData() { @Override public List getUserImportData() { - List dataList = new Vector<>(); + List dataList = new ArrayList<>(); Set operators = Bukkit.getOperators(); Set banned = Bukkit.getBannedPlayers(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java index eb1b374207..397b758627 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/ThemeConfig.java @@ -69,17 +69,14 @@ private static String getFileLocation(String fileName) { } } - private static File getConfigFile() throws IOException { File folder = PlanPlugin.getInstance().getDataFolder(); if (!folder.exists()) { folder.mkdirs(); } File themeFile = new File(folder, "theme.yml"); - if (!themeFile.exists()) { - if (!themeFile.createNewFile()) { - throw new FileNotFoundException("Failed to create theme.yml"); - } + if (!themeFile.exists() && !themeFile.createNewFile()) { + throw new FileNotFoundException("Failed to create theme.yml"); } return themeFile; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index 24e925518a..23f784a7c8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plan.utilities.html.HtmlUtils; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Check; @@ -44,6 +45,12 @@ public class WebServer implements SubSystem { private RequestHandler requestHandler; private ResponseHandler responseHandler; + public static WebServer getInstance() { + WebServer webServer = WebServerSystem.getInstance().getWebServer(); + NullCheck.check(webServer, new IllegalStateException("WebServer was not initialized.")); + return webServer; + } + @Override public void enable() throws EnableException { this.port = Settings.WEBSERVER_PORT.getNumber(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java index c34714ed1a..d129636c24 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/DebugPageResponse.java @@ -115,7 +115,7 @@ private void appendServerInformation(StringBuilder content) { .append(" ").append(variable.getVersion()); content.append("
    "); - Database database = plugin.getDB(); + Database database = Database.getActive(); content.append("**Database:** ").append(database.getName()); if (database instanceof SQLDB) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java index 5b5a629618..e7acec9018 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/webapi/bukkit/ConfigurationWebAPI.java @@ -5,12 +5,12 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.settings.ServerSpecificSettings; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.webapi.WebAPI; import com.djrapitops.plugin.api.Check; @@ -50,7 +50,7 @@ public void sendRequest(String address, UUID serverUUID, String accessKey) throw if (accessKey != null) { addVariable("accessKey", accessKey); } - addVariable("webAddress", PlanBungee.getInstance().getWebServer().getAccessAddress()); + addVariable("webAddress", WebServer.getInstance().getAccessAddress()); sendRequest(address, serverUUID); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 580365fc8c..c517894828 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -70,49 +70,8 @@ private AnalysisData runAnalysis() throws Exception { return analyze(); } - private AnalysisData analyze() throws Exception { - log(Locale.get(Msg.ANALYSIS_FETCH).toString()); - Benchmark.start("Fetch Phase"); - Log.logDebug("Database", "Analysis Fetch"); - Log.logDebug("Analysis", "Analysis Fetch Phase"); - try { - Benchmark.start("Create Empty dataset"); - - AnalysisData analysisData = new AnalysisData(); - - Benchmark.stop("Analysis", "Create Empty dataset"); - Benchmark.start("Fetch Phase"); - ServerProfile profile = database.fetch().getServerProfile(serverUUID); - if (analysingThisServer) { - profile.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions())); - } - serverProfile = profile; - - updatePlayerNameCache(profile); - - long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase"); - setBannedByPlugins(profile); - - Benchmark.start("Analysis Phase"); - Log.logDebug("Analysis", "Analysis Phase"); - - log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(profile.getPlayerCount(), fetchPhaseLength)); - - analysisData.analyze(profile); - - Benchmark.stop("Analysis", "Analysis Phase"); - - log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString()); - Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)"); - analysisData.parsePluginsSection(analyzeAdditionalPluginData(profile.getUuids())); - return analysisData; - } finally { - refreshDate = MiscUtils.getTime(); - long time = Benchmark.stop("Analysis", "Analysis"); - Log.logDebug("Analysis"); - Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(time, "")); - serverProfile = null; - } + private static void updateRefreshDate() { + Analysis.refreshDate = MiscUtils.getTime(); } private void updatePlayerNameCache(ServerProfile profile) { @@ -185,4 +144,53 @@ private Map analyzeAdditionalPluginData(Set public static boolean isAnalysisBeingRun() { return serverProfile != null; } + + private static void setServerProfile(ServerProfile serverProfile) { + Analysis.serverProfile = serverProfile; + } + + private AnalysisData analyze() throws Exception { + log(Locale.get(Msg.ANALYSIS_FETCH).toString()); + Benchmark.start("Fetch Phase"); + Log.logDebug("Database", "Analysis Fetch"); + Log.logDebug("Analysis", "Analysis Fetch Phase"); + try { + Benchmark.start("Create Empty dataset"); + + AnalysisData analysisData = new AnalysisData(); + + Benchmark.stop("Analysis", "Create Empty dataset"); + Benchmark.start("Fetch Phase"); + ServerProfile server = database.fetch().getServerProfile(serverUUID); + if (analysingThisServer) { + server.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions())); + } + Analysis.setServerProfile(server); + + updatePlayerNameCache(server); + + long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase"); + setBannedByPlugins(server); + + Benchmark.start("Analysis Phase"); + Log.logDebug("Analysis", "Analysis Phase"); + + log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(server.getPlayerCount(), fetchPhaseLength)); + + analysisData.analyze(server); + + Benchmark.stop("Analysis", "Analysis Phase"); + + log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString()); + Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)"); + analysisData.parsePluginsSection(analyzeAdditionalPluginData(server.getUuids())); + return analysisData; + } finally { + Analysis.updateRefreshDate(); + long time = Benchmark.stop("Analysis", "Analysis"); + Log.logDebug("Analysis"); + Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(time, "")); + Analysis.setServerProfile(null); + } + } } 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 c8e51412e9..91a65dbf6a 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 @@ -19,6 +19,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.*; /** @@ -116,7 +117,7 @@ private void exportCss() { "web/css/style.css", "web/css/themes/all-themes.css" }; - copyFromJar(resources, true); + copyFromJar(resources); } private void exportJs() { @@ -138,7 +139,7 @@ private void exportJs() { "web/js/charts/worldPie.js", "web/js/charts/healthGauge.js" }; - copyFromJar(resources, false); + copyFromJar(resources); try { String demo = FileUtil.getStringFromResource("web/js/demo.js") @@ -164,27 +165,28 @@ private void exportPlugins() { "web/plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js", "web/plugins/jquery-datatable/jquery.dataTables.js" }; - copyFromJar(resources, true); + copyFromJar(resources); } - private void copyFromJar(String[] resources, boolean overwrite) { + private void copyFromJar(String[] resources) { for (String resource : resources) { try { - copyFromJar(resource, overwrite); + copyFromJar(resource); } catch (IOException e) { Log.toLog(this.getClass().getName(), e); } } } - private void copyFromJar(String resource, boolean overwrite) throws IOException { + private void copyFromJar(String resource) throws IOException { String possibleFile = resource.replace("web/", "").replace("/", File.separator); List lines = FileUtil.lines(plugin, new File(plugin.getDataFolder(), possibleFile), resource); String outputFile = possibleFile.replace("web/", ""); File to = new File(outputFolder, outputFile); to.getParentFile().mkdirs(); if (to.exists()) { - if (!to.delete() || !to.createNewFile()) { + Files.delete(to.toPath()); + if (to.createNewFile()) { return; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java index 0b033649a1..b826c875fc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/AnalysisPluginsTabContentCreator.java @@ -36,7 +36,7 @@ public static String[] createContent(Map containe generalTab.append("
    "); - boolean hasGeneralBoxes = false; + boolean displayGeneralTab = false; for (PluginData pluginData : order) { AnalysisContainer container = containers.get(pluginData); @@ -48,20 +48,19 @@ public static String[] createContent(Map containe case WHOLE: if (!container.hasOnlyValues()) { appendWhole(pluginData, container, generalTab); - hasGeneralBoxes = true; - break; + displayGeneralTab = true; } - + break; case TWO_THIRDS: if (!container.hasOnlyValues()) { appendTwoThirds(pluginData, container, generalTab); - hasGeneralBoxes = true; - break; + displayGeneralTab = true; } + break; case THIRD: default: appendThird(pluginData, container, generalTab); - hasGeneralBoxes = true; + displayGeneralTab = true; break; } } @@ -80,9 +79,9 @@ public static String[] createContent(Map containe "
    "; return new String[]{ - (hasGeneralBoxes ? "
  • General
  • " : "") + (displayGeneralTab ? "
  • General
  • " : "") + "
  • Player Data
  • " + nav.toString(), - (hasGeneralBoxes ? generalTab.toString() : "") + playerListTab + otherTabs.toString() + (displayGeneralTab ? generalTab.toString() : "") + playerListTab + otherTabs.toString() }; } 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 6c65caf4d9..751e0fdbd9 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 @@ -1,9 +1,10 @@ package com.djrapitops.plan.utilities.metrics; - import com.djrapitops.plan.Plan; +import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.info.connection.ConnectionSystem; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.webserver.WebServer; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; @@ -32,7 +33,7 @@ private void registerConfigSettingGraphs() { if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) { serverType = "Spigot"; } - String databaseType = plugin.getDB().getName(); + String databaseType = Database.getActive().getName(); String analysisRefreshPeriod = Integer.toString(Settings.ANALYSIS_AUTO_REFRESH.getNumber()); String themeBase = Settings.THEME_BASE.toString(); @@ -52,7 +53,7 @@ private void addFeatureBarChart(String id) { metrics.addCustomChart(new Metrics.AdvancedBarChart(id, () -> { Map map = new HashMap<>(); - map.put("HTTPS", isEnabled("HTTPS".equals(plugin.getWebServer().getProtocol().toUpperCase()))); + map.put("HTTPS", isEnabled("HTTPS".equals(WebServer.getInstance().getProtocol().toUpperCase()))); map.put("HTML Export", isEnabled(Settings.ANALYSIS_EXPORT.isTrue())); boolean isConnectedToBungee = ConnectionSystem.getInstance().isServerAvailable(); map.put("BungeeCord Connected", isEnabled(isConnectedToBungee)); diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java index dc71114ff8..258903f11d 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/AdvancedAntiCheatHook.java @@ -5,7 +5,7 @@ package com.djrapitops.pluginbridge.plan.aac; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -35,7 +35,7 @@ public void hook() throws NoClassDefFoundError { HackerTable table = new HackerTable((SQLDB) Database.getActive()); try { table.createTable(); - } catch (DBCreateTableException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); return; } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java index 1d1b8b4215..35a6eb97a3 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/aac/HackerTable.java @@ -5,7 +5,7 @@ */ package com.djrapitops.pluginbridge.plan.aac; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; @@ -41,7 +41,7 @@ public HackerTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnUUID + " varchar(36) NOT NULL, " + columnDate + " bigint NOT NULL, " diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java index 95bc1242f7..8373af1b7e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/protocolsupport/ProtocolSupportHook.java @@ -5,7 +5,7 @@ package com.djrapitops.pluginbridge.plan.protocolsupport; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -35,7 +35,7 @@ public void hook() throws NoClassDefFoundError { ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive()); try { table.createTable(); - } catch (DBCreateTableException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); return; } diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java index 6d810f4a3a..2f798fe02e 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ProtocolTable.java @@ -5,7 +5,7 @@ */ package com.djrapitops.pluginbridge.plan.viaversion; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement; import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement; @@ -38,7 +38,7 @@ public ProtocolTable(SQLDB db) { } @Override - public void createTable() throws DBCreateTableException { + public void createTable() throws DBInitException { createTable("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnUUID + " varchar(36) NOT NULL UNIQUE, " + columnProtocolVersion + " integer NOT NULL" diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java index 8fb7612ba4..b1aba12ded 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/viaversion/ViaVersionHook.java @@ -1,7 +1,7 @@ package com.djrapitops.pluginbridge.plan.viaversion; import com.djrapitops.plan.Plan; -import com.djrapitops.plan.api.exceptions.database.DBCreateTableException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -40,7 +40,7 @@ public void hook() throws NoClassDefFoundError { ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive()); try { table.createTable(); - } catch (DBCreateTableException e) { + } catch (DBException e) { Log.toLog(this.getClass().getName(), e); return; } From 3df0d4f88dd9c0820fab5e0c1aa1a2a705ee9a25 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 10:42:04 +0200 Subject: [PATCH 077/166] Fixes NoSuchMethod on Spigot (#514) --- .../com/djrapitops/plan/system/tasks/BukkitTaskSystem.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index 839907a529..4ced6e0cf4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -11,7 +11,6 @@ import com.djrapitops.plan.system.tasks.bukkit.*; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.ITask; @@ -29,7 +28,9 @@ public class BukkitTaskSystem extends TaskSystem { private final Plan plugin; public BukkitTaskSystem(Plan plugin) { - tpsCountTimer = Check.isPaperAvailable() + String serverName = plugin.getServer().getServerName(); + boolean isPaper = serverName.equals("Paper") || serverName.equals("TacoSpigot"); + tpsCountTimer = isPaper ? new PaperTPSCountTimer(plugin) : new BukkitTPSCountTimer(plugin); From d697c4875c2572be4a9b8c3001df9f8f91b7affe Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 21:14:41 +0200 Subject: [PATCH 078/166] Fixed RedProtect API call in PluginBridge (#502) --- PlanPluginBridge/pom.xml | 8 ++++++-- .../pluginbridge/plan/redprotect/RedProtectData.java | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/PlanPluginBridge/pom.xml b/PlanPluginBridge/pom.xml index 16dce44b83..90547f22f5 100644 --- a/PlanPluginBridge/pom.xml +++ b/PlanPluginBridge/pom.xml @@ -57,6 +57,10 @@ jitpack.io https://jitpack.io + + redprotect-repo + https://raw.github.com/FabioZumbi12/RedProtect/mvn-repo/ + viaversion-repo https://repo.viaversion.com @@ -189,8 +193,8 @@ br.net.fabiozumbi12.RedProtect - RedProtect - 7.3.0 + RedProtect-Spigot + RELEASE provided diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java index b3bc1cde3b..d2dde28150 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/redprotect/RedProtectData.java @@ -4,8 +4,8 @@ */ package com.djrapitops.pluginbridge.plan.redprotect; -import br.net.fabiozumbi12.RedProtect.API.RedProtectAPI; -import br.net.fabiozumbi12.RedProtect.Region; +import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect; +import br.net.fabiozumbi12.RedProtect.Bukkit.Region; import com.djrapitops.plan.data.element.AnalysisContainer; import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.element.TableContainer; @@ -32,7 +32,7 @@ public RedProtectData() { @Override public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { - Set regions = RedProtectAPI.getPlayerRegions(uuid.toString()); + Set regions = RedProtect.get().getAPI().getPlayerRegions(uuid.toString()); inspectContainer.addValue(getWithIcon("Regions", "map-marker", "red"), regions.size()); @@ -51,7 +51,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain @Override public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { - Set regions = RedProtectAPI.getAllRegions(); + Set regions = RedProtect.get().getAPI().getAllRegions(); analysisContainer.addValue(getWithIcon("All Regions", "map-marker", "red"), regions.size()); From 2e6ca6aa8e819d4064dbf6749d0227834083071e Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 21:19:07 +0200 Subject: [PATCH 079/166] Fixed Bad ID values in Plugin Accordions (#504) --- .../plan/factions/FactionAccordionCreator.java | 13 ++++++------- .../plan/kingdoms/KingdomAccordionCreator.java | 10 +++++----- .../plan/towny/TownAccordionCreator.java | 8 ++++---- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java index f9f378f3b4..f7c623ac39 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionAccordionCreator.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -55,7 +55,6 @@ public static String createAccordion(List factions) { } } - List memberProfiles = players.stream().filter(p -> members.contains(p.getUniqueId())).collect(Collectors.toList()); List sessions = memberProfiles.stream() @@ -69,21 +68,21 @@ public static String createAccordion(List factions) { String separated = HtmlStructure.separateWithDots(("Power: " + powerString), leaderName); - String htmlID = "faction_" + createdAtMillis; + String htmlID = "faction_" + factionName + "_" + createdAtMillis; // Accordion panel header html.append("
    ") .append("
    ") .append("

    ") - .append("") + .append("") .append(factionName).append("").append(separated).append("") // Title (header) .append("

    ") // Closes collapsed, panel title .append("
    "); // Closes panel heading // Content - html.append("
    ") .append("
    ") .append("
    ") // Left col-6 diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomAccordionCreator.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomAccordionCreator.java index a88f6d883e..04bad77b21 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomAccordionCreator.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/kingdoms/KingdomAccordionCreator.java @@ -22,7 +22,7 @@ public class KingdomAccordionCreator { public static String createAccordion(Map kingdoms) { - StringBuilder html = new StringBuilder("
    "); + StringBuilder html = new StringBuilder("
    "); ServerProfile serverProfile = Analysis.getServerProfile(); List players = serverProfile != null ? serverProfile.getPlayers() : new ArrayList<>(); @@ -60,15 +60,15 @@ public static String createAccordion(Map kingdoms) { html.append("
    ") .append("
    ") .append("

    ") - .append("") + .append("") .append(kingdomName).append("").append(separated).append("") // Title (header) .append("

    ") // Closes collapsed, panel title .append("
    "); // Closes panel heading // Content - html.append("
    ") .append("
    ") .append("
    "); // Left col-6 diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java index c20065ac77..0ac75367e5 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/towny/TownAccordionCreator.java @@ -75,15 +75,15 @@ public static String createAccordion(List towns) { html.append("
    ") .append("
    ") .append("

    ") - .append("") + .append("") .append(townName).append("").append(separated).append("") // Title (header) .append("

    ") // Closes collapsed, panel title .append("
    "); // Closes panel heading // Content - html.append("
    ") .append("
    ") .append("
    ") // Left col-6 From f9883473f503aa42e3b2f4795cb39e9447450e5a Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 21:26:33 +0200 Subject: [PATCH 080/166] Fixed NPE related to Factions (#486) --- .../plan/factions/FactionsData.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java index 71d8ab741f..06046a08be 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java @@ -1,4 +1,4 @@ -/* +/* * 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 */ @@ -36,20 +36,27 @@ public FactionsData() { public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { MPlayer mPlayer = MPlayer.get(uuid); + if (mPlayer == null) { + return inspectContainer; + } + if (mPlayer.hasFaction()) { Faction faction = mPlayer.getFaction(); - String factionName = faction.isNone() ? "-" : faction.getName(); - double power = mPlayer.getPower(); - double maxPower = mPlayer.getPowerMax(); - String powerString = FormatUtils.cutDecimals(power) + " / " + FormatUtils.cutDecimals(maxPower); - String factionLeader = faction.getLeader().getName(); - String factionLeaderLink = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(factionLeader), factionLeader); - - inspectContainer.addValue(getWithIcon("Faction", "flag", "deep-purple"), factionName); - inspectContainer.addValue(getWithIcon("Power", "bolt", "purple"), powerString); - inspectContainer.addValue(getWithIcon("Leader", "user", "purple"), factionLeaderLink); + if (faction != null) { + String factionName = faction.isNone() ? "-" : faction.getName(); + String factionLeader = faction.getLeader().getName(); + String factionLeaderLink = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(factionLeader), factionLeader); + + inspectContainer.addValue(getWithIcon("Faction", "flag", "deep-purple"), factionName); + inspectContainer.addValue(getWithIcon("Leader", "user", "purple"), factionLeaderLink); + } } + double power = mPlayer.getPower(); + double maxPower = mPlayer.getPowerMax(); + String powerString = FormatUtils.cutDecimals(power) + " / " + FormatUtils.cutDecimals(maxPower); + inspectContainer.addValue(getWithIcon("Power", "bolt", "purple"), powerString); + return inspectContainer; } From f0efc39c833f6ecf520d0576fca32d85f79af93d Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 21:31:19 +0200 Subject: [PATCH 081/166] Litebans PluginData no longer uses hardcoded table prefix (#480) --- .../plan/litebans/LiteBansDatabaseQueries.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java index fffa1be1a5..39cc800fa9 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansDatabaseQueries.java @@ -2,6 +2,7 @@ import com.djrapitops.plan.system.database.databases.sql.tables.Table; import litebans.api.Database; +import org.bukkit.Bukkit; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -18,17 +19,20 @@ */ public class LiteBansDatabaseQueries extends Table { private final Database database; + private String litebansTable; public LiteBansDatabaseQueries() { super("litebans", null); database = Database.get(); + String tablePrefix = Bukkit.getPluginManager().getPlugin("LiteBans").getConfig().getString("sql.table_prefix"); + litebansTable = tablePrefix + "bans"; } public List getBans() throws SQLException { PreparedStatement statement = null; ResultSet set = null; try { - statement = database.prepareStatement("SELECT uuid, reason, banned_by_name, until FROM litebans_bans"); + statement = database.prepareStatement("SELECT uuid, reason, banned_by_name, until FROM " + litebansTable); set = statement.executeQuery(); return getBanObjects(set); } finally { @@ -59,7 +63,7 @@ public List getBans(UUID playerUUID) throws SQLException { PreparedStatement statement = null; ResultSet set = null; try { - statement = database.prepareStatement("SELECT uuid, reason, banned_by_name, until FROM litebans_bans WHERE uuid=?"); + statement = database.prepareStatement("SELECT uuid, reason, banned_by_name, until FROM " + litebansTable + " WHERE uuid=?"); statement.setString(1, playerUUID.toString()); set = statement.executeQuery(); return getBanObjects(set); From 547b1914644cbd21406781ec17d8df25943929d6 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 21:45:23 +0200 Subject: [PATCH 082/166] Added support for GriefPreventionPlus (#494) --- PlanPluginBridge/pom.xml | 7 ++ .../plus/GriefPreventionPlusData.java | 85 +++++++++++++++++++ .../plus/GriefPreventionPlusHook.java | 37 ++++++++ 3 files changed, 129 insertions(+) create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusData.java create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusHook.java diff --git a/PlanPluginBridge/pom.xml b/PlanPluginBridge/pom.xml index 90547f22f5..afa4512984 100644 --- a/PlanPluginBridge/pom.xml +++ b/PlanPluginBridge/pom.xml @@ -149,6 +149,13 @@ 16.7.1 provided + + + net.kaikk.mc + GriefPreventionPlus + RELEASE + provided + litebans api diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusData.java new file mode 100644 index 0000000000..37a14527e4 --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusData.java @@ -0,0 +1,85 @@ +/* + * 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.pluginbridge.plan.griefprevention.plus; + +import com.djrapitops.plan.data.element.AnalysisContainer; +import com.djrapitops.plan.data.element.InspectContainer; +import com.djrapitops.plan.data.element.TableContainer; +import com.djrapitops.plan.data.plugin.ContainerSize; +import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.utilities.analysis.MathUtils; +import com.djrapitops.plugin.utilities.FormatUtils; +import net.kaikk.mc.gpp.Claim; +import net.kaikk.mc.gpp.DataStore; +import net.kaikk.mc.gpp.PlayerData; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * PluginData for GriefPreventionPlus plugin. + * + * @author Rsl1122 + */ +public class GriefPreventionPlusData extends PluginData { + + private final DataStore dataStore; + + public GriefPreventionPlusData(DataStore dataStore) { + super(ContainerSize.THIRD, "GriefPreventionPlus"); + super.setPluginIcon("shield"); + super.setIconColor("blue-grey"); + this.dataStore = dataStore; + } + + @Override + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { + Map claims = dataStore.getClaims().values().stream() + .filter(Objects::nonNull) + .filter(claim -> uuid.equals(claim.getOwnerID())) + .collect(Collectors.toMap( + claim -> FormatUtils.formatLocation(claim.getGreaterBoundaryCorner()), + Claim::getArea) + ); + PlayerData data = dataStore.getPlayerData(uuid); + int blocks = data.getAccruedClaimBlocks() + data.getBonusClaimBlocks(); + long totalArea = MathUtils.sumLong(claims.values().stream().map(i -> (long) i)); + + inspectContainer.addValue(getWithIcon("Claims", "map-marker", "blue-grey"), claims.size()); + inspectContainer.addValue(getWithIcon("Claimed Area", "map-o", "light-green"), totalArea); + inspectContainer.addValue(getWithIcon("Claim Blocks Available", "map-o", "light-green"), blocks); + + TableContainer claimsTable = new TableContainer(getWithIcon("Claim", "map-marker"), getWithIcon("Area", "map-o")); + claimsTable.setColor("blue-grey"); + for (Map.Entry entry : claims.entrySet()) { + claimsTable.addRow(entry.getKey(), entry.getValue()); + } + inspectContainer.addTable("claimTable", claimsTable); + + return inspectContainer; + } + + @Override + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) { + Map area = new HashMap<>(); + + for (Claim claim : dataStore.getClaims().values()) { + if (claim == null) { + continue; + } + UUID uuid = claim.getOwnerID(); + int blocks = area.getOrDefault(uuid, 0); + blocks += claim.getArea(); + area.put(uuid, blocks); + } + + long totalArea = MathUtils.sumLong(area.values().stream().map(i -> (long) i)); + analysisContainer.addValue(getWithIcon("Total Claimed Area", "map-o", "blue-grey"), totalArea); + + analysisContainer.addPlayerTableValues(getWithIcon("Claimed Area", "map-o"), area); + + return analysisContainer; + } +} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusHook.java new file mode 100644 index 0000000000..2596bdd42e --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/griefprevention/plus/GriefPreventionPlusHook.java @@ -0,0 +1,37 @@ +package com.djrapitops.pluginbridge.plan.griefprevention.plus; + +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.pluginbridge.plan.Hook; +import net.kaikk.mc.gpp.DataStore; +import net.kaikk.mc.gpp.GriefPreventionPlus; + +import static org.bukkit.plugin.java.JavaPlugin.getPlugin; + +/** + * A Class responsible for hooking to GriefPreventionPlus and registering data + * sources. + * + * @author Rsl1122 + * @since 3.5.0 + */ +public class GriefPreventionPlusHook extends Hook { + + /** + * Hooks the plugin and registers it's PluginData objects. + *

    + * API#addPluginDataSource uses the same method from HookHandler. + * + * @param hookH HookHandler instance for registering the data sources. + * @throws NoClassDefFoundError when the plugin class can not be found. + */ + public GriefPreventionPlusHook(HookHandler hookH) { + super("net.kaikk.mc.gpp.GriefPreventionPlus", hookH); + } + + public void hook() throws NoClassDefFoundError { + if (enabled) { + DataStore dataStore = getPlugin(GriefPreventionPlus.class).getDataStore(); + addPluginDataSource(new GriefPreventionPlusData(dataStore)); + } + } +} From 554eb83efda68b08b882feae545459af2181e68b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 23:01:20 +0200 Subject: [PATCH 083/166] First attempt at BuyCraft support (#475) --- .../plan/system/settings/Settings.java | 1 + Plan/src/main/resources/config.yml | 3 + .../djrapitops/pluginbridge/plan/Bridge.java | 21 +--- .../plan/buycraft/BuyCraftHook.java | 33 +++++++ .../plan/buycraft/BuyCraftPluginData.java | 75 +++++++++++++++ .../plan/buycraft/ListPaymentRequest.java | 95 +++++++++++++++++++ .../pluginbridge/plan/buycraft/Payment.java | 49 ++++++++++ 7 files changed, 260 insertions(+), 17 deletions(-) create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftHook.java create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftPluginData.java create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/ListPaymentRequest.java create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index 1eeb72de32..ff8754fb4e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -61,6 +61,7 @@ public enum Settings { WEBSERVER_CERTIFICATE_STOREPASS("WebServer.Security.SSL-Certificate.StorePass"), WEBSERVER_CERTIFICATE_ALIAS("WebServer.Security.SSL-Certificate.Alias"), EXTERNAL_WEBSERVER_LINK("WebServer.ExternalWebServerAddress"), + PLUGIN_BUYCRAFT_SECRET("Plugins.BuyCraft.Secret"), // SERVER_NAME("Server.ServerName"), // diff --git a/Plan/src/main/resources/config.yml b/Plan/src/main/resources/config.yml index 3e489f4165..3aed780603 100644 --- a/Plan/src/main/resources/config.yml +++ b/Plan/src/main/resources/config.yml @@ -123,3 +123,6 @@ Plugins: Towny: HideTowns: - ExampleTown + BuyCraft: + # http://help.buycraft.net/article/36-where-to-find-the-secret-key + Secret: "-" diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java index fa3d175bd6..13a44d9359 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/Bridge.java @@ -8,9 +8,11 @@ import com.djrapitops.pluginbridge.plan.advancedachievements.AdvancedAchievementsHook; import com.djrapitops.pluginbridge.plan.askyblock.ASkyBlockHook; import com.djrapitops.pluginbridge.plan.banmanager.BanManagerHook; +import com.djrapitops.pluginbridge.plan.buycraft.BuyCraftHook; import com.djrapitops.pluginbridge.plan.essentials.EssentialsHook; import com.djrapitops.pluginbridge.plan.factions.FactionsHook; import com.djrapitops.pluginbridge.plan.griefprevention.GriefPreventionHook; +import com.djrapitops.pluginbridge.plan.griefprevention.plus.GriefPreventionPlusHook; import com.djrapitops.pluginbridge.plan.jobs.JobsHook; import com.djrapitops.pluginbridge.plan.kingdoms.KingdomsHook; import com.djrapitops.pluginbridge.plan.litebans.LiteBansHook; @@ -26,23 +28,6 @@ * Manages connection to other plugins. * * @author Rsl1122 - * @see AdvancedAntiCheatHook - * @see AdvancedAchievementsHook - * @see ASkyBlockHook - * @see BanManagerHook - * @see EssentialsHook - * @see FactionsHook - * @see GriefPreventionHook - * @see JobsHook - * @see KingdomsHook - * @see LiteBansHook - * @see McmmoHook - * @see SuperbVoteHook - * @see ProtocolSupportHook - * @see RedProtectHook - * @see TownyHook - * @see VaultHook - * @see ViaVersionHook */ @SuppressWarnings("WeakerAccess") public class Bridge { @@ -88,9 +73,11 @@ private static Hook[] getBukkitHooks(HookHandler h) { new AdvancedAchievementsHook(h), new ASkyBlockHook(h), new BanManagerHook(h), + new BuyCraftHook(h), new EssentialsHook(h), new FactionsHook(h), new GriefPreventionHook(h), + new GriefPreventionPlusHook(h), new JobsHook(h), new KingdomsHook(h), new LiteBansHook(h), diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftHook.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftHook.java new file mode 100644 index 0000000000..32e366e1b1 --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftHook.java @@ -0,0 +1,33 @@ +/* + * 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.pluginbridge.plan.buycraft; + +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.pluginbridge.plan.Hook; + +/** + * Hook for BuyCraft plugin. + * + * @author Rsl1122 + */ +public class BuyCraftHook extends Hook { + + private final String secret; + + public BuyCraftHook(HookHandler hookHandler) { + super(hookHandler); + + secret = Settings.PLUGIN_BUYCRAFT_SECRET.toString(); + enabled = !secret.equals("-") && !secret.isEmpty(); + } + + @Override + public void hook() throws NoClassDefFoundError { + if (enabled) { + hookHandler.addPluginDataSource(new BuyCraftPluginData(secret)); + } + } +} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftPluginData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftPluginData.java new file mode 100644 index 0000000000..6b83cae0c7 --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftPluginData.java @@ -0,0 +1,75 @@ +/* + * 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.pluginbridge.plan.buycraft; + +import com.djrapitops.plan.api.PlanAPI; +import com.djrapitops.plan.api.exceptions.connection.ForbiddenException; +import com.djrapitops.plan.data.element.AnalysisContainer; +import com.djrapitops.plan.data.element.InspectContainer; +import com.djrapitops.plan.data.element.TableContainer; +import com.djrapitops.plan.data.plugin.ContainerSize; +import com.djrapitops.plan.data.plugin.PluginData; +import com.djrapitops.plan.utilities.FormatUtils; +import com.djrapitops.plan.utilities.html.Html; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * PluginData for BuyCraft plugin. + * + * @author Rsl1122 + */ +public class BuyCraftPluginData extends PluginData { + + private final String secret; + + public BuyCraftPluginData(String secret) { + super(ContainerSize.TWO_THIRDS, "BuyCraft"); + super.setIconColor("blue"); + super.setPluginIcon("shopping-bag"); + + this.secret = secret; + } + + @Override + public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) { + return inspectContainer; + } + + @Override + public AnalysisContainer getServerData(Collection collection, AnalysisContainer analysisContainer) throws Exception { + try { + + List payments = new ListPaymentRequest(secret).makeRequest(); + TableContainer payTable = new TableContainer(true, getWithIcon("Date", "calendar"), getWithIcon("Donation", "money")); + payTable.setColor("blue"); + + for (Payment payment : payments) { + String name = payment.getPlayerName(); + payTable.addRow( + Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), + FormatUtils.formatTimeStampYear(payment.getDate()), + FormatUtils.cutDecimals(payment.getAmount()) + payment.getCurrency() + ); + } + + analysisContainer.addTable("payTable", payTable); + + Map playerTableValues = payments.stream() + .collect(Collectors.toMap(Payment::getUuid, payment -> payment.getAmount() + payment.getCurrency())); + analysisContainer.addPlayerTableValues(getWithIcon("Donation", "money"), playerTableValues); + + } catch (IllegalStateException | NullPointerException e) { + analysisContainer.addValue("JSON error", e.getMessage()); + } catch (ForbiddenException e) { + analysisContainer.addValue("Configuration error", e.getMessage()); + } + return analysisContainer; + } +} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/ListPaymentRequest.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/ListPaymentRequest.java new file mode 100644 index 0000000000..6e9a6002b6 --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/ListPaymentRequest.java @@ -0,0 +1,95 @@ +/* + * 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.pluginbridge.plan.buycraft; + +import com.djrapitops.plan.api.exceptions.connection.ForbiddenException; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.ParsePosition; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * Request to Buycraft API for payment listings. + * + * @author Rsl1122 + */ +public class ListPaymentRequest { + + private final String secret; + + public ListPaymentRequest(String secret) { + this.secret = secret; + } + + public List makeRequest() throws IOException, ForbiddenException { + URL url = new URL("https://plugin.buycraft.net/payments"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("GET"); + connection.setRequestProperty("X-BuyCraft-Secret", secret); + connection.getOutputStream().write(0); + + JsonElement json; + try { + InputStreamReader reader = new InputStreamReader(connection.getInputStream()); + json = new JsonParser().parse(reader); + } finally { + connection.disconnect(); + } + + if (json == null || json.isJsonNull()) { + throw new NullPointerException("JSON should not be null"); + } + + List payments = new ArrayList<>(); + if (json.isJsonObject()) { + return readError(json); + } else if (json.isJsonArray()) { + readAndAddPayments(json, payments); + } + return payments; + } + + private void readAndAddPayments(JsonElement json, List payments) { + JsonArray jsonArray = json.getAsJsonArray(); + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + + for (JsonElement element : jsonArray) { + JsonObject payment = element.getAsJsonObject(); + double amount = payment.get("amount").getAsDouble(); + String dateString = payment.get("date").getAsString(); + long date = dateFormat.parse(dateString, new ParsePosition(0)).getTime(); + String currency = payment.get("currency").getAsJsonObject().get("symbol").getAsString(); + JsonObject player = payment.get("player").getAsJsonObject(); + String playerName = player.get("name").getAsString(); + UUID uuid = UUID.fromString(player.get("uuid").getAsString()); + + payments.add(new Payment(amount, currency, uuid, playerName, date)); + } + } + + private List readError(JsonElement json) throws ForbiddenException { + JsonObject jsonObject = json.getAsJsonObject(); + int errorCode = jsonObject.get("error_code").getAsInt(); + String errorMessage = jsonObject.get("error_message").getAsString(); + + if (errorCode == 403) { + throw new ForbiddenException("Incorrect Server Secret. Check config."); + } else { + throw new IllegalStateException(errorCode + ": " + errorMessage); + } + } +} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java new file mode 100644 index 0000000000..ec025b6e8c --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java @@ -0,0 +1,49 @@ +/* + * 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.pluginbridge.plan.buycraft; + +import java.util.UUID; + +/** + * Represents a BuyCraft payment. + * + * @author Rsl1122 + */ +public class Payment { + + private final double amount; + private final String currency; + private final UUID uuid; + private final String playerName; + private final long date; + + public Payment(double amount, String currency, UUID uuid, String playerName, long date) { + this.amount = amount; + this.currency = currency; + this.uuid = uuid; + this.playerName = playerName; + this.date = date; + } + + public double getAmount() { + return amount; + } + + public String getCurrency() { + return currency; + } + + public String getPlayerName() { + return playerName; + } + + public long getDate() { + return date; + } + + public UUID getUuid() { + return uuid; + } +} \ No newline at end of file From bd96978917424acad3d39031a1eea97d02786704 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 29 Jan 2018 23:46:34 +0200 Subject: [PATCH 084/166] Fixed BuyCraft PluginData --- PlanPluginBridge/pom.xml | 4 +- .../plan/buycraft/BuyCraftHook.java | 1 + .../plan/buycraft/BuyCraftPluginData.java | 61 +++++++++++-------- .../plan/buycraft/ListPaymentRequest.java | 25 +++++--- .../pluginbridge/plan/buycraft/Payment.java | 15 ++++- .../plan/buycraft/ListPaymentRequestTest.java | 19 ++++++ 6 files changed, 88 insertions(+), 37 deletions(-) create mode 100644 PlanPluginBridge/src/test/java/com/djrapitops/pluginbridge/plan/buycraft/ListPaymentRequestTest.java diff --git a/PlanPluginBridge/pom.xml b/PlanPluginBridge/pom.xml index afa4512984..d1ffb05426 100644 --- a/PlanPluginBridge/pom.xml +++ b/PlanPluginBridge/pom.xml @@ -219,7 +219,7 @@ maven-install-plugin 2.5.2 - + @@ -1078,7 +1079,7 @@

    Command Usage

    // Chart draw scripts activityPie('activityPie', activitySeries); - activityStackChart('activityStackGraph', activityCategories, activityStackSeries); + stackChart('activityStackGraph', activityCategories, activityStackSeries, 'Players'); worldPie('worldPie', worldSeries, gmSeries); playersChart('playerChartDay', playersOnlineSeries, 3); playersChart('playerChartMonth', playersOnlineSeries, 2); diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java index c6ea8069b3..568265546d 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java @@ -7,7 +7,7 @@ import com.djrapitops.plan.system.settings.locale.Message; import com.djrapitops.plan.system.settings.locale.Msg; import com.djrapitops.plan.utilities.PassEncryptUtil; -import com.djrapitops.plan.utilities.analysis.Point; +import com.djrapitops.plan.utilities.html.graphs.line.Point; import com.google.common.collect.Ordering; import org.junit.Test; import utilities.RandomData; diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/html/graphs/GraphTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/html/graphs/GraphTest.java index 72c953538e..e1960f53a2 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/html/graphs/GraphTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/html/graphs/GraphTest.java @@ -4,14 +4,16 @@ */ package com.djrapitops.plan.utilities.html.graphs; +import com.djrapitops.plan.data.calculation.ActivityIndex; import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.utilities.html.graphs.line.*; +import com.djrapitops.plan.utilities.html.graphs.stack.AbstractStackGraph; import org.junit.Before; import org.junit.Test; +import utilities.RandomData; -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; +import java.util.*; import static org.junit.Assert.assertTrue; @@ -23,11 +25,22 @@ public class GraphTest { private final List tpsList = new ArrayList<>(); + private final TreeMap>> activityData = new TreeMap<>(); @Before public void setUp() { + String[] groups = ActivityIndex.getGroups(); for (int i = 0; i < 10; i++) { tpsList.add(new TPS(i, i, i, i, i, i, i)); + Map> gData = new HashMap<>(); + for (String group : groups) { + Set uuids = new HashSet<>(); + for (int j = 0; j < RandomData.randomInt(1, 20); j++) { + uuids.add(UUID.randomUUID()); + } + gData.put(group, uuids); + } + activityData.put((long) i, gData); } } @@ -53,6 +66,28 @@ public void testLineGraphsForBracketErrors() { } } + @Test + public void testStackGraphsForBracketErrors() { + Settings.FORMAT_DECIMALS.setTemporaryValue("#.##"); + + AbstractStackGraph[] graphs = new AbstractStackGraph[]{ + new ActivityStackGraph(activityData) + }; + + for (AbstractStackGraph graph : graphs) { + System.out.print("Bracket Test: " + graph.getClass().getSimpleName() + " | "); + String series = graph.toHighChartsSeries(); + System.out.println(series); + char[] chars = series.toCharArray(); + assertBracketMatch(chars); + + String labels = graph.toHighChartsLabels(); + System.out.println(labels); + chars = labels.toCharArray(); + assertBracketMatch(chars); + } + } + private void assertBracketMatch(char[] chars) { Stack bracketStack = new Stack<>(); for (int i = 0; i < chars.length; i++) { diff --git a/Plan/src/test/java/utilities/RandomData.java b/Plan/src/test/java/utilities/RandomData.java index 3fba949391..e7204b375e 100644 --- a/Plan/src/test/java/utilities/RandomData.java +++ b/Plan/src/test/java/utilities/RandomData.java @@ -5,7 +5,7 @@ import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.data.container.UserInfo; import com.djrapitops.plan.utilities.PassEncryptUtil; -import com.djrapitops.plan.utilities.analysis.Point; +import com.djrapitops.plan.utilities.html.graphs.line.Point; import org.apache.commons.lang3.RandomStringUtils; import java.util.ArrayList; From a6bd3eadcc20a7a487ab459dfc1652054c48bd2c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 18:07:18 +0200 Subject: [PATCH 096/166] Added a Stack graph for BuyCraft. (Each currency has own series) --- Plan/src/main/resources/web/server.html | 6 +- .../plan/buycraft/BuyCraftData.java | 9 ++ .../plan/buycraft/MoneyStackGraph.java | 130 ++++++++++++++++++ .../pluginbridge/plan/buycraft/Payment.java | 4 +- 4 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/MoneyStackGraph.java diff --git a/Plan/src/main/resources/web/server.html b/Plan/src/main/resources/web/server.html index 0fdb6e44a3..7c7c25657f 100644 --- a/Plan/src/main/resources/web/server.html +++ b/Plan/src/main/resources/web/server.html @@ -31,6 +31,9 @@ + + + @@ -907,9 +910,6 @@

    Command Usage

    - - - diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftData.java index b58bf35f92..5539822da0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/BuyCraftData.java @@ -72,6 +72,15 @@ private void addPlayerTable(AnalysisContainer analysisContainer, List p ); } analysisContainer.addTable("payTable", payTable); + + MoneyStackGraph moneyStackGraph = MoneyStackGraph.create(payments); + String graphHtml = Html.PANEL_BODY.parse("
    ") + + ""; + + analysisContainer.addHtml("moneygraph", graphHtml); } private void addPaymentTotals(AnalysisContainer analysisContainer, List payments) { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/MoneyStackGraph.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/MoneyStackGraph.java new file mode 100644 index 0000000000..f36c67c3b9 --- /dev/null +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/MoneyStackGraph.java @@ -0,0 +1,130 @@ +/* + * 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.pluginbridge.plan.buycraft; + +import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plan.system.settings.theme.ThemeVal; +import com.djrapitops.plan.utilities.MiscUtils; +import com.djrapitops.plan.utilities.html.graphs.stack.AbstractStackGraph; +import com.djrapitops.plan.utilities.html.graphs.stack.StackDataSet; +import com.djrapitops.plugin.api.TimeAmount; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.format.TextStyle; +import java.util.*; + +/** + * Utility for creating Money Stack Graph. + * + * @author Rsl1122 + */ +public class MoneyStackGraph { + + private final AbstractStackGraph stackGraph; + + private MoneyStackGraph(AbstractStackGraph stackGraph) { + this.stackGraph = stackGraph; + } + + public static MoneyStackGraph create(List payments) { + long now = MiscUtils.getTime(); + long oldestDate = payments.isEmpty() ? now : payments.get(payments.size() - 1).getDate(); + + String[] labels = getLabels(now, oldestDate); + Map> stacks = getStacks(payments); + + StackDataSet[] dataSets = getDataSets(labels, stacks); + + return new MoneyStackGraph(new AbstractStackGraph(labels, dataSets)); + } + + private static StackDataSet[] getDataSets(String[] labels, Map> stacks) { + String[] colors = ThemeVal.GRAPH_GM_PIE.getDefaultValue().split(", "); + int maxCol = colors.length; + + List stackDataSets = new ArrayList<>(); + + int i = 0; + for (Map.Entry> entry : stacks.entrySet()) { + String currency = entry.getKey(); + List payments = entry.getValue(); + + List values = sortValuesByLabels(labels, getValueMap(payments)); + + String color = colors[(i) % maxCol]; + + stackDataSets.add(new StackDataSet(values, currency, color)); + + i++; + } + + return stackDataSets.toArray(new StackDataSet[stackDataSets.size()]); + } + + private static List sortValuesByLabels(String[] labels, Map valueMap) { + List values = new ArrayList<>(); + for (String label : labels) { + values.add(valueMap.getOrDefault(label, 0.0)); + } + return values; + } + + private static Map getValueMap(List payments) { + Map valueMap = new HashMap<>(); + for (Payment payment : payments) { + String label = getLabel(payment.getDate()); + Double value = valueMap.getOrDefault(label, 0.0); + valueMap.put(label, value + payment.getAmount()); + } + return valueMap; + } + + private static Map> getStacks(List payments) { + Map> stacks = new HashMap<>(); + for (Payment payment : payments) { + String currency = payment.getCurrency(); + + List dataSetPayments = stacks.getOrDefault(currency, new ArrayList<>()); + dataSetPayments.add(payment); + stacks.put(currency, dataSetPayments); + } + return stacks; + } + + private static String[] getLabels(long now, long oldestDate) { + long oneYearAgo = now - TimeAmount.YEAR.ms(); + + long leftLimit = Math.max(oldestDate, oneYearAgo); + + List labels = new ArrayList<>(); + for (long time = leftLimit; time < now; time += TimeAmount.MONTH.ms()) { + labels.add(getLabel(time)); + } + + return labels.toArray(new String[labels.size()]); + } + + private static String getLabel(long time) { + String locale = Settings.LOCALE.toString(); + Locale usedLocale = locale.equalsIgnoreCase("default") ? Locale.ENGLISH : Locale.forLanguageTag(locale); + ZoneId usedTimeZone = Settings.USE_SERVER_TIME.isTrue() ? ZoneId.systemDefault() : ZoneOffset.UTC; + + LocalDate date = Instant.ofEpochMilli(time).atZone(usedTimeZone).toLocalDate(); + String month = date.getMonth().getDisplayName(TextStyle.FULL, usedLocale); + int year = date.getYear(); + return month + " " + year; + } + + public String toHighChartsLabels() { + return stackGraph.toHighChartsLabels(); + } + + public String toHighChartsSeries() { + return stackGraph.toHighChartsSeries(); + } +} \ No newline at end of file diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java index 4bdf44d4c4..93d97381b0 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/buycraft/Payment.java @@ -9,6 +9,8 @@ /** * Represents a BuyCraft payment. * + * Payments are sorted most recent first by natural ordering. + * * @author Rsl1122 */ public class Payment implements Comparable { @@ -55,6 +57,6 @@ public String getPackages() { @Override public int compareTo(Payment o) { - return this.playerName.toLowerCase().compareTo(o.playerName.toLowerCase()); + return -Long.compare(this.date, o.date); } } \ No newline at end of file From 98d55b2ff2b7aba74ba7840de042873da88408d1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 18:17:53 +0200 Subject: [PATCH 097/166] Added World Name to GameMode slices (#491) --- .../main/resources/web/js/charts/worldPie.js | 19 +++++++++++++++---- .../plan/litebans/LiteBansData.java | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Plan/src/main/resources/web/js/charts/worldPie.js b/Plan/src/main/resources/web/js/charts/worldPie.js index 3d72cc9269..ccca32c8fc 100644 --- a/Plan/src/main/resources/web/js/charts/worldPie.js +++ b/Plan/src/main/resources/web/js/charts/worldPie.js @@ -1,14 +1,25 @@ function worldPie(id, worldSeries, gmSeries) { - Highcharts.chart(id, { + var defaultTitle = ''; + var defaultSubtitle = 'Click the slices to view used GameMode'; + + var chart = Highcharts.chart(id, { chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, - type: 'pie' + type: 'pie', + events: { + drilldown: function (e) { + chart.setTitle({text: '' + e.point.name}, {text: ''}); + }, + drillup: function (e) { + chart.setTitle({text: defaultTitle}, {text: defaultSubtitle}); + } + } }, - title: {text: ''}, + title: {text: defaultTitle}, subtitle: { - text: 'Click the slices to view used GameMode' + text: defaultSubtitle }, plotOptions: { pie: { diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java index 1b844a95e6..23713012eb 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/litebans/LiteBansData.java @@ -53,7 +53,7 @@ public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContain List warns = db.getWarnings(uuid); List kicks = db.getKicks(uuid); if (bans.isEmpty() && mutes.isEmpty() && warns.isEmpty() && kicks.isEmpty()) { - table.addRow("Not Banned/Muted/Warned/Kicked"); + table.addRow("None"); } else { for (LiteBansDBObj ban : bans) { long expiry = ban.getExpiry(); From 44cea6ff45557e3e2a685f96817050f901312379 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 19:15:05 +0200 Subject: [PATCH 098/166] Implemented Settings for Date formatting (#369) --- .../plan/data/calculation/AnalysisData.java | 2 +- .../plan/system/settings/Settings.java | 5 ++ .../webserver/pages/parsing/InspectPage.java | 2 +- .../plan/utilities/FormatUtils.java | 46 +++++++++++++++-- .../plan/utilities/html/HtmlStructure.java | 2 +- .../html/graphs/ActivityStackGraph.java | 2 +- .../utilities/html/tables/KillsTable.java | 2 +- .../html/tables/PlayersTableCreator.java | 2 +- .../html/tables/SessionsTableCreator.java | 2 +- Plan/src/main/resources/config.yml | 11 +++++ .../plan/utilities/FormatUtilsTest.java | 49 +------------------ 11 files changed, 66 insertions(+), 59 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java index a72867e86a..99e57a5606 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/calculation/AnalysisData.java @@ -72,7 +72,7 @@ private void addConstants() { addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE)); addValue("serverName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_")); addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); - addValue("refresh", FormatUtils.formatTimeStamp(refreshDate)); + addValue("refresh", FormatUtils.formatTimeStampClock(refreshDate)); addValue("activityPieColors", Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE)); addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE)); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java index ff8754fb4e..d7b20515a5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/Settings.java @@ -33,6 +33,7 @@ public enum Settings { ORDER_WORLD_PIE_BY_PERC("Customization.Display.OrderWorldPieByPercentage"), PLAYERTABLE_FOOTER("Customization.Display.PlayerTableFooter"), WEBSERVER_DISABLED("WebServer.DisableWebServer"), + FORMAT_DATE_RECENT_DAYS("Customization.Formatting.Dates.RecentDays"), // Integer WEBSERVER_PORT("WebServer.Port"), @@ -65,6 +66,10 @@ public enum Settings { // SERVER_NAME("Server.ServerName"), // + FORMAT_DATE_FULL("Customization.Formatting.Dates.Full"), + FORMAT_DATE_NO_SECONDS("Customization.Formatting.Dates.NoSeconds"), + FORMAT_DATE_CLOCK("Customization.Formatting.Dates.JustClock"), + FORMAT_DATE_RECENT_DAYS_PATTERN("Customization.Formatting.Dates.RecentDays.DatePattern"), FORMAT_YEAR("Customization.Formatting.TimeAmount.Year"), FORMAT_YEARS("Customization.Formatting.TimeAmount.Years"), FORMAT_MONTH("Customization.Formatting.TimeAmount.Month"), diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java index df705c864a..9780dd9891 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/InspectPage.java @@ -79,7 +79,7 @@ public String toHtml() throws ParseException { public String parse(PlayerProfile profile, UUID serverUUID, Map serverNames) throws IOException { long now = MiscUtils.getTime(); - addValue("refresh", FormatUtils.formatTimeStamp(now)); + addValue("refresh", FormatUtils.formatTimeStampClock(now)); addValue("version", MiscUtils.getPlanVersion()); addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index 1cbd9a8dbe..1485785e89 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -1,13 +1,16 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plan.system.settings.Settings; +import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.utilities.Format; import org.apache.commons.lang3.StringUtils; import org.bukkit.Location; import java.text.DecimalFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * @author Rsl1122 @@ -44,16 +47,51 @@ public static String formatTimeAmountDifference(long before, long after) { return formatMilliseconds(Math.abs(after - before)); } - public static String formatTimeStamp(long epochMs) { - return com.djrapitops.plugin.utilities.FormatUtils.formatTimeStamp(epochMs); + public static String formatTimeStampClock(long epochMs) { + String format = Settings.FORMAT_DATE_CLOCK.toString(); + + return format(epochMs, format); + } + + private static String format(long epochMs, String format) { + String locale = Settings.LOCALE.toString(); + Locale usedLocale = locale.equalsIgnoreCase("default") ? Locale.ENGLISH : Locale.forLanguageTag(locale); + SimpleDateFormat dateFormat = new SimpleDateFormat(format, usedLocale); + return dateFormat.format(epochMs); } public static String formatTimeStampSecond(long epochMs) { - return com.djrapitops.plugin.utilities.FormatUtils.formatTimeStampSecond(epochMs); + String format = Settings.FORMAT_DATE_FULL.toString(); + + if (Settings.FORMAT_DATE_RECENT_DAYS.isTrue()) { + format = replaceRecentDays(epochMs, format); + } + + return format(epochMs, format); + } + + private static String replaceRecentDays(long epochMs, String format) { + long now = MiscUtils.getTime(); + + String pattern = Settings.FORMAT_DATE_RECENT_DAYS_PATTERN.toString(); + long fromStartOfDay = now % TimeAmount.DAY.ms(); + if (epochMs > now - fromStartOfDay) { + format = format.replace(pattern, "'Today'"); + } else if (epochMs > now - TimeAmount.DAY.ms() - fromStartOfDay) { + format = format.replace(pattern, "'Yesterday'"); + } else if (epochMs > now - TimeAmount.DAY.ms() * 5L) { + format = format.replace(pattern, "EEEE"); + } + return format; } public static String formatTimeStampYear(long epochMs) { - return com.djrapitops.plugin.utilities.FormatUtils.formatTimeStampYear(epochMs); + String format = Settings.FORMAT_DATE_NO_SECONDS.toString(); + + if (Settings.FORMAT_DATE_RECENT_DAYS.isTrue()) { + format = replaceRecentDays(epochMs, format); + } + return format(epochMs, format); } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index f10aa2af57..3a504e3bb6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -112,7 +112,7 @@ public static String createServerContainer() { int maxPlayers = properties.getMaxPlayers(); int online = properties.getOnlinePlayers(); Optional analysisRefreshDate = Analysis.getRefreshDate(); - String refresh = analysisRefreshDate.map(FormatUtils::formatTimeStamp).orElse("-"); + String refresh = analysisRefreshDate.map(FormatUtils::formatTimeStampClock).orElse("-"); Server server = ServerInfo.getServer(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java index 2f0fb7addb..734505e5e9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java @@ -28,7 +28,7 @@ public ActivityStackGraph(TreeMap>> activityData) { private static String[] getLabels(NavigableSet dates) { return dates.stream() - .map(FormatUtils::formatTimeStamp) + .map(FormatUtils::formatTimeStampYear) .toArray(String[]::new); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java index 057cec7b37..4572357044 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/KillsTable.java @@ -41,7 +41,7 @@ private void addValues(List playerKills) { String name = dataCache.getName(kill.getVictim()); addRow( - FormatUtils.formatTimeStamp(date), + FormatUtils.formatTimeStampYear(date), Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name), kill.getWeapon() ); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java index bcde92aca2..4db1bd9787 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayersTableCreator.java @@ -69,7 +69,7 @@ public static String createTable(List players) { playtime, FormatUtils.formatTimeAmount(playtime), loginTimes, registered, FormatUtils.formatTimeStampYear(registered), - lastSeen, lastSeen != 0 ? FormatUtils.formatTimeStamp(lastSeen) : "-", + lastSeen, lastSeen != 0 ? FormatUtils.formatTimeStampYear(lastSeen) : "-", geoLocation )); } catch (NullPointerException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index 411145da5c..56656b45e6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -79,7 +79,7 @@ public static String[] createTable(Map> sessionsByUser, List } String name = dataCache.getName(uuid); - String start = FormatUtils.formatTimeStamp(session.getSessionStart()); + String start = FormatUtils.formatTimeStampYear(session.getSessionStart()); String length = session.getSessionEnd() != -1 ? FormatUtils.formatTimeAmount(session.getLength()) : "Online"; String world = getLongestWorldPlayed(session); diff --git a/Plan/src/main/resources/config.yml b/Plan/src/main/resources/config.yml index 3aed780603..3b1ef63f0d 100644 --- a/Plan/src/main/resources/config.yml +++ b/Plan/src/main/resources/config.yml @@ -89,6 +89,17 @@ Customization: PlayerTableFooter: true Formatting: DecimalPoints: '#.##' + # Dates settings use Java SimpleDateFormat. + # You can find the patterns & examples here: + # https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html + Dates: + # RecentDays replaces date with Today, Yesterday, Wednesday etc. + RecentDays: true + # Non-regex pattern to replace + DatePattern: 'MMM d YYYY' + Full: 'MMM d YYYY, HH:mm:ss' + NoSeconds: 'MMM d YYYY, HH:mm' + JustClock: 'HH:mm:ss' TimeAmount: Year: '1 year, ' Years: '%years% years, ' diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java index 1ea1b4bb9d..0410e230f8 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java @@ -13,9 +13,7 @@ import utilities.mocks.SystemMockUtil; import utilities.mocks.objects.MockUtils; -import java.text.SimpleDateFormat; import java.util.Date; -import java.util.Locale; import static org.junit.Assert.*; @@ -54,52 +52,7 @@ public void testFormatTimeAmountSinceDate() { } @Test - public void testFormatTimeStamp() { - SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd, HH:mm", Locale.ENGLISH); - - Date date = new Date(); - date.setTime(0); - - String expResult = dateFormat.format(date); - - long epochZero = 0L; - String result = FormatUtils.formatTimeStamp(epochZero); - - assertEquals(expResult, result); - } - - @Test - public void testFormatTimeStampYear() { - SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd YYYY, HH:mm", Locale.ENGLISH); - - Date date = new Date(); - date.setTime(0); - - String expResult = dateFormat.format(date); - - long epochZero = 0L; - String result = FormatUtils.formatTimeStampYear(epochZero); - - assertEquals(expResult, result); - } - - @Test - public void testFormatTimeStampSecond() { - SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd, HH:mm:ss", Locale.ENGLISH); - - Date date = new Date(); - date.setTime(0); - - String expResult = dateFormat.format(date); - - long epochZero = 0L; - String result = FormatUtils.formatTimeStampSecond(epochZero); - - assertEquals(expResult, result); - } - - @Test - public void testFormatTimeStampMonths() { + public void testFormatTimeAmountMonths() { long time = TimeAmount.DAY.ms() * 40L; assertEquals("1 month, 10d ", FormatUtils.formatTimeAmount(time)); } From fd65d552574518361d118779ccfc626c8aad7202 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 19:28:17 +0200 Subject: [PATCH 099/166] Fixed Midnight appearing as "2 Jan" on PunchCard (#247) --- Plan/src/main/resources/web/js/charts/punchCard.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plan/src/main/resources/web/js/charts/punchCard.js b/Plan/src/main/resources/web/js/charts/punchCard.js index a16775f47c..c65f7b7881 100644 --- a/Plan/src/main/resources/web/js/charts/punchCard.js +++ b/Plan/src/main/resources/web/js/charts/punchCard.js @@ -7,7 +7,8 @@ function punchCard(id, punchcardSeries) { xAxis: { type: 'datetime', dateTimeLabelFormats: { - hour: '%I %P' + hour: '%I %P', + day: '%H %P' }, tickInterval: 3600000 }, From 4d92e67caaac1f480f716f3114c58217815dbef3 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 20:10:37 +0200 Subject: [PATCH 100/166] Style improvements on smaller screens (#481): - Reduced Sidenav width (+reduced content margin) - Prevented extra scrollbar appearing next to tabs if they overflow - Added Zoom to World Map - Shortened quickbox texts on Information tab on server page. --- Plan/src/main/resources/web/css/main.css | 16 ---------------- Plan/src/main/resources/web/css/style.css | 4 ++-- .../src/main/resources/web/js/charts/worldMap.js | 6 ++++++ Plan/src/main/resources/web/server.html | 4 ++-- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Plan/src/main/resources/web/css/main.css b/Plan/src/main/resources/web/css/main.css index 3a2be7d2c9..4ff663d1a3 100644 --- a/Plan/src/main/resources/web/css/main.css +++ b/Plan/src/main/resources/web/css/main.css @@ -81,7 +81,6 @@ .main-limiter { width: 100%; - height: 100%; overflow-x: hidden; margin: 0; padding: 0; @@ -157,24 +156,9 @@ font-size: 19px; } } -@media only screen and (max-width: 850px) { - header h1 { - font-weight: 400; - font-size: 30px; - } -} @media only screen and (max-width: 780px) { .scrollbar { overflow-x: auto; width: 100%; } - .nav-bar { - flex-direction: row; - } - .row { - flex-direction: column; - } - header p { - display: none; - } } \ No newline at end of file diff --git a/Plan/src/main/resources/web/css/style.css b/Plan/src/main/resources/web/css/style.css index a2ba0a027f..6bb4a8702b 100644 --- a/Plan/src/main/resources/web/css/style.css +++ b/Plan/src/main/resources/web/css/style.css @@ -2402,7 +2402,7 @@ a { animation: none !important; } section.content { - margin: 100px 15px 0 315px; + margin: 100px 15px 0 235px; -moz-transition: 0.5s; -o-transition: 0.5s; -webkit-transition: 0.5s; @@ -7475,7 +7475,7 @@ fieldset[disabled] .form-control { transition: all 0.5s; font-family: "Roboto", sans-serif; background: #fdfdfd; - width: 300px; + width: 225px; overflow: hidden; display: inline-block; height: calc(100vh - 70px); diff --git a/Plan/src/main/resources/web/js/charts/worldMap.js b/Plan/src/main/resources/web/js/charts/worldMap.js index 797d01c84b..db66ebd4e0 100644 --- a/Plan/src/main/resources/web/js/charts/worldMap.js +++ b/Plan/src/main/resources/web/js/charts/worldMap.js @@ -4,6 +4,12 @@ function worldMap(id, colorMin, colorMax, mapSeries) { animation: true }, title: {text: ''}, + + mapNavigation: { + enabled: true, + enableDoubleClickZoomTo: true + }, + colorAxis: { min: 1, type: 'logarithmic', diff --git a/Plan/src/main/resources/web/server.html b/Plan/src/main/resources/web/server.html index 7c7c25657f..f93b3ba717 100644 --- a/Plan/src/main/resources/web/server.html +++ b/Plan/src/main/resources/web/server.html @@ -284,7 +284,7 @@ person
    -
    UNIQUE PLAYERS / 24h
    +
    UNIQUE / 24h
    ${playersDay}
    @@ -295,7 +295,7 @@ person_add
    -
    NEW PLAYERS / 24h
    +
    NEW / 24h
    ${playersNewDay}
    From 673e0a2790d8452528f40116d65cb718ad87963b Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 20:20:10 +0200 Subject: [PATCH 101/166] ActivityStackGraph now only displays Month Day without clock. --- .../djrapitops/plan/utilities/FormatUtils.java | 15 ++++++++++++++- .../utilities/html/graphs/ActivityStackGraph.java | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index 1485785e89..d63beb5642 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -47,6 +47,16 @@ public static String formatTimeAmountDifference(long before, long after) { return formatMilliseconds(Math.abs(after - before)); } + public static String formatTimeStampDay(long epochMs) { + String format = "MMMMM d"; + + if (Settings.FORMAT_DATE_RECENT_DAYS.isTrue()) { + format = replaceRecentDays(epochMs, format, "MMMMM"); + } + + return format(epochMs, format); + } + public static String formatTimeStampClock(long epochMs) { String format = Settings.FORMAT_DATE_CLOCK.toString(); @@ -71,9 +81,12 @@ public static String formatTimeStampSecond(long epochMs) { } private static String replaceRecentDays(long epochMs, String format) { + return replaceRecentDays(epochMs, format, Settings.FORMAT_DATE_RECENT_DAYS_PATTERN.toString()); + } + + private static String replaceRecentDays(long epochMs, String format, String pattern) { long now = MiscUtils.getTime(); - String pattern = Settings.FORMAT_DATE_RECENT_DAYS_PATTERN.toString(); long fromStartOfDay = now % TimeAmount.DAY.ms(); if (epochMs > now - fromStartOfDay) { format = format.replace(pattern, "'Today'"); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java index 734505e5e9..70b43d280b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/ActivityStackGraph.java @@ -28,7 +28,7 @@ public ActivityStackGraph(TreeMap>> activityData) { private static String[] getLabels(NavigableSet dates) { return dates.stream() - .map(FormatUtils::formatTimeStampYear) + .map(FormatUtils::formatTimeStampDay) .toArray(String[]::new); } From 6f475b8d82d9daa4c91829df8d64579f66807f16 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 20:43:03 +0200 Subject: [PATCH 102/166] Fixed CacheInspectPluginsTabRequest ArrayIndexOutOfBoundsException #512 --- .../system/info/request/CacheInspectPluginsTabRequest.java | 5 ++++- .../response/pages/parts/InspectPagePluginsContent.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java index d81489d176..c16b8f456a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/CacheInspectPluginsTabRequest.java @@ -29,7 +29,7 @@ */ public class CacheInspectPluginsTabRequest extends InfoRequestWithVariables implements CacheRequest { - private static final String SPLIT = ";;SPLIT;;"; + private static final String SPLIT = "AASPLITAA"; private final UUID player; private final String nav; @@ -83,6 +83,9 @@ public Response handleRequest(Map variables) throws WebException UUID serverUUID = entry.getKey(); String[] navAndHtml = Base64Util.decode(entry.getValue()).split(SPLIT); + if (navAndHtml.length <= 1) { + continue; + } pluginsTab.addTab(serverUUID, navAndHtml[0], navAndHtml[1]); } } catch (DBException e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java index 8e519fcfb9..2fad778111 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator; +import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator; @@ -42,7 +43,7 @@ public static InspectPagePluginsContent generateForThisServer(UUID playerUUID) { String serverName = ServerInfo.getServerName(); String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName; if (containers.isEmpty()) { - return new InspectPagePluginsContent(playerUUID, "
  • " + actualServerName + " (No Data)
  • ", ""); + return new InspectPagePluginsContent(playerUUID, "
  • " + actualServerName + " (No Data)
  • ", Html.CARD.parse("

    No Data (" + actualServerName + ")

    ")); } String nav = "
  • " + actualServerName + "
  • "; From 1155d109345005328b56fb98ca1c29f0ff3909d1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 20:45:00 +0200 Subject: [PATCH 103/166] Fixed IllegalArgumentException: No task with id 6 (#512) --- .../main/java/com/djrapitops/plan/utilities/queue/Consumer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java index 7694d15b8d..7cd1cc621a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/queue/Consumer.java @@ -42,7 +42,7 @@ protected void stop() { run = false; try { super.cancel(); - } catch (NullPointerException ignore) { + } catch (NullPointerException | IllegalArgumentException ignore) { /*ignored*/ } } From b6d7be5bd4f8f72ea97edce569ace377d45f3ede Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 21:02:04 +0200 Subject: [PATCH 104/166] Fixed Bungee Analysis refresh attempt when Bukkit not online (#512) --- .../plan/system/webserver/pages/ServerPageHandler.java | 2 +- .../webserver/response/pages/AnalysisPageResponse.java | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) 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 662356dc60..67230dd0e9 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 @@ -34,7 +34,7 @@ public Response getResponse(Request request, List target) { if (response != null) { return response; } else { - return AnalysisPageResponse.refreshNow(); + return AnalysisPageResponse.refreshNow(serverUUID); } } 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 1b373085ee..a863fa36ef 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 @@ -3,7 +3,6 @@ import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; -import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.cache.PageId; @@ -20,10 +19,6 @@ */ public class AnalysisPageResponse extends Response { - public static AnalysisPageResponse refreshNow() { - return refreshNow(ServerInfo.getServerUUID()); - } - public static AnalysisPageResponse refreshNow(UUID serverUUID) { Processor.queue(() -> { try { From 1c0fe8612f77a69dba11d3ce05e0e70c56232dc7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 1 Feb 2018 21:09:39 +0200 Subject: [PATCH 105/166] Attempt to fix ConnectionFailException when viewing inspect page and some Bukkit servers are offline (#512) --- .../com/djrapitops/plan/system/info/InfoSystem.java | 8 +++++++- .../system/info/connection/BungeeConnectionSystem.java | 10 ++++++++++ .../info/request/GenerateInspectPageRequest.java | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) 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 14524d6fd0..a7874e5c14 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 @@ -6,6 +6,7 @@ import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException; import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.PlanSystem; @@ -46,7 +47,12 @@ public static InfoSystem getInstance() { } public void generateAndCachePlayerPage(UUID player) throws WebException { - sendRequest(new GenerateInspectPageRequest(player)); + GenerateInspectPageRequest infoRequest = new GenerateInspectPageRequest(player); + try { + sendRequest(infoRequest); + } catch (ConnectionFailException e) { + connectionSystem.sendWideInfoRequest(infoRequest); + } } public void generateAnalysisPageOfThisServer() throws WebException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java index 91f426932a..30c40ee362 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BungeeConnectionSystem.java @@ -16,6 +16,7 @@ import java.util.Optional; import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; /** * ConnectionSystem for Bungee. @@ -65,6 +66,15 @@ protected Server selectServerForRequest(InfoRequest infoRequest) throws NoServer } private Server getOneBukkitServer() { + int rand = ThreadLocalRandom.current().nextInt(bukkitServers.size()); + int i = 0; + for (Server server : bukkitServers.values()) { + if (i == rand) { + return server; + } + i++; + } + // Fallback if code above fails (Shouldn't) Optional first = bukkitServers.values().stream().findAny(); return first.orElse(null); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index 21f66a56b6..5ac1fe3cc7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -25,7 +25,7 @@ * * @author Rsl1122 */ -public class GenerateInspectPageRequest extends InfoRequestWithVariables implements GenerateRequest { +public class GenerateInspectPageRequest extends InfoRequestWithVariables implements GenerateRequest, WideRequest { private final UUID playerUUID; From 6dbf3ee3fa6cadae5abedf441655d07568353d20 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 2 Feb 2018 13:12:12 +0200 Subject: [PATCH 106/166] APF 3.1.0 (Fixes #485 & #459 as well as other small annoyances) --- Plan/pom.xml | 2 +- .../djrapitops/plan/system/BukkitSystem.java | 4 + .../djrapitops/plan/system/BungeeSystem.java | 4 + .../system/settings/PlanErrorManager.java | 52 ++++++++ .../plan/system/BukkitSystemTest.java | 2 + .../system/BungeeBukkitConnectionTest.java | 119 ++++++++++++++++++ .../plan/system/BungeeSystemTest.java | 6 +- Plan/src/test/java/utilities/Teardown.java | 21 ++++ .../java/utilities/mocks/BukkitMockUtil.java | 2 + .../java/utilities/mocks/BungeeMockUtil.java | 2 + 10 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/settings/PlanErrorManager.java create mode 100644 Plan/src/test/java/com/djrapitops/plan/system/BungeeBukkitConnectionTest.java create mode 100644 Plan/src/test/java/utilities/Teardown.java diff --git a/Plan/pom.xml b/Plan/pom.xml index 8ede53de87..99d975a238 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -25,7 +25,7 @@ com.djrapitops AbstractPluginFramework - 3.0.1 + 3.1.0 diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index 74d84a31ff..ad217d8aaa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -13,10 +13,12 @@ import com.djrapitops.plan.system.info.BukkitInfoSystem; import com.djrapitops.plan.system.info.server.BukkitServerInfo; import com.djrapitops.plan.system.listeners.BukkitListenerSystem; +import com.djrapitops.plan.system.settings.PlanErrorManager; import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; import com.djrapitops.plan.system.tasks.BukkitTaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.api.utility.log.Log; /** * Represents PlanSystem for Plan. @@ -28,6 +30,8 @@ public class BukkitSystem extends PlanSystem { public BukkitSystem(Plan plugin) { testSystem = this; + Log.setErrorManager(new PlanErrorManager()); + versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); fileSystem = new FileSystem(plugin); configSystem = new BukkitConfigSystem(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java index b779d0c814..ab5a9db146 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BungeeSystem.java @@ -13,9 +13,11 @@ import com.djrapitops.plan.system.info.BungeeInfoSystem; import com.djrapitops.plan.system.info.server.BungeeServerInfo; import com.djrapitops.plan.system.listeners.BungeeListenerSystem; +import com.djrapitops.plan.system.settings.PlanErrorManager; import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; import com.djrapitops.plan.system.tasks.BungeeTaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; +import com.djrapitops.plugin.api.utility.log.Log; /** * Represents PlanSystem for PlanBungee. @@ -27,6 +29,8 @@ public class BungeeSystem extends PlanSystem { public BungeeSystem(PlanBungee plugin) { testSystem = this; + Log.setErrorManager(new PlanErrorManager()); + versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); fileSystem = new FileSystem(plugin); configSystem = new BungeeConfigSystem(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/PlanErrorManager.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/PlanErrorManager.java new file mode 100644 index 0000000000..a7db9b8c88 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/PlanErrorManager.java @@ -0,0 +1,52 @@ +/* + * 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.settings; + +import com.djrapitops.plan.system.webserver.WebServer; +import com.djrapitops.plan.system.webserver.WebServerSystem; +import com.djrapitops.plugin.api.Check; +import com.djrapitops.plugin.api.utility.log.ErrorLogger; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.api.utility.log.errormanager.ErrorManager; + +import java.io.File; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Abstract Plugin Framework ErrorManager for logging Errors properly instead of a vague message. + * + * @author Rsl1122 + */ +public class PlanErrorManager extends ErrorManager { + + @Override + public void toLog(String source, Throwable e, Class callingPlugin) { + try { + File logsFolder = Log.getLogsFolder(callingPlugin); + Log.warn(source + " Caught: " + e, callingPlugin); + if (WebServerSystem.isWebServerEnabled()) { + Log.warn("Exception can be viewed at " + WebServer.getInstance().getAccessAddress() + "/debug"); + } else { + Log.warn("It has been logged to ErrorLog.txt"); + } + try { + if ((Check.isBukkitAvailable() && Check.isBungeeAvailable()) || Settings.DEV_MODE.isTrue()) { + Logger.getGlobal().log(Level.WARNING, source, e); + } + } catch (IllegalStateException ignored) { + /* Config system not initialized */ + } + ErrorLogger.logThrowable(e, logsFolder); + } catch (Exception exception) { + System.out.println("Failed to log error to file because of " + exception); + System.out.println("Error:"); + // Fallback + Logger.getGlobal().log(Level.WARNING, source, e); + System.out.println("Fail Reason:"); + exception.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java index b23db4562b..509bf6f254 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java @@ -14,6 +14,7 @@ import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import utilities.Teardown; import utilities.mocks.BukkitMockUtil; /** @@ -45,6 +46,7 @@ public void tearDown() { if (bukkitSystem != null) { bukkitSystem.disable(); } + Teardown.resetSettingsTempValues(); } @Test diff --git a/Plan/src/test/java/com/djrapitops/plan/system/BungeeBukkitConnectionTest.java b/Plan/src/test/java/com/djrapitops/plan/system/BungeeBukkitConnectionTest.java new file mode 100644 index 0000000000..1d95a57ecf --- /dev/null +++ b/Plan/src/test/java/com/djrapitops/plan/system/BungeeBukkitConnectionTest.java @@ -0,0 +1,119 @@ +/* + * 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; + +import com.djrapitops.plan.Plan; +import com.djrapitops.plan.PlanBungee; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.database.BukkitDBSystem; +import com.djrapitops.plan.system.info.request.GenerateInspectPageRequest; +import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.settings.Settings; +import org.junit.*; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.Teardown; +import utilities.TestConstants; +import utilities.mocks.BukkitMockUtil; +import utilities.mocks.BungeeMockUtil; + +import java.util.UUID; + +/** + * @author Rsl1122 + */ +@RunWith(MockitoJUnitRunner.class) +public class BungeeBukkitConnectionTest { + + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + private static Plan bukkitMock; + private static PlanBungee bungeeMock; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private BukkitSystem bukkitSystem; + private BungeeSystem bungeeSystem; + + private UUID bukkitUUID; + private UUID bungeeUUID; + + @BeforeClass + public static void setUpClass() throws Exception { + BukkitMockUtil bukkitMockUtil = BukkitMockUtil.setUp() + .withDataFolder(temporaryFolder.getRoot()) + .withLogging() + .withPluginDescription() + .withResourceFetchingFromJar() + .withServer(); + bukkitMock = bukkitMockUtil.getPlanMock(); + + BungeeMockUtil bungeeMockUtil = BungeeMockUtil.setUp() + .withDataFolder(temporaryFolder.getRoot()) + .withLogging() + .withPluginDescription() + .withResourceFetchingFromJar() + .withProxy(); + bungeeMock = bungeeMockUtil.getPlanMock(); + } + + @Before + public void setUp() { + Settings.DEBUG.setTemporaryValue("console"); + Settings.DEV_MODE.setTemporaryValue(true); + } + + @After + public void tearDown() { + System.out.println("------------------------------"); + System.out.println("Disable"); + System.out.println("------------------------------"); + if (bukkitSystem != null) { + bukkitSystem.disable(); + } + if (bungeeSystem != null) { + bungeeSystem.disable(); + } + Teardown.resetSettingsTempValues(); + } + + public void enable() throws EnableException { + Settings.WEBSERVER_PORT.setTemporaryValue(9000); + + bukkitSystem = new BukkitSystem(bukkitMock); + bukkitSystem.enable(); + + bukkitUUID = ServerInfo.getServerUUID(); + + bungeeSystem = new BungeeSystem(bungeeMock); + + Settings.WEBSERVER_PORT.setTemporaryValue(9250); + Settings.BUNGEE_IP.setTemporaryValue("localhost"); + Settings.DB_TYPE.setTemporaryValue("sqlite"); + bungeeSystem.setDatabaseSystem(new BukkitDBSystem()); + + bungeeSystem.enable(); + + bungeeUUID = ServerInfo.getServerUUID(); + + System.out.println("------------------------------"); + System.out.println("Enable Complete"); + System.out.println("Bukkit: " + bukkitUUID); + System.out.println("Bungee: " + bungeeUUID); + System.out.println("------------------------------"); + } + + @Test + public void testRequest() throws EnableException, WebException { + enable(); + + System.out.println("Sending request"); + bungeeSystem.getInfoSystem().getConnectionSystem().sendWideInfoRequest(new GenerateInspectPageRequest(TestConstants.PLAYER_ONE_UUID)); + } +} \ No newline at end of file diff --git a/Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java b/Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java index 13bcdfbffd..a7e1916dd3 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/BungeeSystemTest.java @@ -13,6 +13,7 @@ import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import utilities.Teardown; import utilities.mocks.BungeeMockUtil; /** @@ -30,8 +31,8 @@ public class BungeeSystemTest { public ExpectedException thrown = ExpectedException.none(); private BungeeSystem bungeeSystem; - @Before - public void setUp() throws Exception { + @BeforeClass + public static void setUpClass() throws Exception { BungeeMockUtil mockUtil = BungeeMockUtil.setUp() .withDataFolder(temporaryFolder.getRoot()) .withLogging() @@ -46,6 +47,7 @@ public void tearDown() { if (bungeeSystem != null) { bungeeSystem.disable(); } + Teardown.resetSettingsTempValues(); } @Test diff --git a/Plan/src/test/java/utilities/Teardown.java b/Plan/src/test/java/utilities/Teardown.java new file mode 100644 index 0000000000..4e301e5d49 --- /dev/null +++ b/Plan/src/test/java/utilities/Teardown.java @@ -0,0 +1,21 @@ +/* + * 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 utilities; + +import com.djrapitops.plan.system.settings.Settings; + +/** + * Test utility for {@code @Teardown} tags. + * + * @author Rsl1122 + */ +public class Teardown { + + public static void resetSettingsTempValues() { + for (Settings settings : Settings.values()) { + settings.setTemporaryValue(null); + } + } +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java index 739fa05f17..394b655098 100644 --- a/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java +++ b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.task.RunnableFactory; +import com.djrapitops.plugin.task.ThreadRunnable; import org.bukkit.Server; import org.bukkit.plugin.InvalidDescriptionException; import org.bukkit.plugin.PluginDescriptionFile; @@ -47,6 +48,7 @@ private BukkitMockUtil mockPlugin() { StaticHolder.register(planMock); StaticHolder.saveInstance(MockitoJUnitRunner.class, Plan.class); + StaticHolder.saveInstance(ThreadRunnable.class, Plan.class); doCallRealMethod().when(planMock).getVersion(); doCallRealMethod().when(planMock).getColorScheme(); diff --git a/Plan/src/test/java/utilities/mocks/BungeeMockUtil.java b/Plan/src/test/java/utilities/mocks/BungeeMockUtil.java index cf3d64b873..85fe2c7524 100644 --- a/Plan/src/test/java/utilities/mocks/BungeeMockUtil.java +++ b/Plan/src/test/java/utilities/mocks/BungeeMockUtil.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.PlanBungee; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.task.RunnableFactory; +import com.djrapitops.plugin.task.ThreadRunnable; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyConfig; import net.md_5.bungee.api.ProxyServer; @@ -48,6 +49,7 @@ private BungeeMockUtil mockPlugin() { StaticHolder.register(planMock); StaticHolder.saveInstance(MockitoJUnitRunner.class, PlanBungee.class); + StaticHolder.saveInstance(ThreadRunnable.class, PlanBungee.class); doCallRealMethod().when(planMock).getVersion(); doCallRealMethod().when(planMock).getColorScheme(); From 13e948c1b455b50c347b4925fa5d9499638f2c30 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 2 Feb 2018 13:12:35 +0200 Subject: [PATCH 107/166] Fixed GenerateInspectPageRequest when player has no data in db. --- .../request/GenerateInspectPageRequest.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java index 5ac1fe3cc7..999517663a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateInspectPageRequest.java @@ -5,15 +5,13 @@ package com.djrapitops.plan.system.info.request; import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.api.exceptions.connection.BadRequestException; -import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException; -import com.djrapitops.plan.api.exceptions.connection.WebException; -import com.djrapitops.plan.api.exceptions.connection.WebFailException; +import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.webserver.pages.parsing.InspectPage; import com.djrapitops.plan.system.webserver.response.DefaultResponses; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.utilities.Verify; @@ -63,8 +61,13 @@ public Response handleRequest(Map variables) throws WebException } private void generateAndCache(UUID uuid) throws WebException { - String html = getHtml(uuid); - InfoSystem.getInstance().getConnectionSystem().sendWideInfoRequest(new GenerateInspectPluginsTabRequest(uuid)); + String html; + try { + html = getHtml(uuid); + InfoSystem.getInstance().getConnectionSystem().sendWideInfoRequest(new GenerateInspectPluginsTabRequest(uuid)); + } catch (NotFoundException e) { + html = new NotFoundResponse(e.getMessage()).getContent(); + } InfoSystem.getInstance().sendRequest(new CacheInspectPageRequest(uuid, html)); } @@ -82,6 +85,8 @@ private String getHtml(UUID uuid) throws WebException { Throwable cause = e.getCause(); if (cause instanceof DBException) { throw new TransferDatabaseException((DBException) cause); + } else if (cause instanceof IllegalStateException && "Player profile was null!".equals(cause.getMessage())) { + throw new NotFoundException("Player has not played on this server."); } else { throw new WebFailException("Exception during HTML Parsing", cause); } From 70130f962974599b7400ec92e641cc81eed2cc93 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 2 Feb 2018 13:20:50 +0200 Subject: [PATCH 108/166] Fixes Network page displaying odd Unique player numbers (#518) --- .../webserver/pages/parsing/NetworkPage.java | 6 +++--- .../plan/utilities/analysis/AnalysisUtils.java | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java index b21ecad3bc..6e1704ddd9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/parsing/NetworkPage.java @@ -81,9 +81,9 @@ private void uniquePlayers(long now, Database db) throws DBException { long weekAgo = now - TimeAmount.WEEK.ms(); long monthAgo = now - TimeAmount.MONTH.ms(); - addValue("playersUniqueDay", AnalysisUtils.getUniqueJoinsPerDay(userSessions, dayAgo)); - addValue("playersUniqueWeek", AnalysisUtils.getUniqueJoinsPerDay(userSessions, weekAgo)); - addValue("playersUniqueMonth", AnalysisUtils.getUniqueJoinsPerDay(userSessions, monthAgo)); + addValue("playersUniqueDay", AnalysisUtils.getUniquePlayers(userSessions, dayAgo)); + addValue("playersUniqueWeek", AnalysisUtils.getUniquePlayers(userSessions, weekAgo)); + addValue("playersUniqueMonth", AnalysisUtils.getUniquePlayers(userSessions, monthAgo)); } private void peakTimes(UUID serverUUID, long now, Database db) throws DBException { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index 5369a74784..4f83c777f2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -33,6 +33,24 @@ public static long getNewPlayers(List registered, long scale, long now) { return newPlayers; } + public static int getUniquePlayers(Map> sessions, long after) { + Set uuids = new HashSet<>(); + + for (Map.Entry> entry : sessions.entrySet()) { + UUID uuid = entry.getKey(); + for (Session session : entry.getValue()) { + if (session.getSessionStart() < after) { + continue; + } else { + uuids.add(uuid); + break; + } + } + } + + return uuids.size(); + } + public static int getUniqueJoinsPerDay(Map> sessions, long after) { Map> uniqueJoins = new HashMap<>(); From a6b96009a0d7456ae013bb9473b9f9585302e7f2 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 2 Feb 2018 13:23:07 +0200 Subject: [PATCH 109/166] Made TPS Count Task use Peak Player count for minute instead of AVG --- .../plan/system/processing/processors/TPSInsertProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java index 9bc77adc69..8d268c26b0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/processors/TPSInsertProcessor.java @@ -28,13 +28,13 @@ public void process() { List history = object; final long lastDate = history.get(history.size() - 1).getDate(); final double averageTPS = MathUtils.round(MathUtils.averageDouble(history.stream().map(TPS::getTicksPerSecond))); - final int averagePlayersOnline = (int) MathUtils.averageInt(history.stream().map(TPS::getPlayers)); + final int peakPlayersOnline = history.stream().mapToInt(TPS::getPlayers).max().orElse(0); final double averageCPUUsage = MathUtils.round(MathUtils.averageDouble(history.stream().map(TPS::getCPUUsage))); final long averageUsedMemory = MathUtils.averageLong(history.stream().map(TPS::getUsedMemory)); final int averageEntityCount = (int) MathUtils.averageInt(history.stream().map(TPS::getEntityCount)); final int averageChunksLoaded = (int) MathUtils.averageInt(history.stream().map(TPS::getChunksLoaded)); - TPS tps = new TPS(lastDate, averageTPS, averagePlayersOnline, averageCPUUsage, averageUsedMemory, averageEntityCount, averageChunksLoaded); + TPS tps = new TPS(lastDate, averageTPS, peakPlayersOnline, averageCPUUsage, averageUsedMemory, averageEntityCount, averageChunksLoaded); try { Database.getActive().save().insertTPSforThisServer(tps); } catch (DBException e) { From 70cfe0984b42464eded115707f4a6ca829804de1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 2 Feb 2018 13:29:18 +0200 Subject: [PATCH 110/166] Updated PluginBridge jar --- PlanPluginBridge/PlanPluginBridge-4.1.3.2.jar | Bin 105912 -> 0 bytes PlanPluginBridge/PlanPluginBridge-4.1.3.jar | Bin 106110 -> 0 bytes PlanPluginBridge/PlanPluginBridge-4.2.0.jar | Bin 0 -> 124932 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 PlanPluginBridge/PlanPluginBridge-4.1.3.2.jar delete mode 100644 PlanPluginBridge/PlanPluginBridge-4.1.3.jar create mode 100644 PlanPluginBridge/PlanPluginBridge-4.2.0.jar diff --git a/PlanPluginBridge/PlanPluginBridge-4.1.3.2.jar b/PlanPluginBridge/PlanPluginBridge-4.1.3.2.jar deleted file mode 100644 index 4568649bb001cd35fcfcfda21f9af8c14a43ba10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 105912 zcmb@uWpJEbmLx1HF@wdHWihj4F*7qWGc#FKVrFIri&{3k&((XA@j+QM;03<7!oj!_%sH-1zcfH-gqpuOLQUW9oAIcF?pb;ChY?&l z6|Q;?m4En3AvT@Z^otC@{ZYVL#CDx`J%#>i_qEGJ^niNf!0?HtAwuXJ(~E(5Il z@yINGy<->gJaiDA2cc z&XKBH-!I`CQ%bF!jaFoas|Su6&0CN(N|x=s$fI*+?L9jZj)-YUu%YabTrW97Cr9GU zDM-AZ+?rclie=Vx z9>k6GhUA{cyTFI!dl~e(y`K`54OCy^r|Ts+g@xUO^6cvOb?PZJNgWOWT$ng5OLPmX zrX6z`c#?6_x1NJ~w=ycK`e7NuLB=DNnMF-9u(Gggk6qi=t(nB;R#t>r#FCN2Dt(_AjrATi*IXgIQ$x+&xxn+y68s;xNwlHx!63F2v zm?;|IZQ2zUn=l%g^5)VE*CjKkfe^*}i(I%rn5n{rBt=<&2Te$`S&u6f##o!LHN2h{ zn^cCczFW@YkD&&;r(7=n#>M_A$+DQqmsd$KATSNs6FSR8wrOH z3co*JG-4s;s6h!D8%xtp2vrE<6i#n#T1*jl*Bj;P7ILz}VRImo!zdILfi8HaRCUbS zJ@CsyE1S@OgCqjsLgG7y0AUb)2vFc@*NjVPTO2zk$Ejvlj!p2~Icu!%qd24pY9HYz z>X3(UKLKVAtA-yaEpeZr_$+snJtRP-NIuZHi#N3a)4ON^G$pzt8l)7T5G(lqNZYJ8bUy37?l-zf+blP}JSDp@(0*Y=xX(;}Mmwb*QB2BqD{{e<^^--u z8ts-l<{l%x)3*qaJp(^X;QefOIG(G4+qloX9|BK5+z6(BS}Y=u<2#_+RipS|$w~alnI36_eT5I{7nH4KKNA@@(tm=xEcy{G#Qb`RCH+8s4M&%Dc)qz#<96Jd%~t;^PU)EU zfjY7~CU*lETTq1v!EJBsZmGh@&Ho;Vn={Ay!m!?XR#6zPxpiPm--Nj#88I|GKFO>M zagPwzP&p^lt@W!wNQK!m-)JM{J9E#uXmW1?)mv@2zSrW>jzPlHP(K95D{!uYD%xfe zN$ZyeLxrVfe0m%5(rD|QI+VC>^D?j`iS5uVT;f1=W-D?Ejbe}g2^Vxmlp!TH3NhnF z+{G+Uke~9-BuFfZB|B7jn&rxff(KB6a~v&z%Oz&rA$HPlCC=JbqR4bBh zI=l#<;8XS*xBw{av&c?-X>2Dr?nPC;9TCBBf~db#2~C$HrE8&*=KRU4+FLd@+sNKP zU3z3ozh%pkIErK4{i{4Yf6Z=oI2|H2`7o`QOnKfAZOIrC%uW9;=zAe`OrgbYLvllD zAv%`NG)nGwShXw>({CEC=!?5~*QAX%bKdzx$8La{gNDzGKJ+3;c#6`q&UHBV4pi*r zykyYwL#p5LBwYjjGacEU%49YmvO9ZEZ+K@?WAaM8HNTypKnHfC;f#y-ZRGS%pe^Kx z>Be6BO`PSk_3d1sO@#kc2?=rz0%t37{n;0Ja6_7dS#4F80D(to@L9LguI%%mPXKqV za18w?4={v+Zs-IZCwPRy3<9AM;cuqlqVoXrM+_BwR$Iz0NN9oVHk_9~F> z#DL?GQIcUi`1+&)K_7KvJ|P|zJ+V3Wvd)niO%6mZq6%MD>1==;v~oikm8;96F-E)u?I4?`jtID|3R=WS-2ZY6u_( zpPq=dQ|jtxE+)9sN1Qu!InhUy?m}~wvUupW#@F|kkx1B2a4wG|)4sDvt( z-w9Z?nyvD>7^)v~<_H?Rg2X)p03D*7X+SD5jy0_l2mg$*PBVc?z6?wS+AP+$nSxeY)As%KDXe*!|Ov z4RZp}!O_BF$*z7fNcefij52r)0+&Nq8ZT zunEU(_3n@MVQ#IsX2@N4wN`im%C3RfUW*N`paxU_yMFt<+Q@T>rSa}3*Olaha%f+} zaha#+APVcR9}~~hPOyUaxBD#u;rK@>O`ojBv@KmZfgQu1t6UECVdD>HIi=>=UL`gF z*7N)qSTReVP&E`ZVmMT3#JW}9hYKK{F>6KsF9=Mb==lpBX%viBsNjb2G*TKwbw*L| zxiy+sebnM>vpsQverSX~j@_a};i8wjn3t z^ic9mMGETpDap|Q&hRxJtkBGj0SB=X=Cw6!Ty zoT&Q1LLAVlQb!L^p~+cJC!qS?Twm~g9!8hjQ|O{~$BB0I=Zddb;E3ZerCm);r#Rm( z?l0~2r*dB2f9U%|I^b@z6+$NNIdXq@PJ{mve)?rgOsZc7%x?mkDU=&L%2;pWQ?QU0 zE%u<3ly7DK<1$&nbs67)BF;m#efuXGcek zn;kh1%E;#=L8OUKBw|R+&(`6&)X0d(=aTwip5Dh{X2vOOEyeO|!<1W|Wo99rUQxh6 zlS00Pl`r24`a*#eq;1@8w4RlcDlbF7A;0D6hTbnjC<|R~a2se8-xnEw*X=7GyG@1A zU@7kCk%J#|F3`}`V{*bHmrl%BS9lj#m=2^P2F)nd$|SEpLbOD-3&*%DYtSIfXH_i> z&=s#jjH=7EGDz`U3rqcp}R8eKsf*Y%;@$52@H zr`~7rq2EU!{y^7fS_nP!zz%8qQ4VF|6J&4tP!QX`K8gDc1(L6+jPDjMFcLI$%BJ$o&6gqQc{s6P*v4|d z9dmyj9TMw8yS1t8;a_M+?A~w1vsS5zp#DlAM_NWA&j;!#A^v@|0X}#oW@za`S!b*+{`^S!IZ#JCF(Nw=jw4B1w zEmt(e8@r{qg-!HJK~L{JYBze${T>+CjvY!NfJ5gwrrryy8w>3L)nuV~619-Oi7=4N zV=0FG75vrsS^eqD_V{0PT{EL?bj-?3D;hZoK;t#55hhb4(x3DN|=|3D`UY>|cl-XRniSQ5hjIFvH~9ZI{@ zwB0fO4yBe{575;rf@laO9CM$bimTE>e{+d}DE6Wdly4~b<%}U+Pdv9*fO`KRan*F0GOb(rCIL{H#&QW*o;V`K24=HH$v91n z=%ijn)ftQmYN4bzpXOrWNMCI6G}%<)NJ=@4HeP4A**SDN%Y9+qGbt7@9&0=dG4jhV zpr1)_Vg|CAx0YzBr=f-D3lO!~p2lbZk0t5lFYsiC!RFzrAIlk4Ta$|P1)>mGF?A?N zc6WJ`ZYk-a+l>i{VgaAO4i=eF^SOe(wB@RvR+Ks)D6X9o=Q^D#I=Bo?`i$*vIxyjUvMEO%rU$jYzM)Ivz5-~3- z0V;WVgIQV{DY(gU##lGa)u!e*Qm5k006ed|f>aPvPVw8t(s$wY^Lxy|GDhz?K21c_ z@5^y$VX-x4CW2Tq^S#yO(wUs=H<9$t9WSIEulk0v7nnRJ;}Pw>?&Y0^Yoh{6SWzFV zT0?=mOj>QWtCORVqNg=T+Mj6l#ycC|^M8}jC2R0pVs1w9*jGGSuDQJak!CjCirmJW z@CQW?saaLf<;G~7gwwm8gfO+FGo9dO6E`Vg>Tohh<6JeMx%kj(kf0z4iIAR$uzL@) zu3(>J1y9YjYPTdN7V8behq~4sbXCIU7EpdsE1y&S{Qlokt-9W3i!@?lx_e zNUqFX+V#n~ebs3Zg|((OJ}OG;N8yiH$hTiTt=?SLNH1JQ3=B{)OW!r-%M8yAiJL{2 zM}KsjdUR$^s`q;Fy;BoKGb+W@+f|$L*5&i%EudVu$j_`t7-AhRe8sOJPw{UxT@of# z&o2;RufZ!LXWWY6!YbKtcADL3hRc#unXa;uo9uJrsq2!$;1;HPijAMN6K?q&tcyX9 z=}WM;Ezj-WBBGp_L0#1EgS_*_<2WH>m#hEB*5W&fi28Kj8?5iND=fnuVezMD47afB zn)=Ur{o?`xRQ_M{xEz8%MQ}x^pD32GOf!&#Q4J`FuWp9I>UYPEn7G4D!}6S5`NriwS?2IPi z;F+~;lNPf##_Bg=&DLDy-duELXqUsdG(uQ_^o#Z!)5^=PVW$A~idp7k0$EybL6|oj ze?e&>K6>O|P&)KK52Y-BhtgyfZS{Ep)Q^-;5M%;v6=8u9YY1^pxA02Ik(lF6y>INB z%Ae+n$f@=kdPba~Q23r9e<^-8$Dnsoi18h{nz-;`*|zCEIR0_X4<=(+39ywYBf}Nu zR$?k*LI+U}X&HVg+;B9NrL<-i3!@nGsxX>nWXq&XgOZ zylm^F_ANcbRjpJ@ahpvpuKyCc4t-ow=YpJWW^w0U%#mf7_UvEl(Bd(R4$n(sdpgZb zKz7%}Oc-sC#;f_<_EGNn6a!^dCW}Uoe=?SdqGwG7N=m z^f0Ff^}3EC)`bWwtN5O-H->c$IY?0zqcJU`YUWd= zvJMMV39geDay=nIFe}1moMH}J=yg4Q$Y1Le(xyn>j87`uvezSkrOAsc^hZ$~DF+V| zq;Cr%e$8y2-)7SE*3kLL%Bn_&_>tRooiG z6at;Yf>220aF6^opjU}a(_nK5j2P!?hyJqS(Y&In-E@9-L7kO=#4BnDgH<%n4iRz< zE~8L_BSdeU$!NFk6SS6mp16ZxF-ml!)T;L1pEA8iGAQ+MqmXA`X{B3ib$iMVBt z`~neFGVqo$jJMx-<139=sVz8k5BOh0H@dC2fbvHQCPM!!{=)u$AqD?a2wEzyt6}oi zgTskS_G;n_6_UoS07anZY~qS&$!G8q4Il$%lvdTE!r}-e$!AJVw@Ti&h-UO>rZ7($ zS+f1EV$UAm#);(O{X(;D#`RNE_S) z<6@-9)9lgAG8Z0&uC!2?<$pGBCKe+m^K z|ACzvH99&=jNJEJP+v9DZgg-^WNRf>(_+I^v_c)~du1Xrx*=cv$s&JLH*M~&-N@QA zNQnKx5@@D>JcA#>K$StvEy(gh#@S&(4Vaw5rfn1W;-prW+-OvO7(hm0KO73}1yUwB zgTB{Nytys!353 zN}$iAzrq2oKqG9~z?@&(X};Xc!=`KA*}WOU zTi=YO0+y~+YksO4@k3fbcdN6|F1ie4j_@Bi5I3F+$O(NKb4J$fKo$f~k`ZgFYPMh< zGxWeFWk=C!UAw%i7HJW37v)W~yDl0|C%qSCDMYruNMrL9$~6xVb=mCZca%T#&M~yZk-x`KHg$>MNYTDUJH(m7QuX znlQb7YebYAcvWViTI5HKl`I4)8S#(}UPX~BOG*xeK1&Q>hz(POP^L6irKJM~5r66+ za;JokdUPrmRMHi*Da~#*doMjU6C2V!hMt5L`5B;j}q7dV7}{IDQW7x98t!8aO|?Ee`u}!xs65MEGc{9-(?J z!pt6@Acj%yIFw=gs-Tf^7ArrLpmZWus`84m9JmEi=)t-r>^?@_tmY2QAxx1uUeI(J zwZ7@;viMqgxJQM8glMO_?4(GBl?A2((8PVL(yywHN?gcbvz+bwtX&K!jhc3n2+rwl zZ0e>o)5Nt>fCnt*W%$)d9hB0DoTez|TeyhGP)Zl&860m86CeXCQj&!i3ow4UAh}jX zKqTAaM(F&`E6b=PC~^BW$B^c!woaMnllek!D|Me>wX*I)xx8IN2y~4JuHbgv`f;Mt zVW*btwY(b!8exgIPdaV7vtd>ouZ&YyUyzAk{FSejfJI_2Ut{K&(9OVoLeh#X_&ArZ z7}ph$#iw=Fk=2c+QZgfa3CK7-*e&d)L$A6%(GUkgKT9ZR2ul zUzyk6?*go1^8;QCP}XLnSiTA6wpPRLvi7%1$Rl?!Il`rao4Wwi;o`f+XT_&+?u?%; zkvAfKAv>BudI!BN)$!jUWRxMWckFYqBexs#;}bay^Re@t#Bj3niA-`K|JWb-H2xj5 zM=%5zTZgXOiC$?PqeW0Ne+{ii${w{yvX-9vTA5iC<0Zj+Ozb)VARu|9V~L-NK_bu> zKhO2}D24weT{MmbqwhqLs@fLehluJG=ENe=cALzJM0_NI>(;tS>)0W=v4X4xcRwH# zT=$AK$0f&3jQs1A&STkQqv7XLM74c?)QkrvLo)ikv1DMIEZo`$8N+2xXQTJs z+|}rKI$ioyJ9EeqTF#c#93Ko#^f%UxkW)0P8rlT{y^>>s_YCR~D|AMn$SLFa6dL3i zE=YfG#_ub`vqX(n7d+_q( zZ<_-*zyq-_>`$D>IV|o+ z!_)TL;5?!o@Ca{}Wjg}t!lqX=_r3kX2;zuhIpg0ALHH5nJD%huTbFKfIf@jhnj^ha zIBN94{+=IpGN&~h@Gqw5@(B_$t*Ct1#-sAbzJb;9WKGQJ1A5<(NbqJ1%Xm`jCiED2 zEV06;KKN?qui}$ZB?UIv(~{Z*CNdyQ+$>IG{QUNnblnUD2iFQ-Oq zvVp&hIWwV7upWgAErb_aBy(POY0B*s-bl{k(G86u>F{YZniK~!knlNdstSjCf8QrO zEWBzh;NEPLCCq^Md=Vo3qQS+P6b~qwFT>@%3rOt)OAHdLgjc&1tw+LX1J4uCaNFHJ|Rfuej32i-IynRTnylZBfb<^R+hD&2>qD&6j5M{LMY_i7vtZ00#rR{KG*0`2!~W?>=A(Hin+2PJh|a z(w4^7GM3IRrgo-I|LI8=t7!k+a8w&Dfr!q%L8w}_)2 zFP$o)VU;OqV8KWlerM9=({9>HQPbpmE3D$(l*|{i67)>#&f?s5xASf1_wl($?u8oT z{T5;E)mj6?5$PADg)_c~9i^Q%Qh>nmz-YN^_Nix2?Nf{5gb};kWwHARm$) zV&SbyXWaI4pTv&tijKvfVH_p}cy*On8>V;>h~jKU(Qo)DH0S;DI76L38Z+5&)xK(0 zhkr_P-tKBaAWpb4ksW$b1aiYbCSKB^Sw_IjZQqz=g(-++SV#ex)6JgOIWZH>`|Ze? z9ddazDX~xzBJE?mJ(7u8N-F~Mw-fUOxIO zbOw(#7Ft0ynH3cw-omt9|={aYkHpUrQ^Rl(tj?9mne=E z(&r?;6WwCmnjBZuTakv z+ku$)o5(nsqO;$)t|QD9UAkfIhKT*jFu>4Y`j=L#{XRGkLL__2%}jrNw77>1uXEWM z%f`n?JtHQHVb+>zh*mG-u7~TcT^XaAO9c`TXT4QbQYbr!Q}xGvEmsd!zuFVxw`ylW zH>)diU0287Zl)&{;YFymt(*dblO?136>|afXYZ zV-jr=iZH%K;=r7hYaae_N3h_Jl!~tZm;Pk0N z1R>7uTMPC1|D`M%1call|I9VypHSsLpKZbax7q&tMpCSHuCy+O`N57e{;2@YGGT}n zDQRW^RiHRua-1ysT*tMS7CJ73KAUw^-3eZ@pUW33! zn5#PmiLE|LskOzjzA(t)rf4ZrA8 zoU`MlDEro%a`z=cY+6>9_dcgr<96WMB0PN3`C*mTuY5LI#RWHcPM3ZNKxlio>RX*UZL1C+wM)7Ou zS5|j}f-IW4UW0r?$>Au6&rU+zB?k%}-c)(FS&KH=CRR)?nC)1n((ueN`_OMUuOGuv zdy`QsUp7d$YBgOjc1*xr~7cWxxZ0)x1@XI_ieljJJ0GNDL7KP=0~{w z@@j&5ZIhoZ*JiIzox6m#_k@^69Lf7SE6_{w z&X=ZOp*KI=I??Rm_a=!4Zc@H%QLn=UdSu#oau=i_&k7@aB@B++OlM>s0p{)dz;fac z9~erBRT2U^c|~H4z_#=S=4`1BgBAO2V6S^aP>&p#!rXy3^qt(nPra~vf}{6(oF2I* zKK?jFy)Yz2yYY;C5#q%g!$q61(jB=9HBJ8<4T58x0Um0X5 z`VhQ~D0#cLvKx#_C@*LsxhH21HIO+fIB}PvvyK~h6rEg1n8pxD zm-+I|Wv-GU0(TWIFJ>!t7gVS@Pok0R%+RUk(Qp+Bc*LmJV$Mpg2#il+x5~EboDr)* zYFZM@F3M5Kck>0`MoW?av2ibhN)M=0~N7^0E}9;{lS{L`*1yXfatiG8f$WWl@na_Me@ z7E`sRT%;oL5!F%|-&3W$GV-0vl||-K9auKHw2Wg~cSf+vs-ASgV|YJ(uT$Z{Emt5p*BWxQ_1+w%PH%1$CcprC8Bo$(!(H6h8-DYldIhc zwrSj`X9-J{{TBf^cEjX|jBn-RgDdqq`Kt_~SUysNWIh@B9cZ}`K^}qZ`Ik2Z5frzW z#R?^q!R31_9#WzN-hXm_P(fMPMs8K>M<1^6uij^@MsNI4pCl=s9dgUZd>sO=+8jZNtPL*xF$a72Diq;5g>h4$~%IExu)LW7YgJHVyI>NC+#a)x? z#;zJ9{;L7`vKLE=5|v+w{OUIdSbt*8D!=f06mQ}ED)&@*rWqf5c;QZPY`*sJl7u_9 z+zu?MClu%qQ>ACBt8I~ByoyTY_a2lltdfFsCofvWs3|Fi3pnU>^j{C5&uR~esaBOU zf|oIDCrZ(C5AwK76ycEOfgSSh^*J-A&_a_6M$s{a?;LK21}iFj$M{L%KV3upqD0!y z9=WmZHSLlH(s8MeW>u;TMR9ZniDgU^O6QM@qRGfA$a$m@lA_)Nk|(7s+6xi5nJU)T zFr#5xzS0!rVB6&vNv$nAD7OV9+X#DBn#=+6ZCTma**pUc-S^*C(7_`lrE{uW7Z%(# zPdB0{<}oiwCfohr%g71kmWF3{iRvUP4?af(STN%j$}VhI%_XWaO%v*CYtV2?=AU}f zi}TK!fDm=G^P@G)#K>n)t;8frn+q#B*>RCMnk@0SR%Fu;%sXY!Im%(>x9jm}hM9_$ z*Q=&`nDDf())qFyg0n;otHE2J}=1AFsh<_pXlpHU)@8g*G#bm-qCwIC+3VMn;QRY z0BtamyNDxFKU08eN^Tf!bkk9|DJP8{+Pk6AJU0vUB0DMC=r&^nu21ZKgRPbMqrN}z zh$JCOHY#+``Qg&e)qiKZl{klhxRqFkNP5npfgQr0`6!_Af#Kzdhlp!)yBOfw0DgWz zv&C*U;()d=3o1o+->ZEC7-gO#ZwfnN$IN80TIDBy6wgXfqQ^8&3KOn(Fnpi~de;;b z0wOiIV_m)VDe-ls^#U^NZ`~K!uKlhZbL}DWSYt#20!5za4wR4t zblr}aZNC#nwz_`S4y#`*eSq$Cq@3fD7m)P$ysj%zO<$A^J9qzOurhbg9Y)ltHzc9p z+opW{9Ng6Rw-5=x@zG?%BL@fy-89aPNM)#dcCQjjO6#y=R5^?tFg@}6ifLB}k_CL% z#30*>h>%n?qd8}IR1JnWjz`;$twm;LIv z9{(w|pTt;z6JB?Y--FN&#ctOeiFgPyn0*g71Yz+rKyfx{2gUK* zRExR%l;6w8F2;9a9=YAl81{$eJggF6V+`NJxrC9xFu=q`182bzE!9P5C@zMkwPH5| z84|=LD8{O@%s5ti3_SL}#R0j_(>qVMs6A7+WaZhk(GdUea8wAdk_vxI88?_s89NLs`1}Z2K_+zRrfK1xvNr4t@lK`ry-8KH2kVZ*pU@%qc;)JK0 zVTz#w6bbgjM}X5`fa)INk<@xUb!@Wd$V>aeug=zp?R~k zIO!L}BdmCty|3Mq+=Y!nM*uMql)5KevSqu$dByzf65RucaV4Bvd_)y(_5gXUXV9%B zstZjCz0SyxtBtR9w#9Mep|^~;@g94=Vuia)NFc!#?;?tVPbC1Ii@HNUj^o7`2(!t7 zmM$2OQrg%rrKewb0}_jhqGQ&Ti?Sri@Vz=t)*?&nah7J@lTC7ng%fn9=3M3I+K*xW zn(FTjR9h;4T#xZTll_hg38vOLVvaV2QBd* z@v;)x3`wqH)HUiBC2FG#C9z^BOX<4CFMSGDkO0MCNoHA;^ofCV$$XE#H&Z$y-&>TE zOle)M1sMPD{-aGAe&&CIt@z8-4}GDW=DEI)zPVjbzus@Ad%zI)&q=5DvLcq1R$}j| zot%2|_FUVJ6Hf*QF-sgJ=~6MJ$%VRICWGVWd}2R`iayXNbjM1Af4fj66ID^X40{nIXBC&WS{C48^a`zvl9#_ackm^ zVR7%VgG&ua6_mO!=Tx@Ky}dTARDyL~MB9w+3|1ypFO;OK8yGyGIY~ z@gsp-HzCFPZ3&rplgo&P=ip93pCjlKWjW{?%+|Vd8oJsw?LWEIiud;IxI$lpMJG_n|1qlR*XuYWh>cz7OYmUak00ElkaF(g@p!G`Sl($;2@CoA%rSSopN%i zHrN}kvvk+jCr=u<|s2Nz@b1XEAp15m9V|KXHmALjQCqEQE}1LWZV&MJ5dJq3f0|naJ87_pWmp-tkZ->=Sc;O zwNI12_5SXB|D|g(9nTxBK(p(|GyL<5Jcp;H!5kdPyHa@5`uAM96lkLqPX z;}U+M)@W%NG2b7J>tN?%22srC2~Rb=)|t6NQ|hvZ33*C9FJj(fvWY8bHVGA6hJ_bU zR@#6Jnb~v2MV;NVT8nnfZ&uZF+gt91@NQL0J&u5IsYdj@V8E1SP?G zSwpDyMn!%AE@E6X_d#oHhCQ-Z+Wb_Kh2a06ixn$h+Mx?#@+#*cAT+^KH>tknS0k+G`lmeyFfI87 zldqS+m4tubyS2C=T*PgPUKT#%kc&l=^Ln)E?Nqeg~bwW0lLn-EXO_9sT%%fGc^5Cw!)&W#I9x*c#gR zDSQ8?kv>#B5Xp%Q7Z)8!ODRZ-sCsxq7i%P+g{q7BHkHd`OL&Q~t3z@m_xAk>XnKY; zi$Z8Wtsad-)0^an%O18xP|6|xaAYBl%yo5SkXMzTAdK~d^I3MjgU|{{x<1ht%tj`u z+hqCvLmQ?wAp@~mdntdV1h0_r+C=^V(wzfQbi@Gv5m1B{>NivIJ}kM=Dd4tkYVZSh z>^BcT&}KaHDTwkYK=^)*bqwRrm1pwr(uIJlcJT^m&g4EtLl2%&y3Q53D2-z4>;NA# zflw69*JF#H1aJ}GUC5>@a+&T0iH}YyD}Q}urQJmrU55EKv0uL@xetFgpqlqh@^|Hf zo-*a=I2FY$LUOD`r}!>Hg4-d!(hmufM-0~TL%V_N+a8%RI-|{pTg49 zfMXmBa%uz^dMeGSet$cjrTAHHU$2g zorDbSWdGjuALxd zq|M)qPUTMIh^Y!M76&Z?gs4bnm?4V5vlKHvjY(PJhNP&fdV5 zz0$t^$a#9#o8F!S&VHnbTSuNemU{u>Dqt>g~ zGd1iaSRQ*<55AS^q>fVGXH)f{(<|NiY1j#FkGL<}NaE* z8JW!Z$(Z?T)P`FZ!(_HZzuehrw%1hBdB0gNAuC~kYj{z1c&Xd*L)Gb;CPj|yF^o(l zgLw%wBE1XER;f1b<{V6vPN!@O*ZZm1=At%~8RDO7gIe3i_OLocvKLEFC%2u}CHvfN zE;crjCNA?4-kFK4iXIU*jwH4wh~v@j8gfe#?U&7m38N!TtXWts0^ic74?V;>0C*U< zK}uC0oxa&b+xHbmvgrs7Urkdw7ZK}eG zVS-v0j$D#;Leu;AT;rMyIc;zQXA0E_Xd$_Cj`^BY;OE&ns=Rr|MORxIZuDZ&Bt+NN z;i=<tI2Ne+0hU{FOGScKTt+n%%gk>wtaJoF?>t~YcT|EMIhg_gw z8Xg}^qUAAn)$V<3E^Qa|xrAuyBLzBK zZdh&HpWssdU!=WLbY+jW?Oheywr$&9v2EL~RK<2yjEbF#or-PSc2=xP-Tco!?SA`d zxAUF*G9Sm&oU@JIM<2hTl(qb9^QwS|ysroMyLuN@pkkN*xhCv-_YE(AL^ytzG|(-I zUQcgJzSMu;g14;YHQPQqjCfBvB-`n*Pv{pNZ_?SYs*G`=7Py9KCZ+N;?Q>*U-kwXY z{jJ>IMPhQv!Ouhj+j?3by?i-3h@=7d{`u21{OW0$(yZ*pD+IZ*vlJ8atP27M4vzma zKp}uW100h5%r_JojjPS)tpjGIyGU!aR+=!~*|A10%2wk%e?Q&P8$HDC{%g#4(SBkO zHRAUnBdIeYMd0$zw zF2~k3_+4GN=Qm*old|*3NVsl&vgSG_ON%ODsdXQdLEU{+?>9%#f4TD}53_>M|88wl zj~i$2U8F9{pv*m3xs|#)vnlGHrTBGm(I3+*H~G{aipn&iT3Ar(3=?4&$bpJ|Vx z_&$1^41>q3(Sn)cJNJItP3G#W>Q83Oc4N(HUZRbfTrh*;)*`#hi?}ZTo$smDA4?@& zI_%U&opel6xuFTUleeQN)^y_~eGQb!y-m_*OHr=OHVrxBCs#-{HiH`hPEDH=I2V5G ztA^rFXT3{FLX!jl((Y*|!9oJO<(J{HQp@z`16*GzV^Md1@%?K#dfvtmkk)&3S&_kP zOP1F4gZ|fL=jV5(Y?6FoC!cHM&a6Mt83#E{G4AlmoHIz>PG$=6il3w-`qTcR!ahIy zLeb>vEYUD?anZOy6uOXrutvWJxaK>o} zXD#J*he_NKOkdaYfw;33?@!;J$1g*CKqxHHNmM_s(mZs&I;$nH&1$0b+V9-z*G4JF zA9|@9flP!KRM1B-GpQEil*GW6#ELB}Q;FZfO^(EpW+GC;V3JiQZZq#>QcxWro0So# z7}|UZgq<2IzHgp=@|4xt;(FO)dgzK(y7k2Eip`l@*XG?C8Ut}@9$bnVelLc`gol5w zrk-IE<;1JSiH$IYO)ZEd(T}=}*tca6Cr<4jfYT2L@jPXX*FEEV@!`ntSP)n@y z%Xi)muuV2fo({D2bU0BEkFT{fWyPS`O0Uir{w|tOMYg;kI8R#dxFEyc?}Y>y`W{JO zR2N#WZ|-}v0-x9b#k_MBfiymF3Lm2H)5GxA@$!Ei^fksPh`qj(G8dy8>SMo_l7F~7 zik)ovK<=j>aC7QH9Axyark4abdHrzvfM>?YZX%#J$4#=>?Xms_0vevuR)b)rfKc$F zm@BcQ-R;Ugq0$=5-WcPMal08kDph4Ys8s?{0D5O)P0Wr)x9t0Nl~WJMv>}3WdY-+k zypot0?uHwuIFsCW^uN8`%F+CA0$xc+{m(E$ufqRmikO5f{`b#B4CVhj1Nr@C%y$GK=5lhB1Kp(b&G+_r*6syfp#dc~2$l>ys;57P0E z4$@Y>`RY#tny@E{z&6!i$#9$UKj#0=E*uc>2Wf|v2(lHEtmo3_dF7@Kx351ZA%&6H z>)VD|`Z`eVh#A+AV~;eAj_;V*JLSYAB^O^Psg1~D*1AU{0>LN z>)>0T#IH6!Itl#F$y#SFg`nNlm{m2d)Xy)vHk85BEmxlaG)u8~vtvdk)wV!)r$XIT zIZTBbK1Z|^FkNmD%)Ss_0JQetn+mZ}fVWoY#hftf2zv7tamcHNep8PtF4w3H4riZt z*FWX|?!n}&SJP4SRA|=4y`$62tcd)eT?{>BjVHDdQJUcBSajC%cVF{GY?ZbM;X=?O ztMn8fx^WQO&Di^cdD-(!@x5%GAI7*F4d;Qa$Rn^(izXQoCR5|_0InDiUN(cr=LdYZ z)uym%>e=N>B~bcdu|a~>{uDyP+sstQx~7$xr}6=DUH^i()j_ZS7Q{QQ?>V92o8E)R z`U`y=%Ezf42H59?W-_>|^COGG+r3flZzjO$5B5KAR~i4k%FSn<^5H+`DH;DKeZ1Iz zvFQGlugcK`xS>mDlcjz z{HOCqII*Xkf2cQ$UD3vsj{yM{s`_rSE-lpZgC5AcQC z;lKlmsiWzcdK^X5Wp%)AI-j47Tq^+0Xr;ml(f$~YXL4uUI+GNyt!<1RxjZ-PUvzg+zK< z4=yh|3xSeyYc@(gJQP{X8Tl1nf5k-?rv;boDyb&z<60lej8=U1Mh`V4?aF!R?W)5G z^bb}DsgF|UkL#35u^XfB;A9DSqS9w@*Q{=mOYT(Xzl^XTK+R-kLzvcZ(lbZAF;sVOFr@qDUW|%wu7Ey=Hr? zuceg&=p_@ptFAsz-1o!y<9X1k*w{Ypse!{b$?05Hxna%E_eyIq9_gy))6Asgoye}S zNN376?cUqte+=W$TwfXIc$WEC;LLc?-b+z@mjfO~UrD*#qID3`RL?hBw!WB>qNSEw zaU!Bf$DG&WILe1Wt03K$pY4N)e!CiXKxuIo5bD~Dh_>f0ZA$5UuPR8AC~!1dxnbnJ zsnkbsjbpjW9D2*gxk=Tz=MAhkf!ehaBR@w{RkZ(U4z^Oh3%P=**Y0h19g^Q%|CN-1$0MfA0RxUHi|Nd^F z!*07wol{5TPJ(poP^ddCD?t(y5`vV*L`#21&pXz$9A9H>xUyVr;NrVh0$s9Ir&<09 z)5?Vf6J}8v?+eb8B;3XsVQMTCn-oLPX5=Db;%wKKC&o zFLRHnswC9Jm}zqaV!r%s2;qww;Y`uQ$2rN#rQI0c&dz0Zt{12D308n4-4BTt6>qV< zCZsEL0?MdraV2#avB zhjV)(>hgIO?jXvIbOTDu54{jage5i zbpK}7fOu!4n9CS16f9Oxwt&2wA)F4JYpU$nx^R$TUzX{GS!bT}_ZaXPVG;q9eUg3g z5NI<3OaFl}!bxI3-?n3WTb`yj=olh=#T-1PYZ>985paZfE27;KGlDlF)02L}3}Tn} zjug<&;x)2t{qZySchg3PVHtC*I~G`|q$}K`lX1k?W)UMd??8c%J^@41xP`7oG~XDC z@1o2DF8UNEdGq);0uGv)kVC_*@BII2|C=S zrg#ezodZYRw5frsOHxMv`Xx#X(xbJ08YJ_dlbHWUlf=T!?KALYV`BfGGGG5AljPqj zN&erW|7MbW0y6bAFh88w*sm>)ipLvm_zg-O)_u>GkUPU`_Fz8|sqF*slpCF$MT(l(e=|J7r7CG`_GJk}+DXw$g zrrM5k4~37nvZV7mo&vt$ODez`#x9q6R}&xade9j%Z!ed72m2ct1#Nm45^ZE(*+ zVhQ=Hi(qEcr1$+!Z&;3p0_>)|R8Bm)X2C5^sbp+x;?FH>akgYOz6)P^8@Hsyno6GP zRd=>5);X|oYQ){%81iHOf-DzuDiS1kZ*(2Kxm^3D13Sgv((mR+jFh#P9E^+(bq{fc zeh(?hM9{n~bkBi7#ApEnSSpQ`rTsFiCBO-q=S2KhEb?#uJonr&h~K&}>t|tSRxmr+loslL*8T-^ zd+_goXwIuKiVDHHqpWq6b5|)+#5ycbP_lCj7tqTjSE@Tv zQ{-qh&vBn>qxbqf>{s{TSP6g3W(mS|C+Lq;mwM$+8eTxC(Ks04uC4WeQ^dqnYc6la zZi{ykZXB*u#hM(udRW-@t}LS8%+H-CypJEkY`SCp%QxHt#k<$uQJdv1 zW&D^e=dy@O`@|IM2x7m>R!x&Nl-*2*esz5%b1)K<~s8~n)yBk%w z@whe$Fe*inrn{sC(@hNgX6)#Gh#l)u7M5=zUU4^*k8l=o%A6`>?@=(;V(7)0>6Dgs zrg7LWmfJUaY&PsFO-~Q4HI}4I?NDmWI$iWb)7Tz==@uKw)jt`kcW^C_-&9sP zaDK86=wfB*Pu9tyqpFZ9^WS|lG~VYB+og-S@-nU&B0y3! z)Z1k}c3=C^6Loxgvk^P&p?2j}xDQpL*;0MqTH)g7H+jF$XQ~kG1KDud<*d{nm;-U@ zj;BwGdEqdbh^v&l@^}c_$U&|YtlF6`F4e`Ls;yX2e6S0YbN(~Q?(#_4B%xNzz2+n`Fn0#WYz@;RHzw4z{4aZl^c$5eCsq#Ma7hiW7 zhKA1%e8cBjVouXd3TpudC$X@qLB!A%GpvgVD#GM~x3;Eq!gfZ0^)3a}?1dt`Bf!`p zQoh>UwN(3%P?O7szuc}!P7ug;U|Gj8$AgL|j?ZYNp>!oH>Z3GdL#tmTdghoer`c4! zi|8OgBX!f}qif8};~|uPd37)~wa5n%cPq;omt9I|KA!2uj6q*|f*c2ft;bdTV;ygU zi7@lPk`miu^jfay!ca#68~e(Wu47ZVl%Bqbnw;IZ__CAeF#F-qpSaMqr(NF|bORS! zq1POmuh;V-2FiRvtSrz#UCh*G=CaiJfWMvIUlnet;jieD0MVzm0s-lOZ|7lPU<_scV(uWS}xD-DbFao*6a|476~w zF|!Hp4_Qhl+`w#|uVlT0dkKyb*@d-_Ts!x9s8O}C^-=U`LLI&Iftq=ueu1tNeRvE5 zx@$zew(6$%70xi{&Nz$K(hDF{{!6_Gx0xV#UO!x07nJH7_gfH+_f7uOx?eI)h9A(KiyUyx9S(9gUgZML~>c z(6k7(pz%U{qLC!xY_zR96vG z{A||X9+T!OtLEyD^l*-c7wb#(kpxxieUIA2!}j6w`lQ>Mt?}~Z#aZ@(Lg+2h7sIjf z3V)~%(W;<5^%+b!!;+mtxEl9>UtmzURY^etrCUtN8Y8om^>C#r^qz;=K?XP7nlB8U zrOF&M0x%evKl!`0=)FVt=V|TvL+cE7@k*1slUTn4#SO+czyn}VG4Tg824<;wmuTK- z$2Q{losYl&*Szr*unS23Y@-`-|IO>|-j4A^d1(i2#vCl(!uuHRHT!?;zr z)af=K2Zv1Z0S0x>l*U>q=*`5ch54gODF+an(9*8-V*D;)dFcT_5Ib!P3?w^5bUJAn z$XCxgHLBK1Q414*)u0jsmMdFCDee)-$)?n?2Tk8t>{z0;DCg@;dDTL@tIEyG?QvaA zD5x!$wsSW4gy<~?7j`-j`n(AeK|t>v%;2{xPCg0d^)jug$&lX{uh)DGYjB2CS{|{~ zrXlc7JLyfDw9xm<23vj;8)wg9r&uG)9(W4iD%{irJjx@rv#t+zx9N--XYx;#DNLHV zC*lyjkDv28P)qqfpx-kpcSEw^IVCMojuDZIVUids*5x2;dsm_!+i-daf`jWYs5SES znLuK5C=t*WMTYK@G0ogd6q-EAx}?#St@8I0+*k(lISj${7!o$;bbo%?3}+Dks1~&c~ns<9wX% zf8vH&nwYuUI63|&;V1q7tB%ya3W}PUIk}pDRu*^tJdxn!`rrGEIQJ{M^E zL|~Gtwbrl&Ov)GtvP&jOC>Bu&<`%(l)7AVIV5vA_?CwI6?vG_-+5w_h$Ns?pCuC=b@{M69p(Al zZRvI0E`0*wRsg4;P&gM{C7S2aFBJX^Kl1vNpl{fpb#RrSNcKTe_dCaUpu1NBw4SnZlu0! z5440#I*oY)hB(E(ZH(Ydk>pd&xg{y{XDghBq`Ht7Djm(kZt~So$`irHStV!ss5T(X zK0({%==4(|#8Wq%YM*5nA0kj^HJI_T3!9mvr6y+1wiQ~K&g;&x*5mSXouP`4nlH(* zvf7_!CO1KOPZp6pkcHP$vIQu1{2aWEGZ`8}T*o~DL22*H+mF@7Od!B79o?A6`u?8C{9RX0 zYSqW0@D*&c_xzhSVG}RuHb%&Q7B4C$)Zf)uCOdYm@{oYyHSKTy@cCa>np;g|D#p3rvGPqx34~ z)ne&Nqz)CHy8>)4^$GO<7 zc3&>2(bC+sMntm4#kZJ4+Dt~yT;kph(w=WD*^5a_W=G*LVkoU-hNLo*`777&S9P>K za?HI-=fPy=Rb%+`Uq`w;|QFFz{u7! zSKNIv+T?*%c8dvf4r(XXso~VCgO;YF`i_8{@?vyahw-F}Ity%ZBAt4bEujO!>%GY| zJ&QeH^zHAgv7_oDp|cXlWjM@htbDaW*=#cRnp$)iUjYk!7-|KmGh;8s@e@n;q0fa} z6Mh>D1@?TMO%rmD+I8sbDoyQT{t5p-#x4D#rkx%AWG{uMou@d>j%Tv0Oe>m(*F@&* zWl|-&z_YU4{_-SwxO@lHLDKQLBZ(b#+n-;Cb&I7`HEatk#mt-P)XPJ4HFU*AGuG5~ z0he?h%B6DW66gh4>bgn>{#c=ACO}6lH|`lJ#o|$W?+wO8x=@;jq~+=C*_RhvPNKYd1DS4+e2AnurIHV#+s}O&@mrpd9i=B%8Z}j5q2|Uvg9Jw zcWqHl;HN z;IWN!{Lfa6z^(E*R6NIGRv>b6Azkb|#IJ4+Zts@1QrYj?C9=S)BD3hlhpI0(Okzrs zYav|+vX+z9a?5VB`dece1ip%(F^nvWDxcycg4_BDVqri+$U*z_#g?lm)Uui{RShOj zXHof~y`YA2+6aG~jB=ea~YDS(<5^E+`v(=^U_=?Al*JHZ|7B# zi=w!LzYk;0+pP^j1_sMU5Rm=Sa-1`X`9x{|Cv2I zyYnx-S@dfvYX68lw`=(3fxg9AnJHAqd`%^@h3L5c9EdmGMz6Eroz zD>MPqv2_KR$ov?6=rb|PsN|uxIvF@aRNm|#C}7rwIM5$dKG~YnlsFfi z2HluGY3IufyoDXi(n+93VE#r_XBj}U*{-`F)u5^C_Q`g)STEV!av`t2+hot-pIlUw zIEu4K(}JMda*M`3#0Hp|7>jj`beV7A&L&IgqF1bwlaJGtFT3*Ac!r#~f_~k)s$|>m zraSI<4FAF2QVctD=oHZ)ZGT2E7akH2riz-aX^IW!f!bU|Jv_x#a%C{%*QFXITd&Eo z6B}zW4Vib;229oKZ+jeG@UG9!dos{Mm`bW>HeH872qFvu82G!Md5traQ-oga8r5w_ ze?Pcs9e4^F9lFPE_n(h@26NLj-cF1BP@EO~N>Dm)?{hF@h};zC=yqZX*d{BkR6J&P zgc^u*@!?GBG=qYR50tB1@zlJEus@4d*Q&3#y6}RuOaDcUprmQ8(UpuD8eD6_>m9`| zi7Vqv$kdf+%br$Ex}F-Xc&PkknWo-Dd;CNMI_a!qENLU_L1;iV5Xu z)o3N#<>%=pXR73(pp9o)$lXZ&4C7-v^0=QT%OlOm>|BnxO0fOda*j9oawl`A-JTcg zm(Nj!)a5s~_F$3J`&yHJK3jX5$vcgn)e8bQOeQ%>5n9N& z+MkO1hQ~M)$GSGvxq5o^XC^vDObyIK4Tf9N4u>q*VD+>hiIzvs?rLF&UBLE~5M}&N zcOQwa2A|WOTO5ZiW~eg~oHN&by;wrLTq=FhouRIewxKqn-@LKlm%pV-J6R?&>xa7Y zX}jSz?Q1D>*WFn_cup05pn++T=KV&na2*E2^A=tTv&BXs5uo~}t{fYJo&UHTdUiCs zV8k4di9AAhi`jV39bsr^B=TN$sx}ChhN}O$`qb=Gh1l%Yp!mRdcXHx{b;tLnC&tKJ z$hyE5?~$gAjquPC1a}_3qz2Tf^B%K16Sj>IPlC;9!00A@XTIUnS<5Gr!IbM8^ad z;4)-kS70xYidJJUTo&M>O`13=K0t*>&r3_(#ocO1N!}^W5}?LFiN;1A#RWn478c-Q zZ!Vd71!Z}9I?kPM(YD(~ZT3qR4~G=yT$ByB0^G$1uXZsr)zY>&d<~*NFA&r|)g7=~ zeWZ>ZC_PXdX5`oT3IcPnD)vJV%{OstV_By7Xe)6~q(Ra%!PGO+)V#S$`&a_Qvz<`} z&uE_e^ee%?OqmUbh5W(aBB$Le2ERBAiAI?uygEmOx$r9(M_dh=@I{-jv5Ij?ovIMz zTe+khu`1^ELv#hnzLH%PG4JDiBlMCD=_vM zP3f%Z`{fC69Y`e@6LJruI%k%in%ft1?=m4b-J8I)pM6i8on{z9+ZEE-@zOmgx#Q8e z!*C@{?N?8T_qHCWa!N{(xF^O+x;n#(h&xP)&MvUjbAFZ{+B-s7^yVB#i+P=lv?t(} z1&U}Srn0l?MW53&qz={mJj@^hrBl^AugdT0{Y6xOnzKJBmP;Raw!`AZ=ui?*I&F68 z|HG!WM;$tCbl*FH@q{7^)G?wSK~xNLqn;PUDQO-n=v=x2bkG9#zJV7<$1)=1%hlCwJ>PGA$M_;Ln}p0pm%DXsMyoUo ztv&qYcFhX0B_T6J&K6*-K7{-mHdGInxP9n~yRFFB$BZpNW(axtwmTEg(fl2TWnh4l ziO^v=XPj~LnWf?7Se)z!_uUEp$_-SJ-94BsfV0+y*v0NcS`U1WZHE{x+*@LAdx)^> zuGKG44St$|7Y}OV;^d~J4HN|U!xIqn!s)$`^B0E_Vu++YZ;Dlp^gZm^$UUyd%4Z7j ztl&RY{QJlDAojPjClIvIL-=zc*#q@9)IaL81O4xpUc@h7f{6cumb7G6g9I#ekFo$+N&F(mBVaB0GOH zNEp-yk4GFc{Z6yLY6GiGVzbwuy`Fu|e>{;Z`1W?r{i8+OW7oJ>@@u@lzz{mLl0nMN zL~lVbCG<3|96npBWisit7BUXpdIcj6RTdi-@w_46#a1Yhvc8z3goygjrP((1Vqr`0vxJ?vbF3i%^JU^Il1MQakFQ9C7uUc z)CF@XZe>2fQCY ziB%&5xiO}WbM`5J)3Z{EHJapmDA?9;**OM$SC|ixZs}ZipG%B34?f{U z?qPC@hE#Kx1RjdfDw~a#CyR*$V5L1O=px~n&|>|4ZH*XX=`_25N6x>k!)=e?s49CH zyps3>{GS&H3#P_o?la6Y`yazR0{%{o5D7>AgDyUZKdGYCl-j-$lX<0c1P zBNIYoWFiAwEy6YsD+arJqTaS!T)Cc)|Ve%I5t>pxqdZ@Z_-(!}7kA$!19^lKnU2r_M#3D+z7 zIso@6;`$BK{|hn3WVpng2_*ClDlReRw%_2yu*97U>=SKSpD1Kr&!2)PSzP3Z>)@ap zwVn!O?k89Lf3b&l%SS} z!FB0kCp@1`#&61{nf4a9)Q)ysN(#fVqB79zP9$T151rH|sb?>zL>QMZ0*kb6pN@E< zh?U8k0%s&TS?o(S8Bz<3lP@)BXr$_E71}(Dvh{l?N+;R4LcUz^vV$OSq$88~-_y7m`;v7dze}A$q)I>{2V%W)_>O)d^9Zc~_*pJ@b@sfSag37LNyfG<}@b*9H;?BA4`|Ir6IF$ocdTEsE>|2HVnlHMC(g zx{lc2t(L{fRXyJ*^A7)BDD1DEa%V=8PJ>?U-~w;8`(^e2gpJHMz}stM08_yN&Dgk1 zbk(CDBpO#=sB^l0ut$AAPywXrH^h>ct;bDc z8a8M?Ivt5pdO)rMf~8LMcFN4EIgHGTIgZS!bxr6Bja%5S$1@0#QyQlNnX>8j<17@{2-q?&|)M~OxSctG3oxCV(5j8@-? zvca~Y*=YV%x*aqhsln>jSc5^@xkXDSk0~K_B}BAIEm{$H9y)bhn){lupEGz!S)(vs z6uL!orn&`ll8q@2!Vvp-jEmEx)1t+5gN-qT^2LXJ39%F#oWcPxJL)y6?A6BS98WhI zeTxJqHoG^Uo(B`^TD5vPP!p93v96gadChQ_8LbJnYE45|fe>sR@ac%`tHaH~0hgk- z_=e)e=&DNA>*!5n5I zaE9ZEUoHz5U@bezmQ3eRNKe@=SA6N-B*%Y}DZmcHsXiC-H8potA)>Y@gklc{-hGug zeA37klPQ$rI8}ojoD4ok5LmgY|Le{cqGNxC$NIGSvOb@c4AJdFIIB^%wbecNu(dt* z8-dIrzTPT!T3S+bH0%z_$$cKHn@JGX@|6p%3nJD*Z*A=)#&;J!;3)*;x{7vl_Fdh` zReuEc{e?NWn+jh4gZ$~TD(}S$A;}yYU`k=}4S>S!{^o&SuE;(WmZ}}$#+jMTDDskK zth4cvV?Vs^N(VBhUb6FhhGT0_43)-B&3B{87)`fy*ketTQsQxFIyWINiJZmw?l)V# zsY{kW{Ia*9Jh1?&mJvlVWuLK{UUo2Vnd~adg~#^Nr>b$@Vw#=Mw%dpY=UIb}-N1Tx z8-^V-H2@vWUlwg>rs%7; zV>#bnV7{qj3s2fj6=T@q^}zBPSr(8@P2GK7r?Y$|uTjRl0ZU;WFXsvYk}j&$cWl)1 zBh$FqcRi-JwfG5kbk32~Q=Hl8_D}CF^|W%tQ+A>*Awb&?w%UwIzb#rqPt^_ zX&dD4Jgg0*XkBGfd>$d8Ulhh6ul0%aENXW(EvtRx2d<{)3s25*?t_;~0Yqa5a*9x| zO{enBG)Z#2gsIeX6J1p!wsi}7=HV8_ry3JH$*Vky6D!Q@>sqSfC5$QQelBqAi)opy zk~UNfIN}x91byBFI@Lj5zC;K<$a>p0TcEuVvQzunq_>NtUBxq2x0b5`yOyQOYy1id zPi7Y1T9Px*rokV9tySJ9^&Gbnqzwrb2hVmjmRr8BSzjc$Li{wO@*k8_&pe< z(i2M?*y(3>l#;~+F*Ii+6@j?(4I>t(rg@O1(ZqfQ+=MN>U+;z(vJlT*X!xif;X(p%jaZTqQr6iB&!-qH7YK?Y&TH9m zOn!om739-|=Nx1uMHoeQHL4AEI74fVkm{2EUf(E&7JDpABgW4BF(&Vtc|Q;)g(f*z zIl7dK8Hfhr=OXiu!OL^LV5~~<~Hyb)m@}d4?06uFyRsb$P+plL~O`ODO)g)!v*C1R) z<=lff>>lP@Pv5S$@y_r~O9$l)!kx`SX$}P%H9X8-c8@Rfc!J?9U3)6e&8ft_yh77oEZvjv< z{jw+^wCxx8B*vTMQ3&K}p+9o0nzXm&%nsYLrOn4q?7TK9NP z3>z}^FltBq5%3dcs#i$*5q^5z2W*Xs<-+D>JzQicCt5axt}$s~=<}FqrEbWcJlWL< zwGo4Hn>HJdaaO_{8pqMRcfVg73i$Hv#EM*NM+j$SlzPhoT>S&iQZ_;^q6rX@*E7lD zvo$CH`_YCaTVifJc4etZ`sRIUGI426J~56{Zh{ifhq{39Gxg0Q#P3F;tL67D3{Kk1 zFp9A{7DxLTR9(W1_HHH40Ga9LHA>fD$Z%cJ?4{Ylfz&AVYDDRPmQBjHTQz55frlz3 z%L6?6Z$PEK{YrBflsS$(_mg@nnihxPQ+CSsDNxsG_f5w6b;ihU*jP~e;O@6!Ub#l)=m2jlVVx3h zmI(CXh8_3cku4s_CQH4C=Wxadq5P8JTH$?upwsa8qH-Vna%w=IW_)*}cXUI8v(uXT z{`C(|W(!eo)YnFWAhl>tEe_{SH7&8>RF=qtP z$MU9NZLOgiV!VM@w#WUce0Ak~MIU4$38H_G*Y3cxJTwQe`@uA9Alk#XNOL>8nw%7}$L zsi`af#@PhK3-84L0{ch3Tx$l0sedlc;}QKQ`TM_9FaH)4P+k8-h@%Luw>H^rq);jA zo`hn-k;;JJ_pm||)}(w`REmGf-89$bxa$quRp&$*?XoAJ07dq|pJ@gz_%sr|MHo{% z`Pu!BCNgH<-ybfae^7g$7%zqfuiw?W3=d_(!=E$p;&X91Y*?iGQL3tRT6(X-4Cxnr zunHdr&_l{=9z$^f7i^k_^A~oJ-NrRi{3)4+lQEWD{Vxa4M zhoNC5Z37W}Tt|R29~{=0(w~=?iQYA&l95v)q+E2|M*77@IG*^`#IYUOCx~pmB23qm zWpG$Sg~^GJ8=YVa2>6UQl#6)%HN&wg`5DW2`{r8E*GhiBKbNPg+s@I?h3ORQlN&wH zqwcTWI0bB(nk71_yWAzZVi)N0-}hUHEGhF_=?$h=aaS1T|0~bnf^S)N5dWULp-|S+ z<-L-a%(12=M;G=JRbS*a6z#O^4>7&@a5+)HK#vg1f)55E&QHfq0^$DX@rx5lK9E^- z>Q>-~Wsh|nQ_k{;Uof2Hmr@5Y9NU@)7i24|0Mvj-3Lm)cng>C;#v?F(YC1?L7ue?h6m zs}rsT{lBi2#EAabJpYu$oBvS~|Bnt=N}1SMC|O$C+c;YM3mg95O!|MU6cv=*c|U+n zJ_*U^H8ltLdR<4;!0enF6*YQg7f;;_IrK@D!I)u!cX362s4(Nx=vR}2mP6EZ5l@Xu0Os9I z0zR4=f+GRI0mO>H=&aDPZ>I_SixN-@<};V5iBZ7UwIjPH^az4VCQ;#oLEOrUl#M71Ja&sVLEtTmI>3WC~- zL<8wm8ClLII(lc;!^E21Nmyl!y@XgXVu`{TWY(&Q;xDL;QF6={odv$&#V8~1e+zq` zu2TTURpiy=cveAogaFTGPwB-2U9P<8(lM6EJSGHfCT|i_x?ZCUl))V$X+HueXTpJX zCMoYw&Tmi@f^KlR_ZPI@N;4Ec!H)Vp5SFuKc;hfyjA0m`>~RqK5x<;M%%Pl9p!wVg zfE8AAG_=C!4Zl@S64WwyF>>Lb+SHlYq)$r8F%}8`LGKhM*eOSESZN3zsghW5iOJVZI#W-1DG`ZdzS_Z9h{pE-4) zdJNjrsaCB26D!Kf)yBfo+4Ym2`?*TtNfYXs>dZ^pg<9U#j$X!%Z8=+Iw?w$0O&KhF|Fs94U_lmyI{a;YI$5(YHnU4T0{3; zq0i@V zEv<>_E{Z=79mH>x0c;Q@u2Cwe zEan%)>W)^hH$wclx7g4!#NBeR^#HfIzuHiXxd84!3y2VR8+aoKyPXCCC%qHL6^1Jy z5XOqngDKBD+OzVe!xkQ99@tMq3!vOR)mPue1wA(zzsJUG!-|Uyge1`%t5MjrEk8Jx64I;=z-h+IX?u$k~*O`??h3o-EQ#Z?C4hx=K!FMYAV|_9&*5%tIAAjNTPbqa6|<80nVy9 zhJ6ZpmC<2i`xEkx>?`@SFP!VrnKKs5LOLVuOp=6pVNB+AUU4GuDufbHXeVx@o>AR` zbOUr{VoF75F1RMFh3Shd!_50G>hzMEvCt!&5o*=C5*63y_PZu>%(9wo7j*FO3ob)8 zQuvt+r)a*#$-mCQv61p{@WA!!{_0s)^kj~mBWP(dTx!pF(6o$FGIG`|t(JPz82|;- zr-h`o74f`16-l6AhDD%kxO%ALW8^EyqyU3_N-YWTLSGn9S)5o9gWbj^tT3wETWt|2 z?*|ZOg>DY5&mFeW^yzyPu=X7_cr2CjrQgMwUk+4L*SAcu zU)mH8(VyzC;~wPrI_Wnh7qAfLHV^)F_Wo7)!o3SOec32Le%CQ;4(olo< z$_cht73SV2fEBh_R%}b87a-ed-yV5|i?C}I|p1mQSbi;J9Ov~3|J@%L=2=3nBaLMoi^7Byi^3iI= zw2g5~ZiMP(NfkU)h>mt}NM*s8;1!F%bl@CNj<{7h8+h+@t7sO5-h%+v9QRv7dJ;;} z0CnY+>}IfWH-Pc>pWWY8T0X55ztDR-hQjR20@g8P)u<%)bj86f|g zd$~j!tvjzlZ;oOCl^SCSRmPF8H&S+Q-~wzFc}Ua@W4 zw%M_5-0Xc$oqN8oPVL&a?(JXQf8Oe@p567%ImdWLu>Hk$W2HM;dz(FHRF5QR%0$z3 zWDuFEp1pQz62hQr4V&oT?QQ>-7t|djoJ}ktE6IFUqFv?gE3XDSTCk*yb4luzFuL=K z$^I>YiG8qHI3@SKs&wpQ0%z~b<0VK%fTlof8^zdjx=ZyM*`=^XA1R9Q%DMPZJ_WIc zhEz;h)5wUw;`2cE({V7(cUn4kV?4!Dkjoxar-cF^ccmt}TaW>xI0nLu5;!<)m5pTQ z^7=lUn(c)Y=jSt`;Y~qOTPrJ#NXRy8D?JkJ4a`a^x}uE7PsfR$T)$euHz0p!4V)lS z@d7;dcO$C|UOG@u^W>>Y2Q$eR+u7>R?I5=&4{xkGF=a^^4}UtB8!0yGZ$pGq^ks0C?Xkf7R^ZCEULEaqy+3I??&8p6v% z^}U>O<5ym%YS}&M%_BC4*-Lmbs0fDB`s2&!rpj<6JIcdl!}4pl;|KiFIfH}&KKhFp zqi#}-!B|q`@*RJW%``gWE{%MeWx$&yF?CNHV_^c z&caUqxX_nkL597ebk$=a-B7U0IHGnSHqXCsG&5n+6=A7gAL#O+U6{3)aYwfywk^An+5t4GqWc#K@>Ke zwK6!p`R+_o7dLn{SoriuKz%q?8|xM~pqm+m9jvtBoOeXjofF#gS^WneUkV|(aB6?q zT`f+89o{3SV>FhQKWz^tq~pNXZ&gv_lv} z#g|PSo1BEdtP_AEs0m>VNjZPU#5^b}`49*)bJW*bEH*uwtsv(XYC%ndUhWUQLzCA*W9fp z1uF#B>Jw?AA(g2k_OLNmwIle|9om#6)o@2t{)XR~JIK};*GGPbLELZ_wQ|1#p()Uz z&asiOfduTgf0$kK?Rw>rCvthunXs9=E&DEMaIP8fAY)T~WKCChggu!y{snd@Yu`CL zx$0%q9SBUuvfLHwNZfJaF0$z+vvr=B+`JDe9Aif{r%?pa&Vdt3!)C{QiC4}CWSZBn z9vyGcr+LHr2X%wn8?>AU)vntCwZeW3?N_~jGQcd0TsN7Nj;j{=cH>^_MS3FZfL(4# z3{zx13mGM`KzRa(jKEGr02QCl%@gX=6#(TE(Y>Q`b9c)Rhx;qxRepp5l(oJphT%#d zr+0XBHtX`3sRi1#J>TNy_hd`wUrx6EUvw}3d(Ks< zWNG=W@Zgy**ff%^EaEL&Y^sHySE}a?&qG8^U;1T9Aq4em9iL@WB<|8@ql-`*HN}3>63}i`}-|y4`Z@os)Ie)ym?EieXOHBNWD2R!;#)r zPylF(j1A`qmzoiVJ0TG!pRrr!)4G<(7VGw|j&@_Gp5|S2q;m0@vj+DqFrMSug8;B{ zqJ@eZN<$zmjSVBQs?slvAur6Z2c34(dnz4EdD63TPFrgS8tIM{sc+1yvD%$)0>eHF zO@Q1ziy+OQif9Dx_uCWRazwVp85j}?({Ir~r{{hj#*QWG?};7B7%zaW!lIH^NqKL& zzURVYacf_X)qv5s9(&Wv!>kwl4ng*9k(zZg zyd+B8yuVN5NEnzgJr?v>c3!2q3C&|NyQ0)8ATC1iPgA=FI9kzVri zp_t_^zcr4_n7ALtlT-DI1Zz}zgZSJmv3Irl{PKTzyW-otxwOB%GAiG^(|=$R{^vlO ze~VlFzpM5iiF@lR2%ph3j)X)Oz~UP5tQ5IFHA(F~dYOacp;O`)QX7mI6FNqd4WJ|U z5gpb(^LUx&wTiOLx8L&Dd_?1|>C-53;W<-y+P5!#JRgs%yM5n4dQ_hYB5=l#BGe1y zmTrK$ruN_{)v5K>VYkUw!w0m(JdvJA@QiB1S;CydV1Z8DR5~wKfcIK^%*LOdSZSth zxcqtyoVOi1=c*p&C|TY=;yba`aM|v;zzb#8ZzY;gHME>Fl-6)CXdxr1+q1E&APVk+ zih1i+QM1aopd?3EY>;oP>y2wMG0TAqhOI?1?>-4Vu;duq!!`R z3q4$Ir(r$u2t!423`hhZ4&84c?h{mYzDnj)_nnbS!V=6OwK!!~r?c>^(SwP!Syhvj z5JLtB6@^Nuhg}59YnzRo3BhNBUQ`Se_XsQt;z^ay_*gP!j$iS@O7_3NPZE-|b}dGt7I|fTGSUy&X0Q*2kMvZ5XQtdlKqdehN59o{B7 z#t|x=l2J9i4J?x>@n-9f_Jnp2SMMtQHvfC{LOq+<7v`$>h-+?O8a=` z>SYTOAe6x(T24iY{qUX2Y_NG`!A7Nl;(|tm64R0L4(k?m>I1mbq^OmhxFXuzYltDc zev~_X0*plogH-kp=4Ij~Y!T~l;w?-mf2X^I^hDmsjS0#jDX}x@4Fm7*^mIVWSke#^ z?(#JSMd|@t)ET$&h&ZPOiy$>(C5k%5sozNKK|4W+$#s6m`{1RhIOj$Uf8OLpV>6#2aBB1sOz;3#jQq1a=lZ=Twucz zSnc7s24uZ7GZlr6oi`Fx4OC>TGYSIa)(L24=8#XT{H^K0yhs{ju!Rj9qOD`z+pf8g zcP^@R#uU*B?|!~Zms}=?lU`RD?zZ?mu7~&uc7I;(#BhOji1b(rEA2VI z+oyygTps#YANfDI*;k`y5pMlS*f_@)uISJ3a%0-sBg@%3=x@KlLwwprvF%jtdFyD| zj(GCC0ixqQ9t`>Em0Hfd({IjAzC*O}F6w?{NO($5sTbKj3@UZq%S6b!R}mTmAV7o% zAQR&Ck_mf3k%4+?^q69BOIrxAWMGB|u)JYvReDJ2lSh<5782oJDJyI`RErROhT}`!=SS#vMSRw*y?JwFd(HU&jAA5mqzs>7X-qK29g3XEhI6- zNi3R9Arlf4l?*3Q&5<$o>G~*c$ueXZs+^TW7>6?Oe!&ao zO_)vExt3i8pc%c|Bic-PSfr3{qmrh+w2(rQrl%6ht(v@<6IO4B<`JxuP{k%)7urQQ zxEnNNG?D{0ROP(mzb@I4l;exa$Y6kS>R)CH3xXNnTRbWGG@PZ0l*FFnfvv7rX-6MJ+9ps2Wdm%aF%_7>mP8gp)h|;S3PAIJ=%0W`r9oGh$k5v{MWC|HDLj!FW`_IrPj?ZhGn03v?f~wD3U0RPl)KlO` zP!L%|DxQ#mWP&=U1+v@LuFS`{e{ zT)mlC1HPpAY9(ch^TuS7OpVQpI&5~pK)ES*CEX&)M}|q50pkNXTZumG1iSX!zk~Y3 z%1xA5Q6P1Dk%7A?cP*dW{@99r=U`snt-UkjE&Ao&Cq6Tf5d>8mkBoc77-R~DQSP-2%=loD+qL-Gwy6Tjnh$6iam zOZ0tf93i_06$b!t-k5B^c3hFZx4qYTU*x;8&rI?HeY)4Gw?6Gv8NuQ=mnsuLJSK_m z*UhcZp6Zav(}R4(-#kR5Yg~$d ztGe76E7F=_rxnXrL4-AFuJLJUchgGh%RML6?Ziy=TyXE9LtAYABh9UkNDhsd%wba0j90+UM2z zNEtPpsJ*3<&X0I`LS_wsqQ6}GEsWZvXVED}nQKC%CpJVdqZ%3~=K!6CMHKe4lRd&= z1J8$k7-+^?DXJM2ZhwpOP_jw=wi=z@%~bA!#Z0QxY=Iix&+o;zdKyThqL+Il8q7e- zDUM%eMrsHgqHr`5^+a5)XshqN1&TUoxse*~#CEQKMiVQ0mKS=HbSWWO0@m*i=HY-Y zr@mW;hI#YY{dZ`L+^Exeqj}0=O@Ah=w9&XAcSSfQPQLBqGRvG4NhpG(qDOjCM4!u}y z*PdWWyR<mLJ?2u?qbY`$v6crIaG%ca!|XMI1FT z!J`hPR@>5j9&2N?uJkxnx&7rfO(L$Rr7c#ROJ1`Lm@0V|8?ObWFu~A?*nZ05R=k=c zc8mL&=@@h1NpeEbPeVp+aiiXh+xmo!biAv`D+a)9d1nFUgk=lKe}CF68ujmRysj)n zxty=Mwre{O7EugIXx8#ab;S~X(RX!-dyb|#Ti%*#oz!fFd#HxW<#MTdYP7GT&ak>-4Z%8(@iz^JN$puvlp!VXq4Egmi!&vAuO@8R~ z&|>jn{Mp*U5qt}_{0jLTHgoyM6Zj58#sI`tnV#E!3{191_*9u^5NIw-w(VV;Cz^km z94(Xci=BdQpYs4HWjy|lZjb5gJp!ako?89s2giOLu!eN*4=VCM$`JClY)kyY2v`=e zA~ewkxHiLJR3j#CWUxKJ=BDrYzbE2y;yw_GhsXpTX#5r z&s#g0myLgGc)?|WIzg|H>3z+YRQCam^93KxSA#Fd5&u@#l9WqEDj>5a7p-+d87HmD z+=ZzECauYX0H|^JDGLYASwI^T;2*Gj{#`7XtgHpPx>5&KYdW zW~i{WGsVI)%?bRobFPSQ%kj1k8=HTJE%99Lk$_S6(m9WGAF9A2&sUin!c zZvShC0P-~{60jOAv`KzSHE3AJ(q}A_)qO|wQ3*FRR*AF6o!)W zid`p5_m;Nh|FMR}+Lv9U+*4vnp_wYbYCP zqs&Y%T9P;aKuG=#i29p=+mGi$^$=r7*N(h-u9F8-e2kka*yMsNTwUBaOaZO?2VJ0m zr7bMDeTPJH-5vy=$n$IzACp&O_fNikqWG~eiVaTj)hI?I_x^B{T<92Zu}<*q!l@u% zF?S;vc@bfSJ_Sx4xo@m>mcWZgoyj`x#M)w=3m|%vmv|)InkWHFbJquq$i*U4kpGX( zhhntZv|cSs*B7@_3n(#YhZ_G_GRfj73}eNfar|h*B9;O4F^zw%MN=p!LXT!vhZpu} z2kuo5*VjK2mhfr;e=xo&B-|MPs#E^P7DkSN_uO45zn8BS2q+ojNcyI8{|=E@F;vSe8GwoTtW_DSM8UAYRd(@K zyWP1bnLZ3!4Y>*+rwWpSM&>etKcI%sBg*xE&~j86 z19Aj|jb(5jKMgr1$dv)Gm@C-9Xz=}puu8D1ASP~JaTi?03A`?5Su`cKK#_;0^X_34 zMokzxJ;Ur6vct zsTnYj8DN?xL-DuZ%Kvz+FNFB00APji7MDkuJ_z^p{^fW7&pr(euxT&*54bFS} z85Te{Wd{+4`uE07e|o9(ublyLyeLxQTS@=b>PD%#st_EH{PR`SvwWK;4|{5F?)X%4!6b0G(xl(?(*-Y7o>2jP|8 zi^IPZZnh~uMMYk6!@rbo@*%Q&VvGf3DWCa3`3RT`COS?Y5Kob^L?L#4xGWJgf+src z|HevUPepmG8Aw=-OdT&FZZZ_=5(jre&Xe538=q@2dTz{;Nl#}xB_ycmZ%h>9GI811 ziB6NrroP-%WH~0hff$*R8gi-6Pd#x3U#`l~#iSuFkUK(HA_)#ZBzV;Aq^UTl<(yx@ zyjt0DbDVNmg+Js8uY=!bUL64wO2`Ms;?!l`sM|8SY(3m}93_j51{fNmO?MuXo|W}M zTBV2>U~iO9rvZ@h{Jx-{NqHHQx|aIbdtl6b*8Xz z^uFAFn1-*P1*l+89KjZE&uOcIsjFbFH+CtRcOl`7`j1`T`A66bbWo18Llq^l7-42; z^>e6a!|LD3$*|pt>*i8QvoqDT6_be`osRf}&YR$`QQp~D)Fpc2-tDEQ&+~b?+5K&f zxqwlE%nD&5`dlF~9hlgHX6SD{s7>6xK7T*Bm)>lUTTxsTf5W*`lEN=z{&-_pV?I4e zL$;cN=Tg-K{hAJv?UhA+kF=ynk+1rj>7Re-rt<_<$25f0?JJA6@k&L_lQMN`d88cO zhz+?+c6il()ODZ5c9)#NJ&jVOL?R^e;a{`9{j(g6!c#R|8a9MpLal2go6tx>{m#f! z#N{$NTAasLZ4(f!ooeOE6m6|;zIkHCR?o%B{TBVcVC`WZ8SQe2C3Tnt_~FzrPI@|p zNwww)lI6!j6IMQoi8g+?7qwL4t9jXUAc?7 zRqS(fP(<93TQ!ip2sIDyKvw&5!I;DPONgvoI!j zQD;5<;FcQuhkuQ0yP&J$sHZPIV zxS;4sRk>6Wuw>Sdywu1%_o~vCnIS~wY|-Gi)TodmqAJ%cqN<>fACJDzYTUBj5yyzV>wJO&{FUR#Vv#pwngcO{v z8|8?=Cl-yH0t5;<3R@UR7Ur3HBokCVIy!6j%@m=xKE#do_6E-nzKl#OE=yKKdre&LG_QZ2xj1ZV zeiftD6sowntjtqNNjJifAt_w#&r0N24$PstFy#DlLDv$`P?|fp#9u15D()0P$RGR# z<`R;4X(tV_Y^A9)yc%dM&@-ABvZaHruBfFaI*mZj`sQHI z_k05I5h#g7oyvdF5#%Oq3nzsitgAc9m%JMwf%Nz0hk<`z2#`n6YflY0 zma}RFcmeiBWTI}}X_#F}kI6PJik0~lNslKo43qZ#)$4q6V^tFf-TYk;U+Iis%XIP|UiS+I!`#&kdP!Eah1BY3 z$qIMUK?AhVG`WZ5H)KBo$I)N#cAp|{5C!G2dO*C2#i%E$8k5IT3q5@{Ps`Fw?;g^} zoeQ3=|K=BY)HXGY=s@$5-LD66SHBA{TD-N4)MWa~pcG=UUyJaLqdx_OTSmozlp_T+ zu9TUA6AMhgB%8hv#%+xMVS!HD0b0{|#dBD=Ck3;jph_XL;lNilhQtX78L3J0Ypp-a znaPp|Jo?8?V{}H$qBFNp)>bbSOdsu(uR#8O;mKrkpXoh+H|+mK_9>%)J|GU8;V7tW`f^u*R=H`7L4VA~^k%)PrNY`1H=8cK*rU-bP5wE*cc*6VP z=FFKQ`vl~}Q~W$N`e0Fkm_lv|!GK*%AxK+DZK70>=bz~wr+^10GqjGv;@{UQy(#zP z_QqJXc*^M!9$1CyZ7hV7b(QkwYaR_PtN{msmC~C`YQ59k7rzI3^R;pM)GIQ3%Mdc! z3W_#2h=<nxLfl`PR8A_^(GpBPnhGCc{vN1h z4eY?s#*h@vwpN&9VHeG^cu?c0icar^XE!0WXRO`?uO!v(GqW;IDe#Q98)RTaS)*+^ z^j0C&2=^=kHzi}P|I|_>K(|G(YS**&e}FhfjWw`qplZse-Xhys8u2CcgM8z1G zt6HU8V+XC_AHzfZM(uk5c1a<{SSQ--oQq0q515NeZZD00Sm6b;uAE=Nrw=Z`rg9A_ zY;V|*rU8!5=6y<|#Rs%_ht4yc7oRoPMCs!oRtPbv+-T^818EI$bYnH=fne&)1Jpv+ zYw?O>d$f-SI*Yz)VEdSw z(S9=?D|Rgyb`*c0V>+X1wm~!Z=Voyj?ZHKP0vB_MQui26?Z_nWZ>WKDbVhhVvpY)8 zMbpe<|F8 z{5?@N&iXw=Q>A#%F74QH5d2K9H3E+;Zt1J<&-ThSh#YXxppP1*cHM~DaxJmIP3-6c z!4H$BX?-`>fEoB6uWP?k?-tHz;3vRFHH5%96b;_^yrhs!e}YiI z{q};uf2_r4&`TzGp|DVN> zx!ym>_%@7bT<&-Atn;8lpb{sH;t4XE8fIkXEYi(0<{ILv2>Zr|B<>eRCaF(Ftf;82 zN*f3%d3(VqY=PnPfl&U?X3AQp;dw0)&?+0_3f*re=A>y$1uy!^?U|latxuVES&mm+ zujf2ZKx&j&7PaVf5BfR5tT3-Nx({@ByBdq#TK!bl60pm=%2?m3m*;B@*h;r7`0C|r zFsRB!Tu<>Vv#Xv-j4AQSE{C`=W884xE&MNtNu3@ zuOG|hCp5fXa{VFK`ob@v1EMSwLzNZ>hCUm?0X`eiG3AHINICaJfwJOW8V{~wULqG> z#TJ*h00cM*FO`164VoJcSV_Bbc#cKw*8AFpMEFMS&;8~>!F)KF45M1*p%cTcmcpT> zaIKldmrD8}Dl!XboP!MaH)(3_ora~`Ve(}%Qu45Tf9H*3`~p60!zF4mO^9CQORtj*P|SO zUWg@P8u792TINdFKNiDivPQaM63NUinznBxuQs)2`X1&5!zqg^4T*r!sMIOznHb|k zFk|FTlh#<&HNAxUsbHrR-s-ibPH|DKF0!J%ArHJz+W5-1o;ES4^O_)&C}WZu2BMxB zqq3zgl#<}ZKIdtYcN5VhRpIV(&EmZsnZ$NPQ24bAvF=E8tg@$EsN}_XiQwOGLd$?ivqLIKQF$lJ6qJwl`e3-NOLtTXXt3AOwP}6vXf9k!ZpKMCDN%8@ptLr?HhR9uYv9nJIZKmnD(3%1snB3 z!1i;@03@#Lu6du(Fq50Ya6LN(eWd`_39yCvshQfT0J+C_U{7fTrF`wl2fCl(aF@Vw<6jP!o7u#c?PE7gfSF(R!VEoHPQqV;FQSi=Xj;& z#vBUu&PMOXp75IjcM{Nv>#7-b=op%mQ%wiMGaJ@aTj%B zaJQ@nhCkk3^nuIutNTcaAZhT0PrBJ-+Gv4T`NgVoLsA(>F$qa8J(ZLJW}B&^rhwJX zsMFTLp}6V%lZL{+`B~X6+~oNj*X2Ug4Ng1>;l;`XH{!Z`?3-s7qBs_13>nv8`JmMx z{(g#aNjO_x!(ZdAn$w}_v+3AFfeL@~k=V)J37^oOokEH6nC5!nDk9~Py*dY^=){dehDuQ!bBPQO=@KazSQsUtfzg9SaJ%wm zP?GxVnkHni*9d6c_ ztJ1_J)x@Yo3E6k{a^z@r2y8ly#;4G_^^_GE8@5zj_)8A7!j?3iL;I~Ahb-zu`Y~;8 zP~h_NcUUJ4Y5V9-<1KpXZa+$^3CNPj7(P#^n>BRwL!dlWZijDgKr0pYi6P-awn4G#o7A6~Rx7%fSZiMZr|O`$PJC z&lIxbiz$5*p=h~0;xi6DGCLa|+QoO7Wew-opzH65$h!$a9)Z+gk!UnM#PnJin)?ZX zb0Lh6g7bcb<+|~a&7o~)HCaiQxkFeSaR)1YGFsuNx=OufEb9WgAg;AQ+Si^C7*<1Q zS-F^>IzsC3&i?gfru4FTng(Zz1-3+!f}mBS!|%hS#ftw^AT+KwRuhZb|_*5aJKL_i8sJvF-nurs>(LVj2yFi5{QGyxd0 z!o^yt`a7%{)}E9qJ3)IW5jfi#@6&wzLVe>xgXjv~YFiwFZ=!{#kAr6ngJ+16{nuBS z+A}w<7`DCTu($v)B&g7}9aR{k0dpFPw5__wsWr7Uo^?5->=qXB4k#4EA70!?y(|G| z5YgDP9~f1IO;{kkJ#xNJcDhG((wh7b^4lit?(0{Moi^wkuz9kb7EeD;5fi&UV^b%T zEC@vpYZze31eP_V2_f6z8%1^-hWbG!=M3yjbe&{hzk1jWh^}*E@Qkt~77_I%BnIsj-_UG2I-Z!EVMh(H&7jqr=Q@_D4)9^_}2z;8P;f#j(sD6)n=i zrDInIr1J9=2J>Wx6VGjegTpK}AtCk~{F*oO<;D_v#l$pD~tJpx*QkV-~qZeh4j@kL-a~QNP ze}P(?zD6(@41LcUk~u)t($vi*8=I4c%*Sdb$yF~KlYT8<@`&5LS}q@Ar{U~;m%>Cw zB2ctgb10>xDjKv-g%XF>uy)_xE~t(;lK2}}#Zz(1J!*Y$ zs|w@t2|lwIt4f%0R9S{Gcy(EplN#;KM6WU6e7&dQQI<6xP~Z$Rtw zgP0frewR>QSU8XP>deiU)!|~K7O~?-Q0&+D^{@y0T0V5O5?N@E%*fot#bhe89`Nz- zHZ1!C-mV-HTNS&+P&UomxQfDYbI30W8^%O_BsO;u|L$pn&H?i+ptt-e2Jv}#Iy62~Qk_*5MW zDtNL>YCzr|DfFBM-XOQ2fCvxXopiBPD*c5^d>{TT|9${|7&B*tJ4@+M$?*JyDz>=LEqcz9`|r1m|9ui z%_33#K4mME)^It`;(H;ySJX!e#|nLf1UFLwdXcwLAN%U4* z(OcDA#lCV^?1uVz+As8w+2{Dl?#^RfvdP6vA3s-k_{#9$eLp>`f%O7{r;N~DxFNxX zKY6Z;4oT9~l|Sq%J9HP~=`z_ldk*#!z4;q#i=`Gdow&=utrM)`MKx6O{uf4eCj`tV z5Wjp$mib+&f13GStDo+taOb9f@?-V{f1a!A5|&fP#NP}IDcA>&lgoC+~yw>ko@vlW|!Uu|RJTw7SZuWMg^ooyHXVvu-5*MON@O~R_-LB)RMxm^F zg4PH4Jf$lUx~qGhZQ*&&I5L_SvNP}BN2}ZehGG6gdQIZO5!W?56t{Y+pr8^c zc;XoIMhvv+Z?XT$k{Yx>OY!ONM0?rw0i)d?l~@rAEYiHcKV{_7onGgX*%A+cFEbk+ zzc_Z<0IVU<*$mO0r&YgP?N|g~lmBO4}QGucyoN<~ksb&`Jicc(vRcr^HR zXkZBywxw+-%$Z))Dw1XoY(o~%5X>gJYDx*mZ0^M4vllL<8}3Og#$7hn!Dch*wZmfe zj!`HgOhz3zA3X6%y(9ZBUeh6e4f%>8k!JVJ`=@o)By;kU-34EmR})hc4>TFG>_kls~Nz7fd%RI#wtP)0ap~O;5~Vl%|v_O*}~- zkV+$9l1?L0E}BR_@mB|ZLXehWBB3p|bO@#}rJSsn;?T_Qmo~LxP7ldcs?IW&E6^|| z$e1+3E|*Rta$E%9C|Z=n=%zVTO)wpB@3u9b;v7evb_iK6w(g%U>a$|%l(H1coJyzB zK}(s(2Bi}xDjvPv(|@p|u&LSb$;*aj)QO>GIQUWPzos)`PCsDGMKvwwoH$eE)io%f zsV0uqNo?qiIjHB3N+@C#iYF)+RV1?%X_2EJ#B+eX`x`5AtwJPA0SEcj4w!tQme8bk zU>!j@6-8CaUG^2%jK(k)KWb#VM7uV`^;6RcmSPUqGWZksmMQKkEWMCRAXDdfF^g0X zXPqrPHa9xXM^|F6HC0H)Ba#Z<1f9p8a#|EuaDT>@$gC7udRp_OG0PY2v6na1sI`{E z4ULr{p(Wnj&z`t_^e%@3Yk;1ka2Ba7>ZrSkWHANHRPr2*|AfwjV|z1QYX!It-V|$1 z+G~P?@i2Z%;ntY*Rcx=4CmQ|d9Y3Q9)_P1$f5s{|zNk3zD<{9vH1}_vmFCBNrK@M) zr^X?>QQ+FZ#=PD8Vb6mio9amKyJ=Y&c$0GJxvxJ@9!#yB_*x(M4D=uN=*^joc_Y*BIWXNH9Co8v#Vt?I1$CD#uH@MJ$c zN>rG=KZ>F&xt3g-NZG8dHfNXWN(0&ztqEB5E1F-P_GbHcC)M;5|J*L5DG;0(9jgTK zvm{uAA8Ax%`=rkQ#b58o~@n&$Ly zdPC3(QHCR9bJT|1`)La1fTvAZ;aq9xcldtLv@L7-dmZet$zG zb*T#;T0P=dqvuV?7fbxE)q{YN#(4#ikuYPB;cjMgQ|dLQv`xW)pK93dOlNmNYXbOF z)4FDK>?<}kbDb3Hm5?aVRv%;vN_=Hf*7T_k2Agd+`7|n&Nlsq$$2`9o+S9G}(dbJH z89b54_2HHP1`w>*d_}a0KO|PVP%gY|_Lt#M@U%ghS-C@FQ>p#J#CKAT&PS zW%;{9`h|~o>chwQStQI`fE^j2k9M3E^b+_EGkQ(5z@BMXaI0Nb{E3Iz)#IQ+4*pD3 z#3T(x>L)rc3{R+WU`NHht~96xStQ{I8>`;)N?lP#rx3Rj!j4wOyAiuX)DD?(V@1Fi zihK;`PU8#(4pGoRXjK**>vHd$m5wBVbv zCJ#x5*e^NckCAsiz#Z4tKM7Vd!T~shX&Fx`v|E}ELA!L}LW~jJha>124Z8W56VxV)CbL8S&bp@f(ji#Mi z57s;$Oqwa_{xLmxw_@<091q87j}TKYpYU; zuq%>@+LTv&POk!&&!EE^NouezS3*}!IW6ejD&Q@wHSg6e0<;A)YXc^SuMInNV?lpg z)+@KjUrgm6zfy`I(^E~@he+rNZF0LR0@nJok~rTd?^>kjfHoSBxGfq zAxG9ABh=Dch)>*!A~9ut z%mx1dwc(2q{~#E+7b4HqknZs%bZhd}jTezeb?q7$f3}iwdf4UXhr+pGd!WwO$goS| z_jT7$Gye(vy=>My@vY-{y))Y-pw=gvqNDpqoT1x~;FxW63paT@AHfmiiyj7*+lH_p zHFzIL7@wgEkVLj z0|LP6h*}lt;Q6o1Dw849;Dxf~nTw!-+&)c67EW(36nR@@hHDAhv(t{$79s|FLFUJx zIB4cKQD)r((-GL(LP9q1!RZ}le57hp%Fn2D!*eRAKR@IVVdFor%C?T1ZQ^0Quo2Yh zQpN^D0qX=Dz9Ed;gHP8VU;kXtY5c-RZ2ex)&HYQ;^1mfi{2yB+1ARwhd1vEq{*vQ= zbm5h%ny$#oD4#NnCk5tzu*?cUiGR&CNMjf56do*LYlwkZOVnyrBp5*`&J#~bC3x?+y@5N8*_1tZ zt0F~(Rh#?2SUczDPXF}FcgMDE+xR5iv2EM7*>T6VZQFJ_wryLR@62y&rfR3AW_R`p zT>riA`@%WrRhui5ZJiaveg+J*A^Mu{%cMH|$6IS{_%w9JQkRpNw@j zdiN$@KZ~8lugA6Zi!M5zd}oCord*y(Z4}`-%EF|U0ZfapvBoQ{=gSY;t18A0yH13} zTDB_R*FkiCjd^bNbxexDQBh@^zfY`Kekspv0%dD6KP}NbYc4@&RhS~7R!?=O%@D>; z3?FnVi?54oRjkZ0dKrbUH4>JJ;>O-G#pJsz{lNfMVV>UCqP1Rz;JRPQz zefOK! z+QyJft=iiE74YUNqWg|S{$5xzA*N4KjceIUurc7l*B%9*yi35_FCy7rVWF;jF5X=` zNV-G7J4g=1hucPg4xoWb?Jn$|Kez}Xs5t-RE1#o>A@yLVqipLtW0 zq)<<0XlQ>z2oC@4K-!D63vn-jfAzci`RN4XIPlN%eI(NI&- zZU%HX-fL+zAGuPNxM_cbO{g6Womxt}1$zIdRH0d%NM!;ihS04+@&IgTpICM9s0kXi z8kp^_>p94r{YZ$WQqMovv4nOTp?!al>^I{AJX&;0&+VexM-KE z{m0MeNC&*LJqOx$PwN2uFAmiV$-*n^=;4KtxpL|ZnEpLPxB7R?*(nae+$^2M7UMEDPhwQB2vBUL`n+I+HF2q$! z;ERVTBH50WseXAHh7q>hz3hgBTXd};zB3UPect01NA8h63KY_ja5!@t$0mqf##lSm zg-VS^0ea32w5ByRrH3!V-cIn-?)_d6{bY2Z`=rI<9|qQ_Eec>AVp~LmjGP8&)kD7A zQz|Tv1c|H17doxa4rUblLJzNuocl_}Ma-3IUov<+#k|Eofcf0|C-sxmdAGF=-w3?) zcE|VCBO`uOBa+7*y51NXfG;Z?y7$2jo$%bKXz!BLZ><35A9?57rtlAp0e$tnecuWp zb(rkoz6U4pnxm?F)Zl|B4=FDU@!{-n^d?j~vp*gkrbp#5+y~2w_)HkOK$OCCjF-ie zq?OxB>Ls(`0pu%jT@I$1X02pD0(1t3ove#FJRfcIcS7>tjWR^o1-k*1p zONsK4>-_4-sd%szWu{>?bhE&T?gY-2aNF8I`F3anD^R?&0}aPe$Z(|3w9F>REA zOR-z>gmXxLyd?AXH&3Sd_inh@IVsx>fiq5>|f2{gxIK5q8# z1jbrT#Db(}o%fy3iz(i<}DSeeuDuLDsrlK@a{d)Q}4mc3cu3P67N}{luW%|Fwi~^c$;C!g~Mk+ zXTRU~ch5D?H2roSs*jposglX?_Yyp7*|@>GHXv!b_09B@Gv zNTksXk**WfPp;Moh(uru;|(X2IuhMW>xR9P)gBGg?nO|0#~_gUWmtsxDxAX@2}905 zXvfSan<#1!V=AVv_!RvCcinWvEwK7Q8C&QLW|ei){P4X5x%afUbp+cH+Cfrwo6|5` zMBhC$51A5)Rs2lcU29wyWrQgoA7wPxh2~`K{PM3O4yB)=TGm(0$NK-oeEe(I3;BO? ze6cdHvayEaxQ+QM#2&*Pzp>HWqQa^Hy&-rZv)D>BTh&5iwbZKOp;q0(Lc?R}b%Dxj^X%+k zNlJ1n%Kj^#_X`dE82J^}`A7=i;d#dUZS1&IydBc!VOt$@!u2=24eG8FZ@W~uO_Cjt z_0_I$yFf3u(QtDK(q-=i(#CloEtAY9ameNUwwHeUeDJELYgYig=u>t$=2Nt*r)sYr zCf^!~0Uj^WuCwP{RMhq^6R#h4|Cuyo)?FT)OXyJ1+Y<{fFmSSlYj6 zMA9_CtfDoi!9+nz-MDQf!B9MVKD=xs!(15sl5X1I@dQoJ%wkPa2>F%CT)kPHOyf32wj}-M7l2$;VLGn_8 zx_bR`Mtw=p%I>h}arkn@?>k!D#ishWbW=JJ4F@Kg3n$M=NI?$cx)h%2?hKjI13fR7!?J*s5u(KRy-Z8c7rR-y<0sy*O~oQ(W2o>06+|3tlAK3!odpe#dH zAO5F7talUT4fm5EU2Rm*dO5Lz>Ga1nJ?Pgq-Ss>g84{F!OXy>KHH9>Uj^k9iCB+UJ z+p4(wstZaRNjj4eq-ao5_#7ES`HD$e93(Jgl!QuUSO68t4K;SSNS1WOtx4EVf$#?< zlvGa1S`JF8uo9G1(Kj3PxbOb_CR;**ll{MuCS;3KCwDfA{zyWJJ2vvy9pMB{7A#xp zn6@2}K4VD1vNFB64virD;|kZ(_rpgDPz2*pqnxtB+c%}`(wGD;LGw@op)o~7x2*=w zl=qkJ$0{BHpu`+I`5lgc5F?@B4#8&YY15GZ6fSod_of~cv?#Ge1wSh}=J4xP7YxgGrEty1M-@w6R|b2ao~^wW7$z$+gJ*wUaD1Cq*St&xR_sE52pYJ z{aRJ;uAOig4+^9d3D!U$1IM5oZ*7{^40J`gdjRV*8hQDVQibz5)@qAgUHFi#wlG;+ zb$S25a%CZgkN3kYpx7u?(QmNDxRAWGaNf1*%TB)YJD9j-9JC)!dmbs+-Ou*BQew&v zLW))u2XKUojSj=u;2}|H^sVR(w7!M(LL$!Mvm>-=GtAD~vF#wYG`DEmhva>-=t)iP zKsvd^0laWp4y}L+>bAdPDcL!I`!YHvG9=avAoUJH_FyGyCDV>}P@~8 zEzYnLSexGzcj_sW<&v$Yq#0-p&;m>L3UQd=>>S6fH+d63`WP@zic4D^ad=pJ&8OZA zh^bLFCnh1Icc*$y&ey5UdogbXYH5 zt1qJ@v23R!c`ZmKA0a9P%PyIR;o1nhN{j^U)ue+B!p0Slu)5UgItFT}6M6D#u*n&) zr=-N2w<*8us=L5mFA40wxd<; zLXSshTjMZ1T1+b+;!P$YHE5uwK`r|JV7()oPQWQto?Xi_nxm!#%X&_Y_3T3Rcp&bh zUYJj6+ptuQ5R|VwH~^8rK^Q_BUq6=FH?SVLHXCnxX0E`OqQ{%CLW92dCdAf=tw z?rn!8O`qb}z1{X?$-&%-0w?i)=$ZQcT!Fd|04}w-_zpT6ncGgb#Tgcs>ibBM-}Wql z$#$#oHu)_%SbThlMKc5wA}^3qTpCNm7BULQxxNO(qHt&{Fw1NTrhBo|w1TXKA7S_7SeqvF zjPhyzY=)&Cu%u%gYj@|QP~sQ^-}fHB90~-6_+0?l;bHQ{Vl(f_Ajj8q?GG&pnU;?P ztB&3@X9WHIe2LVb+zLNt%c{JEpuD48-YZu=7+2gkYig^%1e;>!FdYe(Y1hAI8n&#g zc_R3PX=$KkRQ^h7IRrPkf&z&AiaL!S;P4;&6AE?EjM(OOu+Ivw3r`o^U*^0Er3s1u z(E9x4WYG^BjmL`5=s%ApbrcJc5EcDH;`sFpKJLZ;kSYhGSA)H3y^%coK!IuWq|mjc zEvEHivTHN8oEscE=cKLb2cW2;?IYGQ$YO^)7}WUsE&BBkk+arJLJj`%^=ChF%4YB- z{iQ0-F-X}>keGCB8JJvwQl|vEVxGhX63g|yh;I&BQxe`?O9M-ALBhXOy4#8+yAlJk zn6G@>!rv3d0(z{X%{k%6(S71i^#-4B=rtnqAEyC(?lr2r-`MtSU0g9PS{dT9P8q=? zG?%gej3s0qKy_u-IWQBSG3*|H&Gj9c8RX5p_`3OCNi`23d8eF%<6>vo%S&Qq)xWXq zFrBjFoDJBWZrdWqC`XPEIi&ig01|p!b<5?`LNu6e{WoXkh9LTG#y!UUlR3)Z8T(73 zh=y(leDrRZSwJ<5yK3M?+KopHa5v&es|IiamLa4L?p1mnoRytGDtH6GWxZoFt~n`q zNw$^T-dYjBwD~E(_t6pX!S+$|Afc8V5-e5vA#i)D#t%#!#PWIEY-Tl4RASas1#H(HcGtF8mL^a9Qw4b@Vk1tJ|xOVeWutuCN-3kX=i#^&(DHi zYHNiW+rTpZ; zt<>q|?toxNzbQ8jTx98;7zEmyHk7?F%~$9~O8;hslNwh6prP5OsG5dM7jjRq5wHn+ zw7o(`z?(XE^}0F)9Zw}s_eX>^i*Z+r_gg5o%EfRyEeE`b2O8087X0E<`F%&PG@0o0 zw~I&c%xT`)mnf{`-zpaWBWi`My^W)dfsLhuldY|dz2m4hkTi2}G_p3bCt>`bJBpH(0=5#0w>89atTm~ZpLj(W>pX%fx_Ct+fjOk=5x*Jm z_#FKtSqn0q<-_2*6wQzB%Ma)uF2com%#m5Ic{o{ZYG&j{`MXzoQ#_A*fWz}lhnt(r z%})?p>{S7bAcNt0Lgt{g(L7%@=%(8z7#AAPOc6L84Ex324!{9J)=-k_@GiBd)iyTt zBj}_fPuJ2z$ItAeMgS^DoA#o^N$Wm~vp`ja{(2-%-j-$bctMD?2rCGbb?#bd!lk8E zh2qoc^V~)!Op_4?rBt835CQsSaWMz&Rkv54b5V)EdNG#NvcnvlQ~Bvi6xVqpoWbr> z0;h^l4UD0vPKz6Au`A!!;fxvPxy+H3_)L^q$`aZz-AND%hO-jEB6me940}ha%m}E; zB9G51bV5r}Z+S_iZwC@Xh|uP5qLI@RN+YFoy&9$|RnOlqPMFgVKSu;9k6!KRKaRjR zOL(1=GUtuB$&#ZT=9kJYE8NaW#2=!&WtCWg=`R96DzjwMO|vdEV&YyD`DT}oYPixb z=~sZ>_sd$57xrtJNL%bJsn}t|jkKUnI@!n;4cqgu(a@|Es||OVHX7{k&@DClNwJAB z8W@9&{MyJDYRlTKr_w^1DJ@c;n%MAsr92P2kgZ*7RBnmf`UMMf6JE*um9XKrp~7)A zETJvf7OsbTgCd4p^>fS(kTr0UX3f9*d3=7hfF#P0!@*U+DL3pWCsVa>S#mW@Ze)hx zE+_Dv-Jyvbe+0xSI-3aQfzYkECeL-bpLcSy!y6$GY1XB zD7aT&&hOj5}>wEI@ zKiQf8T4*Zy|Lr62zdr%X_Q)bAJQ1W3nDC4o(FDQO7zPsB$p}E-)4oOa#0)PfU&#wy zv&6Q>v&lCxK`VXyeiPTWj8(k({#>jm9VPhP+462n-prlbg|q3h<9+Jud5aR5yDN#*5mSaActzB zVq9OkY@AJ;xff;Ci2W`5x;{)&sJCLba-K?YZEN->wzP+jEgG5wM;g#fhgS72J^Ld5Xl7cH$=yBds~AffP; zY=?aoP$lp~N^x~_rIdGjr3C9CMJj<`vw+!a+qJ&i=NIDFA=-xh{xG(nbq6|-pDI$u&S6-XuO+u{pE zZpQq5!^y#m!*`dyd^v$i3XkXAPmf^sibFhMyM-PXJiMKlUqfFDx{fd0xXjgDPgpR% ztex!r70eGP8XOtUje-+tONU~@UDe}6*pdt^ZS8$Sdz+g?C$6jNFjl{WIJwdK5mmYD z{i;P5!(Wu@0F*12tK;u=DqD^cWDVXQ+EfWqV_UyPG9bfc#}bvh@@q$N@bfYS)OejV z#cl2$63r#I7*D5r!c?hn&(++z&0BcCh2#1j&_X^iaxq_DQ=QaQop3-p{dxunJpj*d zR29UXxPa&JguMS^Qd<3(44gP9JXRTyDUlpGv^(Axxx-aaJu7VvLhNL+RPnTzwlkEw z^@uE6#Q`098|Uq}S-!^Tq7#v&35N6>O<4rq2GH4}Ji%lk>!F@0H1u76oZ(4VOuk1F z`Zct$57X|2weaj+9&Bb;e>t`6eR|v&@5qC6#>dg2Z_#gFIXY^K z9!DwkgI?>JgSk_P6EbT$iJhHeFvwu>hwME0r0@>xAa(RZZf4^<_>qJ(_b;*Jl0s9u zolqFWj+x`zdp_ey>IJv$55{45NA$ZtQZajc{(8ss5fwYqU+=i`-@aq<|EG8SKfQv& z-+P6B+H0#qs^aWpdi$t4C$5VTq(uj4>hn9g_*r5RV~G~WkOT!Fj3epKDF+(?Atz=y zxg-YEH#V-UZam1Yt|*)t%~OFWRPb2MudEgZcU-VRXuLQ^0rS0vp=`o z8UNVuZ+fx)g>TchirU^6<+3CE!@76EyB+#65#aX2e%mk5(1WRd|}=W@UkC;kgb(G>NQKR))A5anmjx6S}$sLnGH9=up;__1kX`#aQS099HQ)l;f} z6?D9+x(YwKsbxgk`}9Sh8Lg43F%_~DX)TX%Ewz>7<59Zl$dPXj?9p+!9$DVG*(}qp zajpOoJCrLswpgDzk||UMSe9*(Z_)BuA(v5wu)NLKgUj(ToJfyu8RjBV#uq=x!DZUu z9t+bCcZ!Z>UwqV1fs)y3pJXWgnQdambf_I~-CV}>m%BP0geJZ@PdTjVbh!~p?(1Wd zrG@4BVz}X)b~;&{eybSTJhFRNW_>R0h@^Ow#)R<&*(dI*$b z5zs`AFyl&bK?C$A>mOK)3TQIX!*LT>>p=SowA-vT7u-_U8a)j!ip;bzYq zC*&Ey1gK%uSyToleUeK7NoZMYnYMn1d(=7VfFIx_90WaT{Tg z@H;?;U9AzASd!I$R9aVXRp~2Lp+f{i8M`*iQau|Ov*9kfU@#RYp*06Bh!KI3D|w=C z8iYx5=IT>-(r4e9zPpQ`DqjNwCW-Lz=VGb6Lxz+9_~;Z*F=6<-Vu^#Mpz@I zIK3O;;Ryjh3H0vn)SYNyyOE3_Rqm)fv0AA0 zSP1vnD88X}DO`D=`gG%?zKIQFU8AG=3~VZX?a5`YWKchQk=vc87!@Cml&h9A zC~tR0>;X#3VXgLW8UwSgK@y*oL#$APiW_$Ph(e_lXn3Uw!OUebR+$!v% zK%^$Np}2-;b<$mCldQi_WbP?(i9Aaw68>~S&?^V(fF#G3$_@aO#?g&{prHkWyNNvJ z8S-Gr1SBwq@=289e=~jYIHhE16bFdp_~@k>mP(A=M+C*S%EL(YDNnnf{6-MV!o+JN zQO5?Ll*&=c6zzhF@y)z?ay5 zpvUcglPU3UN0KfwuQ8RfwW_(RH%`$6*gP=osSbo2(0nJw<<@vW^p&ckEDThwF02nc zkOXuHj;K7fhkJsL?b6yostFZeaV8w@LH1J1EwLOnbvdBd%Xn?jr9XVY-S%K_O#=tb zpB^=q`C8YhQL1LJPYwX>{ET>DIh?D6Xh7M!m~Cz2ZV*g7SV)&Yr3CF6bd#T6UUf?L zlhj5r>tY}kk1JUIePhLHB({OsIzMRfD+Q6NSf@GrUQXHy9%Dh5MejjSV*>Aa+jPat z(D;elefA(G9T&QYJH?$ALaJ-W>kBAVsG-o*GMDTEzhu(hF6&sKqwBVzXQEU(P&rM% z5Mu6EM`m%>oq`T?5!=1YtbH2Sl`meeNYxYTEu48Lu$-@DpUb_*N8EKbpiadpCD6p1 z@<3~p^04kKW-6@BY>oDfklg=;juTWc9Pu$tP}j?p3=i}>w~um(D#INbBWpUnO&i{l z8b3{`%!u8N+ia@u1F_VbZ9&0#L6J!`L46MT}cTzEdjB zBC1^?)g&4sD*XT}P#HNy_@3`_k%-255vNZ43ZWDjMFaeu%s7gigrK@q9sSt2yJ4+5 z9q=JztAd0x`JH5ggZ+UANtCR2$)wdRA}6zz>x*?=qGDwA|};it1WI-Xlc-y zF_bT{KsAD?oDa0L2F9XheWPw!7n~00ECyw0h}Stc&_jMHF8{H*DryZ@XM#aI&77Fe zhXFw`n9;^)n)a#+5cw=X0htJ!=LunC6{80dTvL6)fi}Ovr=4AofF^5JGG+d>BwQ>* zdtbcUp7?s|rjOejqEF1W)M}N#CSTr7cSdG}@x5LjUSy7>$cAU7dNENp%2`t~;?d3% z5nxd4FTy9u7wrEIBxH%|7z98$ENVm<6v3oyjmI%A-r#U3^Ql&4B$OP}a3MQV#PCS21F0k13cE0~}X1}vzi zbcQ*cnW%@#W9BD*CZ;B>$Of{iL-ii7B0fzeO(^c2qPqdH>T0$k72hSpWY}E9))|;i z!BheYk|{+64X%*tmT)??2qK>xE9{4Opr!f9;Eyn_7G>&XyV}VV7-BA#2VE;$uL7p< z!xp;R=|RwX?N&?lJ)aru=7s)w;qgA>mAb%f`|r3-33#e%(NWdoaRnCoo{e0*4_7URBb5q_@-^j%4?`G zh28$PMIPm(;f<8aGo={(E`3%pNR-s;P|(qo;vrzrG`nn@akgg^e(pV&9jE5%JE+5t zt}XtDo;W+{@Wvi^walv8!ZdzdR*mq*p6;}6y)P}oR($EVUUd&5s2+rqqkO@4&HZ!5bvV)MTJjT7Oq?PFH{r4VVy`gf|S z{~tZ_KX$Yg%2q1aLMYyakn4`iK>SuYs``|32-?c$X`~6tNDT9&1z^*%n`9%-YO2om z&g`b2VLshc#pHMKc|$gtyEZq)E@X_HM45_PeHW8!EsrUO8{ChR9}h#nv%atO8w0UB zY4%n)G>5EmU2NgPy6n4X3kZwAUyLlaVWBy$4FTg`>dA?qahg@<>#2$S*jS8CVuNS( z%r=0)KdCo0Q=OL86?L`7SnkAS*sBOzVl316Ueyv)9B4dI#$Blcw^nK}8}MpOix5)` zL0`UTP82e(6!oL-mlHRH*0u(1K1|=TN9Cn3G|VlfMQ~eZ%YaMEGrcQ+`AtX@8`CYn zTGW3CR0!o0v+g#qdW)?^6Ne7zGPr`^C>m??#9k=)L zSdEbMSbQL^%ai3xAat3T8Ih~sGe+4jvX%bMP-SjXOD(Bj)9yja5MJVh#bwNA$b%Qe z`FdPi{5oGifS`DyJbF@$lGlBoF%H?9Z2Zc!kD}ekr!`QM7wnB;*Tt`7$HRIbJ1=3} zA{2zJ1-nAdzK9j=bYRqaB{!tS`A6dzM>EJz+7d6J=}cVE1tLbl&k%#i8yA!`|NRv{ zl!C%gev3Q6Wg8!@!j@SQH^p8_@qYMz?I`6Ka;QFlSR+k#^G+`GRCIw2_`2c5V5ZEk z+j;L8zWf0+S(2ybqfRh>n*Ri3T>%K@+T2MgW%!N-o5ZQ^(?P;{91>CGn5j$92YSxh zXe@gg6H8~1qC+Qd8Mt2*h-BuMr8~aKL;N7B`>8lDP(=NZsbft^Fo`z!+!56vWZ*Uy znWzz(2BWxIU1zDF;L~Ep-{Zd~;^TdFfcLPVmmz#c>8hbtJFTMesX@LQLfC zm`ttWF-T)_r%7tsB01Z?BP%oqvb;k`8GzQ!8x1`h~;yyI)+ADTkcfVHZ;1IPI^s+BsQ+fGU za>ZX1s(&p{qxny!a(g4gzqagOnE?N0S^x9@vXZ=!q3qv_{?k;i@~VNOg6R$JoU*JJ z8!wg}%SOvcMuUBHhed&)4iurK2~i7486g+EKEkBuY|P9pL1*4zZZ+>-wV-}JU`}t| z5CN6naDS8M6FarL&%-=suaV$CMGWBfm~@$Z%y{(ZdQ9hhUG!5A0H+ z>I^Ijo}MygqVaVR?xrzylIEEGaX!}-Cd3FVTsv+R~j| zdlM(;Fb6aK9kLBdnc+BDg;ocH1duVV$$~DKhqM%FcOdERNT9%CwFnWBrmTMjSce&_ z2}{JrFl*A(KSP{?Ju-X-*5bY~j!g*5NV1(3mStJSHkRP%>>DuLq*}_6o7$1KLviM4tb69w&lp}o5 za;c)EOat2OMp%@^Z;h=J_Y)NvY|7&@q4m)#n4BuFxD7evxI^#6C#lg}bgWD~zhN8e zSk9<+V5RU+YDFNePsY|Fg*kUTehGlFR?H+|k7sD{dFf|#9UNz}VR@M!8b zNBNTs(?!(OQ5LWuZE78@bY2KN#ts~{_Gs-Ds6J5pz&gs{{jz;GM?u|%YPAU6!^0M{ z)_8lcPG`;DHo8+tSXkshbhu#n?uK<3iV2Vag>GBS$^)nX*$9Qb#%kS5Cvt!O{<>w( zTC|?Y9X43VTBYHZ2HV_r_(qzX>(Y&yl}An~(>Tp8HCWSHSK6y;ZlFRo8_g4*gDLY_ zD!cVKQZ1A~dpeNKS_mkcFdTHlS&Qaxj2{*aU?D|*tV*(zMN(_%Mokf?|4ZjA(;JSbn!EIgP#xB4sJOTSD5Q>@b78S;aBy*77{L1GW|d z0QGxmt0_AKbCysY z%oJL?qf<9d-T1}Zm+*Kp@p~yLBedX7xr5dcX=K7(k|pUX=R>u$DC26yV>i4}Cn|7y zWoN88FsAihW0mvv=c9&ZBV#~@|L7qhKc{4Oh9n^LbvjTkGCVHUOx-fpF0@XFOTZK< zy6iYanf|30W$fpR2SVXH9UNk^i)hR+2`j`H`^#JVicriqgLcqEmFMtlyPY zAK-}sAKdSn{zF(_pH+W`RljfnaduEG=5Xi;vrIsaY;Kj~M?1cf(;UBz-@WHf|1|a! z13lUG!xJn{>=n+S;3+W@Jx%ay+DaOl-CnY1wUT!)fRHO=O!R>|cYZ$Wh%BKbWzad0 zq>)@yr%W=n?l;HF%8x31Pv!uE5KjKkUnQ&z5pZM+V%0n#3lgdV0rwDo8GVMLqbOxd zVpU?E>GNm%WNG|~jf7`IW{pVUe}b9kf(b4?Bie5X<>Z%;1X-^>HANK-r1+-Gku5V| zX<>bWvEr_WH=ET3XJLl$U^NauK>zxMo5D#ML4PgPZxH|8(D48MG^U=KWQsGXfs1PStip=FEL14YeUTPMI$B+(*vvWIVc3N z+ea8&0Al{z*YV2=Y>B}+noZ~_HYR|Jj=f_JC7(wxnpw#&W4`{cyGFbe)eA}w)mNUP zZZMPPO-4SVx~&kG_>Z3hvha9d$c9(?bEhR|=n|lH&2l|bYq@liDzUh&83iRu)uF2j zv-LOPmLKyi-4%xeWF6QSr{}!*a4vh(nRul7ix^Top(oQIGn3)strMTFhLw_*3LwB9 z5(9_)ID0=mo^xqoWIpy$W!6IRv02dY&QyT%)L-f+V;*pfYQJgcjb3ErIHnR))xWfK zhDRi_)-w1yJl;TIn0q)3fpBydh4S?NX<+n{Yg0GAFjAGpm?M z`x)tL6DBI%Xpa#qLT%aw4B$)wG>Lk0@31zuRI9Go0;H8lxMh{bd#BNN5H3<+BUIXqV>x z5K;17`IC=COQ($Ir-&7}_F!+|dtJjHm9^G`YK`ruSv<#i{_JA*W3lR0FYvk|beLQ= z(dm58;CYq&=zLwp{|2{vNO*`eWrWVbZ2OS7CXou-uq&`{~sBWifTtu&>YYH>*IF{cr`T4Slu z?4;5-kU%`G9(&N_lLDrzysLk6TUe0GB+{6$5EP0hvIKnyX-v6$VM4ntAuDGp9ptR^ zOK+j5qjt91Om%pyp2tZ1d16F6`}PuEMEIzwr^bS0tvV|-l(Qv>P)rM-M$d>9*l9FM zj67)pf#Zw&28BnVK^s=(g6k+oLcuG*Yjt=wz(DOzXg^s0G@iEHXwk7rRHcqn@0C)L zLuu83Hx_V!Yz3>-BV98c=zo3Ae`FTotQ=2TmAMP~yIop>=2YCR#j`72Ed(nJ>i`vm*?1aFTdDJH(*~>m(`y{FNPPs` zL~=y)@+Ijd+p(-?uEy6wzM-?sfZi1b_t}luM@j^;@r)>_+L5FBE2NbNYm^JEhwCUB ztr8ABGpIC@v^{UTHPUEJce@;siFD1)p31AMY?}x7au*n>Y?q98?i!I-`AlaS|881Igfg8f8gmUTHhViWW|jVm(5LW; z{r)+@yn@>ZpHF#1rZi7UkBe}vttm8nw*NN`%f!(8LMR zor&C6(DfxI6jO=bQmi`5k7-q^jocCnjP=35z5t<|=mbU-7#;>p`4NvHltedyM%t{4 zhh)!(h7+Yb^Mx`-tlvdxW%11oZrhU>i#(h2M$X??b?yeRX45BV|ByGVjwwxjR-3I@ zB-T6r=^&Hfc9zS$bj-^|k+-ts*0KZc4(9&g%@jPR9`3?^6VSuF@W~!}IY*n?vGbO^ zI2fYV@VCrKZ*b^D|K)kHdjhp+h2ui*9fV}2A>=`nTbWCYc&r(ii1C8zm({#3Eb0h~xfBL;G6wVQ|FpkG{5I(-Rr5GG5A27&Zk9KH{-SEl~ptpjTt+>Cz z_Yv!wh}0_^1W7!cF|ax9WroVb+=G~4>Rg@U0_V8VBMrK_9g;4D@)o**oZ8Qw{p=eB z1_xvM{+++$SEsXPc8!EtE7ZliAzcfn~h>$lJ zk)WSpdjRs1;=A+?=ZBvwUfo+$OkRHvn{C()??Y&2{ zI_~iQYAuFUIR@CijBA*%|8;BeFTc_M)LQ%lx9%vVA?2y^S`8nkSl6kJPf2vg7t;U{ zp8+(5~J$3mORUO+C z|JxxMFYq@ecpaU!-lP!LEgYIAhpOZ8UgIzSUqpSwr7%Ws>Dy{OHV&BXuW!B{PV*1` zUK89*${E9_^{z*tfCEEPSf~~G(w2d~Y*NR9=Duic1wY;7DSwb})3T{^JD9-b(I&&+Ztv%&KA@}nCn3gzO0b!T@g!&%01OrNbP&eYNEuxh9NB(+&m+zy6hp98t@!6i+vtEm*Wq5|Q(Wq!}MXC6`E|n0_6SN@C z`~=#CFCWnWgPp)!Ur)@hFzoBsVUVoUx;-EJ#atJGM7t-Yt*V$}SV6ds>9Cg%SJI$- zDbkn4jzAs`9n5{8LjgY7;hkv#dtR@EcxeT<((2sb(TYBVc!~uj=;o@X?T|?he5N}1WalsnOTmx zKt|N7+mP-ZwC_hWZ-0o+3)ms8oFN>exvG33sR(8^DZOty~51U;^eZ)`axI(KFuE;nRv8ejcv_g?o7M__lCyTg8WB7G` z+4qOXiPugS@5?U|*^mr<*Y#V`H_MzRFk7&x;wLxQE(BkH9hj}8tL<-eyGcrK;@_w; zA@za1Swo_>@@4>KJBvVnuG3lYp>nz=w>LqBW%IJcqi&W`TRlN9c!fUk)GkbN3^&!ybWBx=B`&qH=!_r>3?Zf((6|~6O zp0k}Q{3nD(o<%)hE<^Ypi`6v$1|T+DESLAw*FV4Rc`jeRPMkI%C_ka8ovt@mbrq6d zt0|5VlGaOk1BYT?-uOB>rq+#Q?JytqH9)RDUk9`Nwl-1X=uCpU#q~gQnnE>G!FCt4 zjYWT7L5P}J-+pL#i05$n&GZeU$z#T>D7hxx(`A|kP}Kapp#YS{0;Bgtb(3?~ACcZI z5%;oA(?&(Z&DSWRKe#_9%9j;7wvQ>U$6oEf(4(G?lY9B_0X{++!xJLjiG?H6AKYhDDhOYSaBF)3XVYpn; zu=DFClO6*tnVOsPx3=1v()A4U^h;oWZ2<>ch`BMGa-!Mu_L zPb?6?sJ9igMSO?eI+_nnm7E_U2D5TSqxLMEvSfNMbpV>R3^MK2J}4pT6^1!B@|MQH z6->qz2_9N*Y}Oz`qR9B#G$(cBQTo>DW{`h#KwVkd$<5x~98ziuh7~$_GTX+>iHqo< zdm==P+bybOoJivkd;>k9y(IM259Ohda7r}mk{zlOzs0i*We2EuMxSo#f3fyXL6&yg zwsuveZKKk*t(mrsO50{t+O}=mS(P&})2_5_nSF~%>~E;5i~Ja(#+cm~5DX-3#OOsJQ3L@z(&}tt{t8J_vd#xvEOY3#Ha7p*mFqMv zI!uC9;?#4o;Wb6qDO4|M{QI!fC$1)8om5YOUZP?%cCJ{ZiqZ%`xMY%@Lk8-jstOzC-sw_!Ub*_Tkr-8Mis~iG2}CS(8|4b(37_ zSrec*n}^&2ixDh4VXj;S>umqIXTgzgVF&z}v%4zMQ3v;M9ohBTTp{fKcutO=X03Eq zV7YeYYj)+Ea5kdScdVQ8N=nf;`a3q{f<7LE8Iatm>!U#jt7A1#qSvB2? zUC)Gv23%e~a}!a>O4Ve;^%0MV?CMIImCfBd;EQ>S1)_pT19h^ivAzj_g<^%rW|1UX zqbfG;dE|I02c|@F#`Jg@Ub|JD$@zh@Qz*~M2 zNr9gM+BUor4^=@~-1#nekXVvXKFbt+m{cqetoZ=hnn(-toi4Zl2l4owudjX<2t9b2 z)zfuYj!*|VSljFii!&JV9xPCPqnq3&7#hO6FSBmH;>Y+k{++qovc)F6d2Otm`%eO7 zCDegKmF>Q*Xrq;i4iAJuc0*QoV+ijL{o7YKith!-*M88rxy8U*?ZR0ssYQ? z3dRBN*W^~DDyy4svgYStXc~iZa7jer+l_T$F?dE)c&7$D>8}3A74CD8g^El!0y}h` zER)6Mw!PY1gf<&*eh!Zeo)T5=0_`F%zkZHZ6Jqq|OHkTXxz@N!B^a=TDsMC!9ak_90q0C`5gW23I4HXloV6CQ6RS&7kf)t?1fZTYt&uy3= zDI`f2?EGdj-TsA;OuoCiKC|;+&a-4xhE3pYo=xk-fjT$EmRexQbY+`fTDRE-v2xK3 z^L!Y?%-qJ0*m*MQfFJDdIEc_KmK39+*SUxe&B!X?SQE!N7xF&;FG zkMR+fN5uWul{CFHeKVj;(1O6QYh&}GtKi#s&Az}oAKeZub){Ty9E=uqi??6->p!c zIzpj2@?cyqorUmHEso@go*_?O?-$Nu8XGZin8>^m_+Spb7#OT0j*M>8CDw*uOEW*O>^pu6r6WiB;Q8wqJyL+&9ZSKW5pfN%zZ${4{{sBWkI03)-*9 z+O!(308$Lp0^h@Ho>e=!I2r}mQJd8YTVvDwhV;yrLW)09+fXTYzW5v#N>rJ#MSIk<166)779}nO7GWQK_^-o`0P-yzP#qg8c3%TC z9g+l1_DUOT$O>BYSOzroZ1yWm)D8o%W1YPEZ}i43Hzn(3S)praP=eQiY5yCM_T_wbr-B7~eKXa`r|ODymSg zSFP&1L@4kZN74YxyXU>2F((bYZG~_qM2AEkJ%$B~y-d(w`#ba7mNVibn-#*8$@?>z zW5IBOQcN}ero>Wr>pH&Hd=*y|+d~@E@M5)FhIC&57tT380IP4?-}G#24L;-oW0l4K zUb0am!_LynD(t0bi8GjChG@#qKLyrBC_~>8(aE`i-=|D`ol@>Yl^$#cKgCQDIYUUI zh+8{b(nGQX1YQZZ>mDo9T0hUPndlUdS)9+DMMrv`YS%W;PrgRpeBR5Qk(g?5VgEpU zKMC@nF1jSk0TPtmV2xNGZr{s;*L@ogyXLVTu&V+JREZ0o?$fEB^Az$E0TAa@pG9*IW3uOOPw%6+N(=t z$j>B{K;rlJy`@8(8s!o-5dZFr_I67TKjrS2rr(!06Gl3c%~jE4B&ijMHiDR?dcWgW zj8vLL%2k~;fHTkw7%}$H^n{wAQ2;9Dh-*JFv5ZhMRrx@Yj+n=*^?Z?ef}Nl?81URX zsY|veI=~9GH^!N?MG%imb`8MP4dAErEDRa%Z;9k&*s=EziYQ^85_TS3+E@ z3nYbS-v*P$if~v;Oiix7R1`sGq?U2;ujlD00>7eSC=32? z>73Ynb1DM zvOdAGKHU94^vFX(<0n0!aG`RwdotCgcExJ{qc9>@?J6n4{cLNJ{Z#0W1dL^RiTGx# zg1;)C+(I1|{SDeR(Nk`&F@D`1JJrG=#+=-~(aQRn{g(?Eh+PxKC1SUmFyO{!$2~J2 z(*$>5to#ZksvivO+)s{8WS@A;_qf#F zRNuqND|VmmZ@yqZwfuX+e^&_qyz%{~HxnLb?*jKp*D5FacfA?j|2yRgu(x$EbTV|Y zclvJ|RJQV{-K-)qKc}0O6@EquLM`gEWc)WtG8)uQyn~U|{`zQR zl`HB~&AK1)2$@9nLRC+c$i^VlZ?F-X9{TS4W9e5uZ|_H}zewj?E!qeok*y=np7_o(p2H^bb?o`T$9+>VE9z@212o+m! z+=g7|n(K@B@L=boQ#X_)7osgLFaG$80iQQOzWaF(hc}r*cl{(7p_g!?a3gALUXB_X zaxSki%AyY)g_$63v`Jcu*IRxa5In!#!>pPh@pj^ZWe%%0V*wwvyNwN*jl_DgyRU!L z6<`-l=qR`bC|<_7)>ti)vb~WCn0sYKP1HJtZAPX{_M?id`Y>){i(`{PyDnygzv2%roMq)hKsGwE;32 z^y`+Eop}^>f?RSH21F5q@Z=L-Y>hK(bin$^d42}7AxK}dcv4u3^XPm)-}^_w!zai{ zIbd)n4Dx-|s1wN;Xe=4Hpyrk7nBhtzzJb&-T}~6Wj4xf)kP*AH#V2_~)N;*8r&u$7 z^fmfogPKck)ByNnie4XyaGEb#YpOa_L4FpyPd{^Cul7e>D5U0T=9 z8(-FIUi{qL*Yu7a+%HTL#^4P}e$p{Lyb~VyPF!T&bbi*{(Q?tHtx$}up#r|X2RYbS}ziCn7jxau5jeb1^)q-DEdW^>!-0XP69xQ-8BD|J_Y{34Y?zsTjS3X>T zUxK|VM*A(qelH)s`21e3p!{C*zyB=Sip98&rLBkixedyFzB2#%%KZ+E{jDndJ`(#I zag)+R?(8EvWC2Vw@}hEhLw)<=^5OUj3HM#8{8qv0DL0U9K!Nru_pz1;To9oE+`i&y zfJnMHiS#PIE-Ahu=|v1K%z$Q&OvqTWn8NFedpq531#G)ECir6+ERZttn=*YQMlh~i zjnbC|$RhRi{Zw+l_8R4y)Z&cQJSjaPyCl<$&syou>*|Zpk}u6`%6C-UJZT7(>kS~J zHM=h<0GJv5!H#esUo;Ml9?FZao8xOdbQZ5J`k|(<7!wkLL>|?)w|HejMJN@mS)U)o z&S&Ig)GreArf9>*mY1Ug53<10WjEsSMKNBLEraMaM&J*P>Jz8h(~O@wUt7~z_AUs) zfNPKRyp?iFvmjKL);zp5P27g1^{W45DYF>dYxjC0GUNm-}C#@D(e%F&o2z*RUQjFQtz828$0Skwuv zx|UET|CC1UjVMT3P4?IDpT5A}swWU%MPT8Sx1Zm|JU(-XX33TMqWn3k_s84KiCGS!fGAA6b z%E`#VQGJ4IfN)l@wB(u=yDVrf`t@}&lyhT`NA(FK66}qQy&gU^q*Xc9LK5rg6TAr7 zWEzWFo zlT325XD{OP$)hJXbm~)3*`9OzrrN@;{b7g*cz3KORR-f-GjX&gS0;E5%yT8f^4~9? z)dJ`dxI_1@>r>$JY4i=BX(1x<%#at4r1xM|-FEAgHh6d&&0847qNnZ;~F<|u*_d3{Q;K&_0UGU>D`tezej5~sY#zsO=SEo&jo2(k7 zQ~x%Ir#3gpC*F0~#6@Q`9nCNhWUQ9Rl&((nSBw%gNTrU?6ce=^HmJ2&I+Zf4sF9bu zK{THtCpScevFFQoGPn<~W!xS%0K8n6sC|=+{+Rm2o*IqJ7aKs9MQK-#&Qax#xOJSS z2+Q3cI@O+H=q6gHk5kjK$TH#oc{`PjY5IHApm1;Pl*<6M>&Nc-tLT_wZgAyq0P$Fn z8be`C`kqE4?o~?Lz^YaTlNQ{M~0)>gZG* zLkT|Fq<-fFJ6KMy(!NV=Y(*ndM!(s zy8E_6)IJzJoA6omOxqPHo-syVS@StUc?POfs7kW>JlO=b?ZbqGz6`#iQ52kmc~J~` z)h#ZGi?Rgw<7)=bR)&lC2le5Xw)=M)Pt8=MA<_;XMS-HOmokR$DY12@G{hXieIwg$ zvWcWK;`*I7Q|sgom<)5MK8kqo(gj`#2#_S)wQH-bHl5(qX(ZGBJC)g*2BEx z89u_Pj3cSw)i<{G5Y`bxw}k16xi8mKH96VH;Aa|BNiZ1)vtBTma+ySUPq$Z9bfaCI z{1)<{=WhJU+2q=lnn zNa}|oTS;(>)5-4HTej&cyDyCIBP{Q=hz&R@v`C;}DT|d>72iW%2k97oJ_(7dNK|vOE^`2%C>#?X-&f^c%v!nBFox8`IK{YI#i=OW*b0EKhtA?vlsjxiJ zu68P+-sUAF*mTiF^Qbg_bsJfNMi~x+MqBN{=R%-^XWx5{2)%+K9R{B_o%!4-raQ(D z^)YEfO1!?lKyk9Y5f^G2PZ2~f7~_{)%BbWUXl|_FE}i}0O^BiuACzWEHL_MsP*+04Dbdc?zP^yIP?qbE|X#!z30yMDk^XO0;GVlQMH+BeYjF77ZAR) zsG8ncoztScTL61wx(U%7{k=3p!0r$7R`Hz)E{LWE@;0-12)hb4b5x~T&wiy=xCeIL ze3J_Xj5$S9=gfrEMt3#@w_F)Br91WH=0_`}AsFs-=Z+Ev=_i@5Pb?Fi?XLRe6_?zm zU7}_02#rO&X%X#M4^u5;dA`SX@r-;sL=_$B2nf!oX#mgD)Y>x8jZM}y+_u17@}%s{ zvTLyE>5gwd>`h7m@FNeyG0B({Gsz71c4k|5yN9QY?A1yb2I_A;TqTFX6z4~$i*PY^ z;jro)g5z0U_TtEdFwPHoMe?DL0w=Rx#WJ&y+nJshm=U>@Vc^3VJ^{wgy=T+?lD9k- z{W)PfgdsaiBOZ5k{7Z9T-V|=|z14B`fTh4;@j^KxuN1Fv?ca%aJNC~OcRnEX=vo#; zyhR2V%K5{8eZAZC1PqM#;r6~!U$>@vY+%x7`e9csqVkV-uiW9y^XjY@HJJYME!{9L zTDrZ5TYyzEZwm>jrZ!cgDRHt2ORlza&`=;<8sD2CBR_4-ejqg|P}q`hZ@1qKvZpL) zcubp#$DB)EDwc){hVBWr$_oWKAGLy!w{B*^V!Cdh?g zoE|NSuUa(p9)rJYGiY#2i*cM%^h%U7b@3`09#w4ywSbgm3%%TL*z6PJP&-{2`ytZ@)7u>g(S`W%_>745I}COxQu?AEv%(d_X^*H)vglIdV>=b zJBg>{Z>sq#vkv=?sja|!5nCk9zL!bXD9%X=VMJ-Td0`TmD?V_|_O07oX(=IOeZTUq z*zs@Ur{hSYHTiE!aeZF3Zg<6u=3+^KXrQN1b+=eFbsaH@vCO97nFFe&qf}G{V^lm~ z7q4mV{W@@^Q!85b4?0U?)U01J!R0F}BpvtO+RU2tjrJkG4g1D2#<*8@;xV zUwN)bS7UO2G+JN6WcUPJLNSY&;{!0n4T*(17`KrJ6~&JyNrBBy*IXe~61d#HUzlTF zi`t<%xYel^Ojb+8kw~^Wu3gEtrh=0nnU(vgigyM34f*=NZ~@;|wmK!h(y~Qar%hcV zB3#T}G9X;IK^=b=?epFxDJ-Ugf{n_4NC=CqS_f^sTruG=X`3VjK(#sNAHl2N&$Lvs zwAeakZ)*FpgRH@G2c2tw&=YjljDwQzzF`O@E)scQ7FsoZI+~l9b4JuOEsys?k~iSQ zFv!nb9NSN}5qr6paS{*dwhr%44-wgyRRgpQY{jbGV(t&RD#0lk1yBB^0S`a#=W?&BGDbq)QdE?f~<^DsKRBjtnq-6{4Y zxaue4rjpO%-35dX`1j(Uqh(vhyV?i5qppAmrxQ|1Y4@lRu}xclU_h69$b`vaMmv;!{h%;DOW zXZ{nu+O4b~rf*_fX^{SEG2L-?N%0&3zGagXJG+j^nw=@o(riR)vOaz~u#3gZT5~wg zBddYF_bw_EL_LdU*FiIU%AdUE9b=vInp+NAW|blp*V(2Fd?=tWtAj{9WF)TJ=Y=si zg43EF(VIo=B$@NrWZ-Qh-NSZ7&k z{RRtvH?TZ{FO#yqG|8;peKL}J3`%cbj*y=7+hz>maMp=BrG{R@ zt*Dof1Yk^`|5v}*T{P1}L}4!uJ59I%m9jj#;ZLewS#4N@#21o{IQtRmxov~F56ptz zk7TBgke{HRCgLB_oU79xn?J99T9Jt+pxVn}N?)4)({BmkC;I8|*>ABT`*;18|65J_ zFB>o_dY{X+pUJL8YiAiH85Yfd=UcR+QQXA9r^BG%h>)zQiqLOu69`&oPtWNZ@dW)M z1Odo!uMi~QOXGeB(m z&ljRTXsL#oBrn_w%K64Q5y0)(7yvL_@ zm0T?ROLnDxX^vLHc=Y3NsF0mrIUEv!tSN_s1b>|l?_E-*N`VhO(q})t!^oSCMQx% zS*CgyN50$uqYj<*CM-dPOS8y_TIN#of4M#9s2igM82fxnzaA_alS3NNdID9-*7=cY-<_~}aO%$4;N`gyP zaii~}OX;CJVu{@BT9cGJ&rJMzksLKS_0_MC5>mOu67P%d2fJCeTki{#r3OUOvF~qy zi}mN82jAZh)uo^u9#7mqX6ibKaMUoIBUHjXUowAY6R}{!Y*Gkt(HWzOgK+_WPaX0wc-0M8%;Q5jIU(=znK9w!$jOj+h6*EP%fG<(fKSDncD6YOSQ!hm2Z&aK?Ul%?9X#e z6QCujT-Kr$c%1@AS{x~S=}PLgdSy2HAj`^YKR?2_qxR3{aknI<_I>*gxMi^SoNh66r zv-b6Mpe=DS{Xou+B!FVsFT2|6wvt|r3}S}#T-a($adH`LB9H3S1U20bq0hUI^>_5K zz$b)q#@fO6$_Wp=zi$v>3GxeTha>ZLJ-A|s5sE9z(0 zdXpz_R;TBZ9=vq^+%N5~%hU0ihu6Km)&?~$B{5p}Dg_U2tW$_=1O-XKP>M0}lW!Tr z?=kyMsblv2~zXxgO9z@=q;9!QDm-W=*j zJ^^?xx-0ZiRbFN`dLVZh55-+8%=jJ7t;J<44VM}xGBfiDrnkAZ~^Kq6UQ054bzWJG^O{he@W4e`6zzS1E~{ijCo2JIu* zd)cPKV`I>7sz=)QlFf@pD1cbcU$l`~G;dY!FdNO@Pr7)6<{%`gz=K)*!fg6f=$Ha5R9f0V9lRS_2oLf^7LAY~(WK5E#Z8{b)#ytc^-N8T= z16>mT^o|hzR5meIXC*%qgV~@8c)I3+bW~)Yd96I&5ZWu4I!`&zYX&cWd$XR9L`9+96;obih+j~u;J4hA_Sn74dm-EUYg#qnzHOW{{sbXbvrBL{uWGU_!&OGEEcK)T@}@&p@p9%BVafxWWht{Hl?-|9@L^iMkWbR7q(m6I9UWrUZ#x@yA@)? zS+&fJ<32Hiv;i1~3J_j1+9I))F>M9~j&0d39uYjUBxu`RW<)zza<~f2Z(N zm_0Yt@6<001^qZV)}^82aWKd2x0;FWQ>x3mQ1In$t!|4b+)+Cw5yE~E!;ZV$Wg2{q z08jWvq_Y{-!StT(^dd1WZZ(ksuSYwSd@oB`2gn_qQkBRPspQxe3=B^Gon?{;*_xv; z&QxgSdzUoE-8ApPtIMXr#;8nUm+ufwUvq}#Mvo@2A%CZwbnBy{Rw`qy#D1=DW_ z*Tn#m=vviW|cKw|% z`id9BelQ`^nzc z^vfsEN-DeMB|hqj;+_HRfX6i2NWb{Qtzf*Tk_T?Ap7{xsmZduCjQh3nla0~JPAKqG zmBoA=;71X&$i&Hx2gtd?WjyRXVJPa1P*YPjiK}exvVk-mznu8hMB1&Po5x(~&^Z?%2p z-1(9t%v$Z>fV_ZG!s|d|h}V#MJtS2RRQ>x8OJkdFcrp8@>x}c-!4nak zNPSE}7!(5xiC4c*O_|gOFdMDrwp_JxJ^0T&!Os8SiCxHdVc5U?*Y5p#0XVzUrz_tO z`~O*Q{L91cU-X8Wj>13LNszEQ(kNdUsXo_riX}C!0u&jC##aLRQBi#}&tuM}&g2`{ z3f?g`e6G{`H|d!LUJ9ek-QXbDgqx%u#e z=DSEJT~X$6Uub8%>pG8u5YsYEYx1Kl9KPvsfhDPEAGWspQFBttkZx*0eLMrN@==yT zT>rR?nJh$8Yqg14J{<)=UhY5)R444K+YA3gC)1jwQM=j!PoTWVxo>0=UO|fG(AhLb zy9I=oMe~;b>!U*_)jeh0Il`(<1z?;ubF*M2wx#GNn+{GVYiP6Glt*=Uocv>h`oIiw z*m9tU+)vc}Q{Z1rM)>R5`HZTYJO$!774wQJ9OMCX;5en*g58f8`FpyZfL_yh_%dRC z$cwFuDXerR>Ww?Srp~I%eQd@Wg`a`C1$jS`?(W&#L8Q-6p78)BW-VsW9TAhC+<^P8 zyD3u}_ZG|h16tvR2mTZSka`Vg)}u}{{3iJeD(T=Q(D z!eh8~MfwM4SxUs%EdX<&?1Sw$@#!xr36-DDjCW?Y4j?Ur$m2kQHK~xJ!mb_Mqy8{r zFK@!ocXod_m^Bk`3yw%L+^<(IoOmB$CDq7|0XgAQ8%SUW4hiC=B=}3S#0vP`TmW5j zOMKE5i4Q-Zc-O^H>6O_tSjGlP%NO(vz&BS@xKAOL@flk74+!J`JhJBbPu3~^rQ8%vooxSQY^~|;gAT%Y z7w_oguf`-pL`LCCBN>tsp&M_AXR1dT9O4c-1w%P)`nx8r-PG#6w1yUjUfLeSwMH#p z>$c4W<7R^qmc8E}1MvD(QaM~P!*I4ceQ1LeJNJurDoj zA-E<#r0PsniSY&+pH||xfRQ91L2(nC!7Zwo%LfZ|iKiEC_Qjxs5f8$g$?prJpZF)L zEio1&4@Y#y@NLL+D!bhPy97s8eVQF?ef3D4OD7z>%LwcH(UrM$8Lf=hF^9>N@R?+bS_>%){U9w>H)YBvD7Kjk7=&fgmIq zE{1<1n6^k!&rRbRIufN~I^gMHWFF?C3=tnzLgidVN7HjgG!PcpZDh{q;dyaLR^Uf3 zTUeV0Xw9w9jiFtaEVJ_&3^lzJ7-nmEUz+?9&5U4pi_?8Gj4v-#$FWn>iVoIX1c%#Rhnj zEw&g*6CQUsda^UK#PM&86T%O)nsJ7={*+TGhL%7#$iMHamvvj^-cXRT+c)()LKOV; z>|GM0upr5{SmB;+N$E+iT}=&OTCA(GyLd@mk1Nl-UW;Xd03YncK-4JxIKC@_drVwv zBWn;80dMM_|HUF0BvON1a@cMB;hm>sR2Ge9{}i$fb>BDJ5=i)!$%O#V8lm=wtXl>7 z17hOot|vRoM{@Xuog;c7C(j(rg`t=1)%gTIf^qphtGdqC@u;&iGUJ0Ng4XO#sJ686 z;*n%qHNvA6Ua>X2R3>6W<+*7zRC$&;vS?wM8z)2@C+~rj*IYn*?;OjUWpz2(RR#wW zU5o;&ul)xxOJ3uXcElSgsS&?=k1R@dle4_^2DuT9y0X-QvlGmBH3vb$ADS#^3k2MK zvL`VCZaz`ljhfeM7>*F%L6l@Z%DttRL~0pk5V?baS+}gJiOPi;#hb)@vW8{tW|@Yb z9f__ku|+hGbcE`45Li+kqP+(W(!B>)5HJS24Lzd%Kj&2pQ#qB4}%F zPyAQySNd?qaqJo~d>{Y=~@T0pK9#)h2X11uUFOH$xCOL--?$quN8!Vrsor{*H0Yf6)(hZ(08&|rQY02 zbBLe41~~hvW)R7-+x>Rq1O?a{mz=NJBl zK$H$M$GKUE=8{~5vbGe*qQXZhl~7ehs3q338jBkd2M22f8IJ14m>X3JIU1lJO&SR3 zyp3HNYiefEWJ$wE2F#=xt~?d#nL1F)(B5_>@Q5v`y`GnNEbwLS>g#gjLf9q@DxKH( zc6Qb-4c9d%1fY@yH2mh7=xhv289!FnZgMppXl%Ek$$jW2tZjlRVk&g{OR60&cI6cR zYH@u^{rkTEz()DkyGh>mvA+9A3l$;Peq`X-DVjvpK`1_@nI?NDW|E$$s!WK|#@-Wm z6Ng{R^F;fQZt$YV4|mIQ;_VeLbpiLeyW6PB60Sh)ALL3{u1F+96hZq(!7~k2tuB z4HV41A5kFf(m9HhbzTQfl&hEGqtK+`=npf7Ptt6Th0R1~{Z$@RFLEv)=t_k1 z+ZA}V4;bg^8g0FUPUe^Y*x74$9~Vk<3c*lowJapE%AMDq1lWc39m*)u2F11aQ&Bt2`ml-A1VVgUAFD zax$`n61Fn3IH0bS`4^@SyX{J#x)%qL?4;UlE3PA(A^-eTjrBC~e2|Ze5gw7aE|MQ} zJNk-cw6!DUl{3s4S{WXI|ExQ&^o%%Yfj}^Pv3I`3k?s__+B%#*f<9*0*utV6>qd*T zyxjy|LDM~pt1_5S1|{Dd&T2Y>r>gJU%(1h_&> zq2%L;WVgfBxcv8gTnsV(5mvO7hmhSBq%NqHFt;T!4#pO!*4R8G(eYAMrfmp#kB3rG zhuZ`R_N?v3!{8ab1<{5Ac9v1{1(b>A%L+4 z6Pl3pnT!}47`+(!7Bnipebo0g^0z8Lzy;?NX0g|HZl8^6_7LhY{cE zIP^X>lg|HWrvC?;nVY4d+kdBn{2O1V)PM9G{Fgud`_z#Wrxj83_xbwj{<40#ouu_y zqd#s8(w5Y0QV4RV0g(wMTrfrGBiieZ9P#9&!zG@Oguf&<-Oa=Lrf@@|L#jdmX%@7n`|-=C8piYk<-of6dVRE{#?NGd~{qzJ7lX`q0R0rZ5nLQ$nY z5UzlfFlY@ur7lYZ#?-ZoGfLs_vlcAI>cV9^WTIhP-O!@PE_aTclEm~<0+`ST>Wdud|a3?)*(32^}nnTExVhVq6kjnCO1PZ)Ph!wx~J*O~BF zrmYOv;&Mk}f881>x?J@erC7~6Fk3m>DgSaS4`NWldky51rP!Xo1jOuVFj9GEQ$_HT zw=}05Xagx*0o=(%g>~lM+gpbKW;wx;p_$<7^ zb@~0Ve#QbhkESB2vqS3VS31^>1P#O@QY$)aCs7}YjCNlCD4StKVbk-boYADxk}SHN z;HtY+ZTrVWwiOwFGk5I@cIKJb35XfhG;Vv#wYXjV)2z!&^O_&SsA$^uIr?4j{A0a} z6^duTtgWq#Q+2ZVg*gXDlEXJxQ9&P9oc*$_uDGS?1gNr@6~gH16HJc~>*5m);_2ya zg~!@gJF%4}jCa{c4i!D}2ms;s%=Ri3THoVlgc-hn{B#KEtj+qicB3B;Kg&IPhbvy) z-AM}ua0x=g?q)_4PS(;Y$5PETciKn!jbz0OJU*(;_G!dHML5PL!Sl3cDPAn>CwC$TX_9jYpVv|0d z>{%d&**ywvR^)|oS)9}ik~ z?;$ZqKN4$<_DB5TY9M2nYyO-67Fg7jVOWj_R(Y=DUmrx@lP{&PdR#JIb!d%n+VsXEEz%pyL3l2iSv1y&TWAYeejf2+hlu562$!&g}SAO)5zWhhR>+m zX)vRiy@34V3>#DWkbFuA8axUfCQei2jlD&}EP(&yoID}d|HC&{nm$SW z4D2?)B4@tNDa`PkQ6V`^!e|$CtE$z;Ap>;!F`vUs=ndwn-SGN&f78 ztJ%cE($E{jWQwxpc%L6|XXtUi3jC$PE-n^HfCHkzcR$KpD2pHtSL9IpNH=hw&o|%LcQP4Taa2=W+Pd%qJ^9RSM6dRYMY7o#Xz`TaLJ;YH%kuL z7cPqy8mJ9c;@$kh4!E6(NOZpI8OPKzud7JC!BF8 zU)Q4E-Ivbjbuog5ylMtYA!5=yk+u!68IB1sRZk-ZTuE7>uBo{aSf9@XFdLGfB{-JK zpUtI7buh|RCY}Ku7-tNN5_|a9kODOzp$pbRM`J50M-{+f75dn$D#&doO|JvJeTHcs zm_oRbpd5z=T#-003nM*|I2}g^0zy|bT^vDudUP;jXZrT5l=i8@=p1VJ*0YG}90q-1 zC66WwvIg}=7oKfMgg_wW%~e;Uc9<>HXte9!BI^j=`$u}d3!R^Oi>1}z;>$Ek_~=~c zzb_=TNsf?GE;nO*ZRCF>(OHXsWL416^T_8AQ1G|Eq>hQSCfVRT)&0&c72TX$Pgz%0 zWp^ZzOWfyC5PNw>)_=~;XSBiU&YfFXP(5Rg8CJJu$H%^PtWZvI8vU?D>RIEPI1gk! z-6ve+@Yp-m7?981dBGm^6dbb%cZ``7d14p!+;`vg8)q`OdMCf`$_)YJpvW2qOvlTy z*0I*EHL9qST#N5J-Uzx=tuCD z`JVK2d6q|Xd}*zsN9LR4pkodW15;zHRFXsTM|t?Eee#ukdD`CT!knTI4#+V89*rwF zvFkc3-2}m0a{xWwjdJ2TL!C?F8h_YUBzIuhXmN{0UcV<`TiK^i!bZT&clNJ7nZc}E&K$f zA}%i@=={_j9*OS~8GxLf85zcdM{q8&U8S|%g}0X))nX&r$Jc9AXPZpw;K9E7o*@>p#l5zq zcx|1tpV6~}iLpR~Af{8rf4)J85lqXKWNHKRg?aqY}~I%V3Ga7{ife ze#jNYZ>=RR+(;EWec@&?N8D8`6%TC$~y&rpY&0fQn)zD~)GP~Quh zvl4rd(JL$g&7{*LBBG`KEi-9|j;rTmN+2|{c;h@6PO#iVh|RZK(r?YC?_|XR5y+01 zMKmZ3IAYDhr+<|50(Q3i;M&;%52i=4So-Us+T*SWypvPz30sSbcYQ}=3|THIp|h** zGywSVVKhX7RELzBE+3KGnJa&zgb@;1{=6P@B%AN~YAEY~UGF9LcQzm`$1hyNqWRbWIa{V;X`1#+{07-Rrc0RwWqP!_BxA9A?R98>`@a&)gihWZ0h z|B)VB>sf(VR{jKoHW(~210}aSjK8!|yb~3B>EWPr(IslPN3=j!G59)Q zKmvZ7H6#YzG*n%e{G5c1_zF(_a0rlMy;tG(-;Zl_g*=S*Pg76GzcuyzN2rs3eO&)f zfv6f9*_i(C0KQ_?Gi5X>bpC7;R*EQOWF@VIGCbFWJT$@kJ_ra1lftk4RO(No6GhR1 zeX?0c`IkyQaIIFZravFQ2qf*D$wON-SSJ_J%o;r8IA0ujzwDI$6#UW_;spt4D-v+S zq@dB#9ZV+H9cU(g4KQd-1KL~Ndt)wKNu->XAdF$R^*UHYdIxj4Wx}^FLvC!l(dkY4 z-IjGQjmM=-u9YborqyuwmaMHpd#)r4^ERyLuR6VnA9CmfV6L{d>h_QWhY);T{IG}q zz;uOnZNWgW?mX9Y4PVaje37T*W3gOv#p&>~em?mXc>-Vllt+y%ZdJpmzC9iS-OSmi zN$=3sIswqA?#!f4CJNNL^F^8P=8FKQxA*y(6g-+_Z`4`v_`Ge(w485o6PI?Qe!%B- zgc7iBGf$psr1Ge2o)GSq3QzelnMT~%b{5uBWI+N}bmPDakB=gTB#Q2xz(R9wd}1>X zQGW_oe=IYNO6*TgDjc;Fh>wkkR()fX-rD(1djnkG)&^Rl-R#(I^ngWuNwCJ&X`!`Q zEq9*GK2c_U6D532Drl~8!3d@2*p#1@=sr_A!V5Vxrfuh#_hZ|Rff|V>T5RL$8^ot? z=qAtd$NXo|Z92B_M86??CiZ|W*bN0{oyBHMIQgq(p4B$Pd3u@QQa`LZ!YXHd2o%M{ zCf(i8*N70q^Sl5i{IfMt-|G2F=#Y~Q0&MC|Bh8;`%B?R(nIT1LJ|e+D0&3ir>#~6AmIG{;$@~I;^VYd-$|;cc*l>q;z+u#G$(+RRj(#T}p>RD4l|I zOG-&7B_Lgb629B({e9&a_oDaR_aA(od)8-G%$k|KXJ*mukf-q@9a1IaKO`9+W~U62 zj_|al05!>`bqz9Lz7*W-xO!CUUK4iWpVBb0tdi2Z9UH){#-cemYP{M=s!^N0$%=cZ zC!wFEJWqYkR-4c`^E?3I%cw`;BqM4CjC%F|IO_ekPR;dy^HN7mL!i(AA5xusZHPF$ z^k(G!@#jNxL%Ad1T%H0xUU5mv$xrolQ{c!Hzr_Hv)nmm|_**61cGs;x!G3BnU3zTo zjID70)!Lneo~@}0>#Y5B_YWHZAC9(Fq5E^myAVZ{Zs1ZdrYcfK*|*i+leqigU4aKp zAiO_IN>=x>ISju#X(uZS-RhDfd=^t}8|Gm(Du0qSL!zgjti6NKbC9=J-%_<%A%sbvZL80fcCS;$!#&18vxm2GQ)g4CoDjtON$i{5~ukyL8zrhn` z+#5FR>}Q8qi9+0{#qAs;ZVtw^TlZZ8MrpDLMjZW){50*Ei&~j2Un{)fR&q?MK{V?= zik3-A?MtKbX}@8S=Ml-$`gDiTgaob&bG_6H6k*byxuHCqr^ByY(fDwm{hA22UC*AB zra%aMtC03#?Kv44;tgE2neYM;<4WNk@fKsS_n3{r%s$zk+mW`$PGQsNXLx+QXX7;? zZ0>uKKA|MZ_!|d!nRc^p$)CBWFui$7l%!E~-0D+lb00T{-Ya1{N;t4f5@8N;VR<^cWZblMzM{C0$X=#-{ z%#HBGBYDg?skJM(Rpd>{Yx-6Z-t@^aF|dD8VT{~f=89-J+-Ua-VrJu)y!FbqH|UeVC~vHKap{?3m0K8^%gI9SC7ia zoABt!?2tCb)M{uE`;pvh6mTSLExItzh@Wcsl4RH1T5G-uy8A)T8bWePpmey5ypFT^ z(7eXcQ*uXm1W?L@CcOZL3Zq_B8~k3gKKh|LkJ~6m_6P@p1EY@|5}QI<(h{R3HB!$P z1<-t1Sm0^T7>h>czgMk3C$gfG4k-{~-o{>%aykv6;wW=;9IG=2U7 z-vB0c!mL!q!47=}Np9WomDZyy%JOufX3Vyj+WURyFx4@u(21BjY@0M*B3vSPYmXPN z$OV_i%)>r5b2vX3tXS)U!$Atm2$8UW=PbqwXA(5*f`5Mi|Ee_X<((atIuY3y`%-L5 z4VvCpwh^x5VgxZPh~$Skp~9Ef%3Xg>5j;GWFP}iAOq%loQ!_S0l8v&3BU(CWeE#ct z*m0oTrpNDz=4Lk&1-#mvDLG3)I^o`1Nt2(%HSERRU~j(J!*SbY^*A{rIB}$-QaM~-N+A^?WIpf?OhGV7(`&QG;Vm95sFg?{ob#$hbubommd1Tmm;-+|f`DZec0tLiFi&&! zgl~$mFJE4{y6T+8TIveLDfBr*R|R9p^`R?1-GY7tnfn>*?^d2|i$N8e)5LJjj4fqe zJwoYjW4ZyItxwP)fcq`h;#RbM}NinGdtA9Pu1+XdSGZ+cS1Ki z-Ogn^u)!>vP<0K#?o%x@{_2KX&sc+WXdA031Fv|Q?n#=S7~>WWp`AI-?ZHE@jDsl0 zP!OClV69U*(keH>5tc(w&-CwB3|V$NfHQBT7Waui-}E$~R+u4T8FAE~&N;`xBn7W!bRHC|lZTpAed z(WIrtxNeRUb_;Opcr%`{^i(?ngI5mL2Ws8t$@25`*hb^xud+&-58G19eQ91ftrB_P zSfCUdAzZUZsb zkyMjR7{hVuk(O5MBy+JhNW<(Bi``RnS;!Up1JLH`=@V!!)N z^WswQ?>VFHi6)LN?l~W{7gCWNCdJ{f_V86`Bt%i@xUSqXDnxlT8&)>6jHL`xP2SO zrcE`;rZb^fko_$qMW<^^C_V#>B{Yt(hA3hxZg%;RbhVR0GadB(JADqT5i#JA;xsE| zFt0weAha(0Dhw+5Lkz<>YaDLj%nxQlRz61i^F&70Xg-tS);_{rI>PL4;i1`)z2%$x zgiUs-?&wan+ryX;?11l(2+tklAUW^W_AEN017{!A59cb)2@6|VQhFcmkEU62jdZn8 zG#2+W%vZ*zA$KVo_W`x~9#`n54_8FRLXl{VWW(yWNsBua@NzzlR?{V4bL2w~`Vt8e5 zx22|nuhcN_hiM`fZg$)DdZ6%0Le>ZuPCcJs!Ru`9`&<^9XzXe={%TU0JxJ)XI*Rut zwH0*n+ymqJn_G8!Dj0dKu}K~0g-Gqt?y`?KSTyShINPmpj6N4Jw~ZaNPax%E$y#b2 zWJz_yLSJ8a7+=qoy~JWez8$ZiS*Q=EX$XfyYyZrZSJ}M-f!0Qua+Qk;uJvh@y(Upd z|2pnc&hkE4AC}P*oSxM8iG?*3^z?Y|i>*>+nO0f4!4tr*+@SK3$mdZL3N!8BpDR6 z_jyjg5a3U_fGL`t+BbB0E0~3@-Y>TtcP+&{2uWU) zAe?>yIKa457G{V#M*}agk!Xc0;we82TM~MAyjPElI4QoYTTR0$kpV%zqUI3?5$-OM zDBf_$pcE<%8+D*4mb{wu+eJ66E#+9_kXK^D0^(#Q*ZdU7lb@`tZRFxYz94t zzbn|3jmpwXfn~Z-#0yROcDE`_=okzgptxc!j~wYusvbe_^Dw5TFUKgNkL6Y209y}I zJno^F7yLwfZc@%|`USt!=3ZwOHVpcFITp@tT1!I>vP7BsJb6Jj_Ap{cC1CJ(QbSoPE0MO87< z(Y)GmRn3f8eZ=QPr2wS}6e6Hg{@8X;B3a=+TU`Pj|NQL+8VyMdUA^^sUGnlljfRe* z3Ogp}_~d}1DfYBt<7wUxL-Hxd=&fv@TpV)-9WYKebP6)FjEfIG1R_JBYx)J>%8(=~ zfvyfdodbgf6JO>DFFmWpU|U+*ZrhJsUVIEPmDwcM$|2{SjC?s6YQa<9Q!OiW4XS7& zd~qowPjLtCC1+yf&WQ6{xm66ry#2=qC-2noKH*U}p000*c70mkYzjRrdXm-#7JS80 zzN2qLwLnolBt88sXiiy`DEeS%G*a}6i1Mllb0^s6*jW;l*C9)G(^$(OBf7s~0&fxe z(@JiVxv(53d9@nt^c-GZ)GZVr6qN|Oz><(FN_x$>31!W#g&r_2y#zqTRPOF7N+leSLbaKe8 z6Llm=#f4M`z4f{WCd_%Wvr3wO|24_}B#3JJybj8q{a&4ySy#ESKs5LGdn(^m!)|qI z8E2W=Yf@{~UG7)>r;HPQw(c}pr`O)%=*SWqItR0x+;EdX}NhLNp{B`r@N zbxc%J^4Z2N@41rT=-s?#1UV$zeoFXb}znGQ9<|XJGTP% zewt$b(`P#I-yG6(Y|V7O?jpFj3)IJmbd2n?C{UCfglLI_Ew6MJX?PZX=CM4F_(Gtp z93mB4w#~FaGu%}cp<1Bgl!3kBrlYgpW5>;cvJ~wi%t`~l*M(Iz%Jvw3Z;lE|BHkQX z>FG_X(cV6QeeSbAw|#nk?+6^4)o=t2MI!CUX%b=&Q_B}t;_V6bEN*ZDVdvUM{{T+n zT`=Wb*gA~2CX_S!-Wlt4VBh%wW{b@!!9qtR}?Tite1DPX-|!yP73k|?T;leAI(QZ zG7Ln@jJ3XMBl;o-G*lYTStX!|6LJ*KYIU{$I`>-p{e(5DiZ0vo1oX6iEy<rJ2vgh{a zUQEM8MyI_it-UuvCX&FXnW3L@wK1~qy@m#30XzOp4V`jTUoo3r7$tYpBe`k%h7Occ zsof>oN*s zPjrZvX6zg!l2ML|Js(0VZD|(E&5zT0B zWuCyXI`j2jze1bis(WwV))3!%w0LwJ1QvULjB{SR$bMXO@5MZDy?D-I)-eG_+P=fI zyik9X@xxK)qlbN`$2SEtnV4l91vAHYDNa)q2NM_V&<5XoqvH@aL}BLMv085K1ud)L zC(uh%DT)(_s!KVPv*ABUU*KL8tzoH^9zIQ@vZM_*CAbfFf@xA1d56IY{yjB=f=5oI zh77MN7b1&xQ8JmumYz)OHCo;^^Eiev=`_;b4s+w+cI-|^g=R0BSyd{Hbq!;!Fc8a$ z{M|LA!pP+XIAg5{ym~!Gl~)~1Wd;QHJBe(C?RJ5mLf%A9`mI1`GjohTBxjq>ov~Xo zb0tlQl-Eldol;5<_LM2Icq5iM-af!XS2e|{3AS+G?f=*oi-%W(UN#W|OEM`&9W+(Z-4ASH2vYr6+ij9JB)!>)e4vHwO$t)^ z50lGzW(MuYFtm~|Bi~ynq}Ri8JxdN@AAFMyRB(FlT$OwrX{(D(jY!0|llYr>#blZ*p|=x}W1mVWZ>FghZ8T z!B3$gsH)w&d@HbAH|Xfm=o1`DM4skX?iEp+7GUBlhtD;tQm2isU47P$%b)0KMH@_i zBeO$yl78JlG0mf{>y=a$+jwN@y_7|}z$#5t9k)qx4hz=z=P&*8%LZeS6xJ0H9?kJ! z(NVKji^Q6NM6S)UsNV5|pLL@3!?CJ=U66i4+GCcOm4`Czp*`@DB&~7Uk`~+bp-0eF zJGk+|K8nCG_tAM;9&=`>%&tAZzzXVt!InDG!NqA4+}t~ZNy81467UubQDA=yh6wPf z#ZWHq5v2=#4a!ivD^Xe?FM|wTFGD?yeHqNUOVevja~EhfxK~PrIHz@p({=PoBFeWY zvL58!q*3FJSa7TwR^!mZ-iwhi)pp^&TXZk`fFnX8Qbyg25L7a(&O$EzcndN4)!cRc zX5V0SmAnEGd#tyF4@J~ptG6979H}lVuu?y6lW|b1cFdnMPY<)&ptOdgn+(Svu#q31 zdpQ}RQ((sJl^2b_J%37le08;0wXK7Af%r8%vVh%cD&^+Evcye&$rZRNJgb|{gQ1EF zE{q``yGJ@+^tlKo;l$qcJ+?)4(SqTMC@2Xn%b!~jG+xs*nTXDlxIx+nx7Fe1A^yZq!Ze&c0)oY{V&-gbon2MuBa>!VLhzy6I`XbrxVo{}FFQMtjd6y$XcE=D(61^~Uq%5tWFs$xosV)O z)~(uga4c(S)vijUWR@_OO;?huXkNk21(e@iCtL8ynLc5ODA869r&9G9rgE&Ckl`LV@N>HV3`quUMshS_!jF7OaP!Jk> zx0CVKJfXFA^`eJFJzfUtYyn($WUNVYN#CeolTx6ugv5TwY$6%~Yo=AUh;_SV45KM2L34&q`P=b6a zc}4fcn%UhmMQ0h0a8Q?_PAk3b8Yox2(ae-nw1VGeV&g91kr>ajwm^<%5sL-Zp_5$zG=Fyo>@@-qY`2JBHf7 zhQE_@|1b_gQT7TxFUu1_3?7#C)y{~47z+Dt8$CQ5*9?ww5h2XfGPhg9{muw()8VI^ zLo;5A@LhcfDor=sDMj47;)J{~uQge-HMmWnk2BE}DR8k33D0}0@Gx>DS4NEN_AA%X zyu8hsz`{<#{rhecT^b^XB8d6dn zgsYBXGJARMsN0Ur>QaJEb|jTUVvAerkR(x2yZ(BfJExOeFx|jJ4NErZkVI^1;L5F~ z6@Pvm`Q&OPT6e=pHzB_EE9*I6UUF@6CFnDTShY5KQtMNV*oqa><+}Bc#)R5AoC6vH z#LN^W0k||ezi;J4a4O9=p3uNcS!Vou$5JZ zf-1AJKCB=rSH^j0$wVywjm0P6yMbr|#C&KDExbcP6YviQ(n}Rw)U&%VkgcjKtCpo6 zHd^?_>BD;Or1d}QE9Oa&t()ZA!Mm$D+TUf%t9R24o?lH&9`2J#Iw@Q`TswY0-R;gK zv()OWfsb_TVkB^)7G?1|Xz}4NUCdEgISaPckE%rnTX*HMt8U1mm=Madcd^uElKR&5 zZwFl0VtGj$Z9zh5dbS|$;cM_##dt+_D)y%xqV0JEUeQxZc<3R^_uwT0@eMA z(7vHt(tV->tkH=%w?hZYqzX~bzcM!dpQo0ji;Zcu(#CD$40rl`6 zeF|kx%PSYfHpl20iMEXW0ARBmT*i(}khJw)buNHn0dEL^>%*g^|dELpwR?-G!=JD+v$rpQEq{%B_W1Rxum9+sP zBrO*3_;+r(B<ueh?qnaC@294-97;qfL)3vXJ%m!a)a2^_B|z!1UvEz zrSk`hH0~cz{@!KtJ*DT3$tw)NatXk@El6EriT;4{_s93|DcGKdK6Sw7Phz0Ye7OSc z+XGMb`;@QWe!ge;M?WMu2V!dz(1!OL0QifV<~JCs=5`EIHAg-@N08JVH6Y!gU zzsiY_Zdzr%4DRm^Yi40%3-SUvf}A|QCc%qc)$3mD(-vSiSt||{loo_a!fb!a_+O^D z0RDBdxKqJ6rv-Si4`>Bs3vL5S|GO7|rsdCC0GU93WoKpx8)yR?$p5_s?)E=1EEu(JJbCzPN4uj{9j#hL9&FIlk!){uWj~N z=s+eXG{vYJm4#6~J;gtY_ z_!uw~B#qPbPic@2`BlGXg3xW=>=HC9GYbz}XQv-+)`0UFss*UQdzS(VN)|#cqxtX1 zmH7(zd419E$0mHlr)DESEDr;*{N32(@&{1K?@G&jkK5J>0&4+jjhGw?N*F@NY_~ta zx&JyQqORYWT?Z7K1r&oMncV&p5@bAF?4b04T2a^l#T^)lASYiHftMi3nAw9=t*jhu zoj_lw760B>IUy{^9C8VYwVN%-%Eb*B(19N7{B`kgQHlGJ4K*@=V@v?YC_sq!{S)!B zUvO&w!~NP#@$~^h#z5EA0meH>u0Z@BsP!H9*G{Vu7OhMGoVEZs4RY{COS%LXQt+>` z!KyRr5 zOae)$$@?9`Eqmiu0mppVZw;BoW}p8F=}#QQ{^AlO2U`yiFpv7t zL8qtuy8Iz+VTGmmoP>I66B2FhNgS@EJP*UV*d#-ho_`3Qk>GsIrB!-?0P<_AbxuDUbOthcFhGQ) zl>sl+|8;46L62{=%UO*cLbrR^m!N$u%=mq(xLB3+I)u>C%L~}mHaz%gp1dw$UOxoIr~Ec|N4L9pN}yB diff --git a/PlanPluginBridge/PlanPluginBridge-4.1.3.jar b/PlanPluginBridge/PlanPluginBridge-4.1.3.jar deleted file mode 100644 index 91e61cf5f3c91d2645ae9f524ee528ee05849066..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 106110 zcmb@uWpJEbmNY0!Dls$KlEuu-%*?D3Gcz+YGc#EX7OTX}%*v^fq?5XlG&dx)cupSuZxPHG0 zc#^jQLjcMUrI1-^Q%J**HCWh`5*Rslj4cqFq+AW`d@JE}& zuR!H$A>N}$nCFAMWXKox-VO`xN-*!ZI`i5Dt{HCr<_I}+cVNb=0eWENH5h?+ z=~BGzl^lt7?GhcK^IP02y}x4~yT1ps8=^TpNX64X8Uf!t9;v>=tV>LyZShIna&iM)Gqer*7O9Ixk|GX@*kLgqc{liz56qWkhxEA4 zch0bbPmg;cVeuC25}gWAtXVO7CW zAe|m1jP!@)pC`IM4J-6981Q&MC#x8$y(Z2yN^*&axCs~7H6G|TQfQGn909m7aN3sX z7S~KW=d)T zW6s{8Uk+-;q$VuH7Z5H4zGG+@G=dKSG92x?aXD?9W9QTa)!gcd37$Jwo%KTuhcrR` z6WnA2(l9O-VD_kH$@p1C_sYTOT;HhZ;yzrZ=idO0nXn-=cK^ z>7vd_lgr4W{Cc7_!LyjF*lBLKp1-1_pC?LkBNMSQ`1Ve&KDE%%6FQn6c=520+F zD)H6)ZnNnJ|aiheogfC-hEl#2A942nwzk!%g&a=b_>Zw8-g$} zIRHnDlI!Q+FRUcK-2_h3xkxjCMZi(C(8OGJf&$$%;+W7299D-{i0uoz|8bm%)r9;I zqIPq3y16Akn5M!Z9l4u$g(R2V(LR@$yN96RW|`E*LZ6$5Pc3JjAg^4XHy%;TyThJx zW}bPGv06k+Zv~Sbot*~OQP5BA$#zv1NsH%A zvr;6tRK{ik@Mu%RWcIZ|;T%QNOMZqt*E%&e)^w<_WaUTUg^anTd6@Is($%lI3S>Fi z@zuma0^2^9&f4HSxLwy6Gi|x!5OS+2_W`_x)jB*oWqWi@7T3)Z=8Yygj>e_2TjtdX zE>xCIg{ecf0W2oARgjE?u$zvQ0t8pz*oSICVpwU-=%*(>+TFSV3Rm%A%29_q)ivnS^nc(TEM;U!&Dhoi=Wn&01H-r1&fMV*nVvD_| z)TZ)cG)$iv}WKasjY5{msu0j6Uj%?2rvYX(!U43V_e6#6s1!dk^oTtc8K|QEA6B7NKc>|NE zi+SRD@i%^x=Y?$jyO*ewkv~*JgPnsvv6Z;~=#M_UCC$UAwW>%0$D=g-tXFMU@p;H6 zkf&ZGjvmVc48EubDoNJ~4!$^xfGy5&j*9kke<_JY)H$NsqMMe2X|OmSA~&04(S)U} z4WvvQzvFYGVMU=8?C{ywbnM+0Ho@NwGnxidOt0CZf1DbaO9{utz%IpyC9W071EC#^ zema13{0*P# zH8V&lGaogi6L-Ee2#W#z7nB|nzj^>wRE&`+0Q8+&dkC^lT`O@l01(>8zTj zAVSF5srYwFJ%j9}BzO9#3x{qe`l#|fDDH9=554xp#(@eFN&88zmC;n%cNWR~QsxKM z?h?Fb+B%2qiiZj92zcJ1KZ2~4~ zZ*ToK0#>VTtFj@E;)j$yiVCMF`2Y?;1FvKnluk}y&FI3xKW7~vW-Dbo+tB(xI?y^e z%53`~{aa9A!A-VImgjvr^P^05oo{VuAuTTOF<8Of`|Xmyt*!H9$KdxPe1Hz+h=a_K z=Vbmc*QUB7^bJirO)os0GPPF&Wwf4j(2H$r{rqR~06 zFK|NkIX0NW`s>H!%Zw9@(8Jw9n_wjVaas$O)wqtOD_23oMFyc^jqmX?49}Rgs_+*$hH&h{rLGJzdOKuD(?kX-4T1)v znD_iT%})cA(i^jV3DF)gmuIq~VScaZCb^uSnB$*~s-5L>K9GW6MbUlbELQaQC$FDR ze4Nnk3eSkkC7S;QTtuw1gfsFQuZqDY?N-Rus; zWP(0&p{Zz5g8(HtD!>`8j>;s8YPN+*w|tB8tXHBJA4p*T0s9xyNJ*oi{(=AlQ~QH9 zf63H;j5M78uGEtR8e5w>sRE5`Oi7vk3t@CL@YOIrP>vvHJC5GW`QM6z>sk@HJ#>q zyL`B^H<-?Qeg9_Q58;5j!&VHDyzj^p;G6+R6nRFpEiOGE3+6Wo#T3r-DaKfT5-UVl zn-+V>Noq0;LbIR8sFm8p8f_b~0MR|z1NjCT<|hQ~7imSDtX51uU0N%xFhwhsHT8Wl ziG>3hnXx-!sNSZ+wLM6XpfuaV-DO!R2I~mz>Rpijq^0=qd?S}U{7?i<6kfjaBAp!_ zHEwS70w}AHiv)otG5HHaa$&A6@0Dg&B0jhDH}lMX4l^?@5o>9d7aOMh${aHbnarvp z2AVYTWz0f_b`TK-Vz7?!ccYD*v~&eo`b~vxPdBsySwcCeO2fM#qs0E`#QPp!h4>vR z_$EsUM~^)GxC_Ci?p~8qUinO7#)jhipyJFhI%3eQa=mQo#uIp3^mmasmlaJK_=TLB z#X-8#HSjSF`E~}GT?Ct~al_y)olUyg`%=}sk+#tYsZUOPgP^i5-GLM*BZ6$cKjqw-|N#u6^!`TQED-XbKB{!s%Jc2kr9 zY_%Y1M+Ivx5yz;nGSv#0ZRRY5Tu2*q*-^}(=gO`kTu1lvX^cXZ)|42dXJDJVcY@#`*bD#ZUV~U=Tas?imEG}R(8Q7n;S3qfu|7C0ybwbaF_5fXR z&7b;!#fSa?p7;aJfN3%O+ygtb<69-9iBGV->0?p+_l+@pFwoTREV{5KE6b7-m8A_i zj!OqTTr>(YNgS?g*(LqXI!Qf<+TMt(#Ghg0>#7rb#fyvtO@*TTgxWRrTYs_LEIt#1J;8*;Da-KW#!%Dcg%{y_XRwa_-@SY*pZ)dT9 z@rc4qs?7>tXpY9PzOJt=oz6X>Zw7iFXFz#JDLZHDV(Ao0u|Nx9 z5Shnv9Qn^rKaF2Bo{6Rgr7etJKDis4#PJC`!+t{kOw6f+I!cyvzgzXK(WdgUP5)Vg zv=B|++d=HyH>P!|2WiLCzq2`q8?HgaQl)d(>Q?IFAx~}fM(+aejwSN!jeCseFA+8 zf{7!hy|PPPqH3LVU9w38sgTEqXmZG&K*1v9MHv2R;w&ZLs#aPajWvqst+*lFqIZXJ zqLJrW!-8Pdq88Y=H^7{m-4-S*pOjjr~dQ@(c0M!{RSAdntV^Zv}T-F#_ zr^!*>^y`=g!!aRkAnCMB%QIxRv`n#`=A>ltz|UWYiZU@R)=4vR2?feYwLs?N zM#4m`qM|I;0D1$-Bh&lu#@pKLaWte zjLT|(YJvVxj<#kRZmPU7=51@Osrjw+nM5l9&+EP@9fX)y`gXY-AhL1sfDu%|=snM` zg@6*Ul7Jc!UuR|_ggLv=S6eBQ&9!kGP4C?KO4|9;04R5f!FxIp^}Wx%vJ1FACa8=V z^RcEq9JI%z-C?^nH5M&)R)?sAMYBKA)%;%gn}jY^llKZ^D~8v;>dA85<>w!1X49j@ zW6TA2Sn`;jQv+3LjLJngv*$?&T~9jO^~r4VHZ4K}Ru*xByACv;7+wn!5&|I-((@Ab z>|-<(9gwWzsk_$fmBqzlzM=b2*SmvG>M!uDsbyLt;$|G8p>3^yf-j|RbNK^qoe2$g zTjO}zOGyIdkv6yDDf2qY>$i9jbe?nyekgU8GL(JJg$wN25;kdYn*XxFtC)qp)KpJ* zm$CLmzQSF`_1XFRn$r?8Yh8U}OpNrm;&1T~Z@+rmy}7LsU%8DK7$D=812h*ZfEPgG zRmg7I8BBHV#mS!-G2@Moq)Xj6Ge7>c|VUpMlcWWF33Yxo_F_VnPo zF>=GRlf6y}-+I;7NDrE}NXE^XZG7r1*6^=3|E;qQ3D!iSUgL@r?<|-F3o|+-W32ZK z5X|vdH{{rt(RfFI!5($ba7zJ_^cy2{jRXhFWw{!%*O@(}{hUD(TlTQyV*^soN%QFl z7+uEi;_U1i&poe`L+D zc-sQctYe3?l)X9LpapZT?mGYWvO7zs656F1+yZ1!vhSEtS#bk14QN!#F&`Jq(S8fY zxaIf@N{jK)qW^-@;s1RoW%(PFrmC)~qYI&Q%Yj1x1L~_Hf}*kj8TIW!qNa(4nh;&? zGOvGpM{TyU;I6pR3I^4+{t$60WPxzpJ%*+5J5Eb|U~L3#-5J zits2il`x@!D2KIyM8%tqrgD_l%;FIg<6c!pGpxKTw?T#P0Xm@0%}oQEYuE*IoSAI- zAicQw3jf|u9ZRkq8``2^)WvfHK|`Vu`z++ z5X~Ou^q@Z1F@%Ot5fxS6v(>z?^h4~NEbAz-O7ZC5LiVz$g)&<8auatE3sJZ3xk+J` zge)GV#prt6+$bw^v08{)gx~JOK{|xa87uV##;7+gw8Z7cxHqnc4Mjk;5xis98e@?W zayZiLpA2!tI(zf%K~mrPV3qdy8Jyy8>x|(P<~XpBLbcl4%eNn_scjBt7($6v7zo4u zaFKx@YBme6lG+s_Ju5VChS%zwMQ%USWSD?4*yr`@#)b<`E$ziaKTbfFBV8EM*VV)Wm5_E2vue z)u^l^B2+^f6og$*6|g2HISg}5Q7Qv3ra^JlUBc=VT0BYfixkt*5I_K})8j9c=$x!T z$-^WboFeF!+|R3F9=ewJ1-T)0Umq{TkxzLNTcrI`o;;|1A=B{qghi|l@xK}bP4a7J zQ=%ud3tgamrN-u%LxxPN8Uw#zhl1&MfOfakXc15`U82j5E9)uR!nT<8+@^8uC?6Splq;|t@>z{ zGfVErra;w#v%83<(YmmB*yc0Wj(e~3O~>2HPVf7t-LHNY!Z4QVvJFOAnC_61FO1Qh z{4PfFeE|U)kX_VHbYxr46TG&}n3?B=z z#901a;4PzXy`m9-jxW;mGcuqCMicXvJD$UbGhD*vM>g;02ao7roCVh*oOzQ4RavAS z8zCCHvojZ)j9`HtN`?ub-15U-iD`vb&$mV+%~lMgx7_K9obG&Wx_QAS7RFL6)-`2# z?vBlcZ|7C6!6F7kJ*3rMt8Q6zw4u(?VY;fd!gC1Nu%tQ3bX+9a(xt$#Wc0he{+?Zo z@UTMRI54C^H9e`6H0G$pB$liJO{~U7b~1eGi*#uG8bE5j_rAhj%6(NH)1t1vqo64l zzS*yd4~y_T-7rw9SBKMTHXDX=`Q#wJ;id0fYK?L;=H4AUY`O+*7L+5Iy>55jS&dDK~?vgBCu@Vqp{h=10j3sgu|dF;AIjSHFkVUYjMvoZo)cMtB< z2DcM1c1j$+R*V0kVJrY)0o9|hBsWw)lugTf=)hEOE#W4JMeU2U)#)aLbZDc_H1#A& zIsi1mCS^y~u3x^ouMut4b(hf1{p?=8a!m?PMp7M9ahbu^scT>uC+2bx6ahmsP{SDy zPY}mM{V-A0Rf9vGJN#OtR1fE3>DfiI&)3CJ1pQ@JYGUoVGqRG^eof=8@BX+nZzaW4 z?7*Sf3nG|IZGsBwVQ!|-)q=Fg+!*Bv=XY|`xUJ!)?rhsP7S#L$c&Fa? z`jvxk;Uno^dj?h}Z#Z0T+w>UHI?%^XO{Am9ln-LqHXip1SlLh%B$AbP&C*prke7qE zClq@z?+ANNP}XX>!nX;_6r$-kK&I7&zgvssH7iNyZ*O;J)yry0HI@6_1aT8fO;%n? ze=2iJ)n-{HPd~3xBd${UripyLeFW4!&t;fWS;p(qQga_YKd|u%t->+#@JdpQp~?u4Y6)VXA@ULXP*(I%V^8F~9{lCeTP zrRHjFxmBGUpOLoKC4}cLb8b@Eq=9W#(%shXgTTkkQEX$cTHb8Q#RuB^@u(!ahD8Bg zh590stEeSf`MEYT3SShCzM0QNRfSH%9t<|o`w zHUY@5p=_)nzvQfM!+!O!c?f@WTkranxqj{vJaW7Qvad!XHSf~K&7auegL4KG(a%ky zj!@7az!|pH?c)*8w^9AHj3X8ZOaIw-HG6|%&R##$>rV(R+*^=I?H|2hXK35I@YMJu zRDK1#5|Pg~z5=P%9E@_u*)=?_(M}uZ+~Uy8_0u$cx2qo7gL=2y7c&BB@)hNJR`#?? zoo7TZI@2qU5cV+{?Qo-?pKta>x;DQ@p7>V{^vZtMZMh>GaTZIp#_1y}gr;N{!N6At zU0^I~O-Ie%sAX=`8H~Luh-Flm4#BB5Ag(=7o#>~)=d=aouLZed#do%DtGE1+%TTf! zxmD(36i6e>*hndOH`t%wi;@Yap(m_s&)G^k%OO!QBa-!zUoeTcv3hn?(M9S7X2DVjo(q-;A1Keq9h!ijHC ztpZsKbLOBvCn5>nEU1z$hQf#72m<$61s6eBTC`>jV;QkzuX&pnz-JH^&&nL31Fj^h(XA_eKTuKI0TuKgcxRrxaa%{8Q$-!O{h=`od-U5taRN*C?64&;fQp*J$;xg<$;paN7&zS-t<^r})H{VSjuA z1H1Y|O8)r<6Zv;Hn4%5P)70rNgIdPY*jm=o*~Qe()ak!m>QZ%`Klfl5AIngXQ7|bo z^reUD9BkyGiZHeT328ETXhM<*c9vc`hlEW;)_PLpd+v`ME|%V%DdGV}C0 zNdaZEw*}nplg7>e7Q>oAp{c;Y|bmWIAzVc}@Ec_vgs@|ui#n9_^5C)+!(XqdLO z6ewXp5#|nUm@IGU4eG@q`JRux}f0@ z zb2;vKGFn1aqfr?Q9+KoP%`r#q`RLJoP&qurcfX$WRFEp4DO=1?nD``W$Tq8bBG`Ir z!Fejj!nC^}MBX8Zsg}uYl_SVpJNZ@?RR%Z6B@6I;t4d_JmXed(nLFEB?hk0q=%A0$Jb9Xe(Z2zc@C_2(mr7~ zkUQFm^Y~rv!rmivOWey0;&W+Hb-a=mshU+WQ$|S|f78))td9x`{YKyu%Lcu(OVz+! zDAPpbDJ06I*he-;{mfBRMdkl2+(+T+@vzq;5+u?2bsLSnFt+@q#q={V^kd?@8*e5b)v4f62H1uvPBi6Q46o9R?8nV~2sg5s!WZ!IaaNo#JL${VAXMdDLTJ%N zTA0Sc2^VbdkI)M2YP;z!WmI4ykkb3*2T-)Q3wAZD;(G*ecl6gJ)x|MUG9iZ|*@{ZZ zMh+#*Nu0xTnu#fi^2{S0IlV(De>vY{tem^sc^%lSY;6DJBK4_UR35(%SeT!7?QBox zv2#biUj61Qy>dsiT&LuT-DTlf=v=R;G5i?>J^g|Qz%sVr70*z8otdQ?IguC=B+JosZ5i*Om5$Sc#|o5!4c{zFuN&@rJ3W}93qGaMi1nPPH4N?2@Tx5xg@qsxAy+I||ZiIHyUYSo%&D1NcVjJBdMU2dc62P*;Jn zTj0q4QBR)RNKws}4L`v|S8arKvD|ufR5O0;thGifDNrA25{08HAq7c39~x$B_dV_g z&A>!7oeqR41tij=xM0UiQ}Jyy<>^lW-?FT(?0d9gD{W88L)o03|cT2X}oa3oF$uF6DuYcjPICd zGH}ds2T*UfKR-rd_NQW2ClZIfL=}q8q*h3b!QV$Hv32kkmyfZIA4)^T$h!~2^oRVY zF+<|xd%hS`V?t;+sDW|?UHHV|ZZV-Ip)exf z778VBk4;cew8dW;*YafjvvKfsJ?w^_e9smq_qP|1Vzam;)DYrmNYx+7pGXT5(U#Ao6=MoE?hhD*pk=+O{S2dYUjTvezwxkU5Vc)HuutU zJN#CdTYfU}=v)DoDt%o5^;YR5j2YJ^pmL-GHUBilb*7QlVFYV|pd1yIzSiIa9T$~2 zX2LSW%g~orLw)Orr_?v>fKb5)A$-o~r%@1YhZMnZ+kD=Ia&`b~oBtbyZ(F8U;lReb zxa+(Tf`TKhdtsEvub?it&o=eNa((XR%(+{5Tj7LNXlBz06Pi!GMcYY-?c-~+2>B~z zx1VsAn{ANY9Toi@+05G%#|I$p($z=*VEmAh(+%lHuq&=rV4vkP?3+Wbg0aFUsz)ai z{2@fEInBYs2jrR^-(dJ&;-@U*kuz~|07%m**L!h*HH6fsjPc+^LY}-I^-j?bpL}|bV=B6(c<=BBK!aeMkzKbX1 zxesPvXzW3s%Ol^!#~*o&wV*f05R! zD0}{{wmNpxR|Z*%et0hxsq^dmuylf+ySVz+$N(k%1c@Zo~hX*O(c#gF5KnV zoRcPAB_|gWrg3=E75+kV+3S?3pgqN_%ekt(MOA99(^y11Gc>9NR9qzjUUBO6xbw1W z0^`&8?TVcSXM|diy0+wsi%LxD{X!AvSUF;ms5osb{)vZDx^e#Mxrr+{^R>2gK0}h* z2=!`Ykka_+v5S&|IV56x=5EgvwZUar9BBs#R$M}y^8hLzT};Z*gH=0RV8)eY5AC8R zxt}$XEM%`xKGRLeV!Gaxn^ZJ0s#ZEHAYIxktI)YpMRY#hfn~E>+c>U$cNDXt<|RaB zaSCB7R9<&hw119nLH)KJyA4(;r~7l8%#tI1D?+df`U9ev{pjIvPVEK54f5?nw=-4Y-&Ej?V9)=>7b{!luhiup0VC^UJLD9A$S)d zJ`V9_*^yDUxZ0g!n6A8ky15=~2I4dWHRvUE-*BHbweWZuTe6k8VQS+mM zJ%ZQ^uWpN?DDE&y70W0?D)(7Dq{Rrl|0D|`gSFwEYSS>a?efd8*+edzRC!}(s9$oT zW)5%x28wrLK2rVZYJYOkYPW2dGy50RPe%Dc_7yMWJ*E2_NsV7%G0hq4c6q4tKo4*| z)%$?1irvPjn>{jZP7a@q>M5G`uZWX0nhEV)syq787nZbD?NQd$J@H>CUkanr??|c) zN9ZOR2*-<+_DpJH@K{kRHRExm6@%fzDm$^N_a}qC^oM6ox|YIn^4V7>@1`v8-uQ`NBy_EE!o9Ij;Xfv__hNV+rmBr~j98equQWw@*mi{_((5Y@Djk8THX@$YCi8$oTUIu9HqRiS`@!2P z+NUTfnY9Zx=b z&MO5EQ;a=V35;@-3ioFiuc{Y&l$m@_L#KF0>TsK2cB9(5XMRSK&`_=K+G)1DRNmIP z(49NTK{&~>_mVk@tP3VzncT9g~nqX77;-ckIL8zL>kaZ?8`%5GAZCl%ksN6gLk z3A2tmEAJh=w%}FP)->=e(!-o_1r4bkM5%ApxcTQ zyg9Y|4Ypq4kMjP=E1H5J)vVY_=Z8x>-x$DlCwT!5ekZvBp7N4M12c?0`%y&W1I@>g z2%ga4b~(ts8TR=R)fT(ehy%*PEVvxWeZT$5x6VbR-{s`6ONIB1~ASmVWc|%XKmcAqxX8wU_ zs5*b&9a_w(FEpu$b4wv{9(Fq5EmYEPVk{MS>;O)om%+6etpfSL?o~!fX&rHbB9Fcc zrZ4eOHRB3SvWV}R9Bf+^6`GD}{8(Jw)XR#jNP}IUu5JWfTzw-SW^EGWL@QDJaNd6zC@&7d4Hj4 zAxTvd8$kbiee~Z4-u`zf#NUOE)pS(; zczYjdSSm&-+0Qf;l5nd9MM0Fxa4>i%VvditQp@bka@y6{{zBcBQ()6UL;TId zQ8BVcI`S=T!dSl8Dlf+@sDKmX+eSJt_lPFKjNKkoxb)=1WI)FdeM@XWpI8b)BGA{~ zFQhoZA2!jw{Tc@F*1?hLA@H)(Uo>)ZPkoDX=uo*GtfGV$h^x5_W708C39?|D0#L>5 ztqatJHcLT;g;1q0O?tWk(}0RpbSbsmgjlHTDZ()OmisxxTQDmyA_2b9Ozu(6T}4Tv zJmUoleD0!TPv8Rc4#CIKLToOB%@oNV_ZpU?qiQUV%BQl0IhF9amXJ)daoJGA4%K0= z_#Jq|h$c)xqHrlh6{s>t9Z*c5*5;hUNGgi&lftJ=6=1!E zk?EA?D~2mLi4S4xRjC@b$ZI~I z)VCesl1juK<+%39s^N4f8*Ioc+z#GqdNv9B?)b&38>iHb)%JH{aFw$_qHNSCET39D z!n+xX;Z*Om(lT|w_wV^ss~m8;NJeELB*g^VF=LCjHF4WXs#`|3phaiVB zn^iu)9as8no}tmK^TWE%20~TO7IF|{V=@E~UOwiu4808Teg#sRiu-h1s>zXb6ujgo zx8`qe)^4TG(5H1YZW=F#yW{ zKWikUV(lsXSIfWC68{-!E0fET;x0v5r*2cGHp)^KFLkn%X=or{?kFM=xwPmFmqUR#kVRUb}I;AR)+asjI zLtQ3dj4M+{g9_I(c4&_u9kzWNT58adl#MsFf&jeupuo@>v{`O{9*Hvr;y zFPeZ-J%tTO`#$73Wo~3BbtjAi+D*yQ{zlrr2|R~;y)&{6^Z6&7r=h_0M?KOKky-Pzi2SzjzHG$AW* z_K^UGL9CCVR1q4KQ_J-s-mqQed%iveg3*%qK)^8KT0Po}BFNWAG`RR;t$^}vph~v= zn72A5myPS{F%$!jf0zP~f5;rxr*044r-Pcu11d$2I0*r7l*pLkY92JJ2?q4@AQ-YGSJ?W=JZ%bv(^RhgRRZ^2HK*`QR zNhi|t-Pf|t+_5f6L8gcG*a$XW+jpO6ar84}hFw6bxb2_arZ%%aIXIB0H6_;DhSGUu z%9Wf5pEX%SiSx{8g!ZCv`xHikvin(EEL`9h!~(5SCY+%r(geQ#woG+!LBauQ?&sOW z2|2md%pcqA)JOs&#i-8ac{i-c+m=@&_8VTr*p{;r@3h4v#MV-AM|teT7}%@S_AWlD z$F2O}q$ab@5FT3~6*Sg4OX2MM-Sz%U&txW%FIJIe&yRQH2ay7Yr`=u;#T$Hz%LGKT z*+K(!g!zIka>6Lm2he zM(^dRy(K@`ukD^RDuO2@{lcwLGqU0Wo{Sq{=HrHt%@+vIG`%*Mxx>>Maz_Yx%RDdR z-s5tKt7x_e6HC% zfJ=b)4qG~6I}H+)h3MxDqu3jj_yM?yaZ%letg#vP$$runraPwiA*0)gObE0uNg*Yu z^fUR5I0oIDsQQ&4P??JU?2a)X2EDHd)JOZ*GyQDj>87|f)v&?!_T0vPZDnxqxWT&_ zKp+g2?&e!`rkr(VzBS=oY&5!nxg!azCBYfOu~oBtp!&Hey&e4ci?Nn(%A2l;J5mF- z){6a|l;4g;uXSxal`_J`i4#M9vwEsSX|9=X>{|^@{Rk^Z56T;wADS(G> zfun9w`&n2EzpCe-@e;_i>=#15Q3hKU`GN1&<^q42uqAd?{DMO+9!t(2fNa{uf`V5R z8I*l_otw>alH+|d8J};^3*iy)X1TeT*k6kpRdbfoQM(rx<{GwE?zcNK zgOi8jmi`v#I=tgBfvPvb2k$u(FUHX5Mfh2hKAubL9V_r$xcP$Dfk$7H<_imHTj&MT z<0ZQ!_TZD;j_{SgNt!&NvsNZ6a(fDc zlg(?9YtT>{*_Nb})qTZ^$jk^E=U9|iCqUO%ZB6(4^w<8RnC-=31qTD$`(tkYbFM-A z?@$CIpq(wy4rp%b^e@PU;Qz3bFwjo!Z%zM>ZfKYr;{SQu1i#LF?$LxYTASS_J7Oix zgkwqqD@b0~h=N$&bS0L>VS-!6{LSc0{#2frs`zqg$Rbdfie#1)Vg1*&^8GAE^#d|${i=OaU>Cv4_`62Popcv6D8Bvpzyr!a&!^ zlHAC0x0A=3vvnBS*=h#!GAIOk7n<#I9o(&X=osBDxi;?iGx4n@9Y`~TKZAgnIl9-!i#)G`bKpo|L2{YMLfons7 zM`>Dz4SheG5Hv@hvyk-2P#$e|$)4N2oGMgiyk_sfUT^^*I3yM!oI^S9WbtJ-+X*Fy z!4c8;#0{39$m|j0qAmII%H+ZF&=|zDyzP^WXW?`Pdmn5$Dm zoP1`mbDNT}X@wrnPy&A?BCp;xB+zos3lmMp6M{~*Ip(k0y=%>5=z=S>wM ztn9`s1i7)Z6ch8T3jzlYj{h=1A%H#u9FqOaHxwF;tIg-F17@YWNNcoKnlRnju|_V+ zR^vQ>Ki$zAJ;d(*Ys`1ieqsLZ}sfjedMN$KJpY6xTt>`<| z!Pu$EG=Cm4{pvh&DDxNd#2<~k-ziz;EMbsv*K z-F;N=H%HKax$`Cuvx3n7Zf#SK8)xrbq%O;#%sp7SmAX2!De9i3_;qp7AJZ%2>gRNG zQ^>QcC!SmrSw*hg<-)vAShI^3b> zMQujKh=@{L3DUqfOf&%Xib+_O& z!&=~)3rxGw*l@2S-vOC?=8?9@h`bWBpYp$WN@x1%W5bmJv`4V1~fP10veQLfB3 z4LRc{S4cHBgBt-(O`8)q7k=!khT>0Wy-P_#lLP?L?rA5%LIS+ym*KHe%k<|1Twf_; zQFnjw{cAaT-o_A+)_ZkXk-=n-aL7kla(isXg<3fWd78e8p5uHO70I6qUUnP2Qo~T(2hW@)Xrj;!J?E z{{{T*yOc$=WAR*A!-`e*2Wol`&0ntU)%;(szFT3VrI)^Zn`XC2m;#foYN^7V)u*S< zsG4SoFa%#j<1YAL42CtpfZ1O;>%>tKqx#EYB*DT_VQ;i`_ggT8cQ7r?=@ zM&BNpq3X63zHGE2Oz+Xueswtbc`$~L(ud$ExatjIOE0WZ2?j7tbf&<7MJRlI*UOh` zM8? zB2vO&l2s>eGw)yo zL;zm?+F(}p;ju#7Ng`%S68_ni&YoQ)kHV6sPfo1t=)?r0^(A4KbiNWy1comGDir4i}DdD~$2vhg?^SF};Me@_!xl zHO452y}pw&7o!{MW51S?f4Dq~oox9)?x!DcbLv7IWc044mjpO@{c!t$XU52GBA_?N zO|sbSvHk`E8lKWtgJ7kAQ1GIdE3u^A?aDr((i+R&7~_y}yBR$yRb@S>RRU1}dS_xy z%#KF4?E7|=QxC|rA%b#xp1rKRl9(9oh8w3iliYXozrEec(fn`%UP(v&&oDx-!vFMa zF$r1x@1Kbn%Kvw)#J}`x|6ix|uc~6x7F`tMgG#4k-NDvQb=}sEbI~>?p$k<)P2vK% zZ3T-|b*5wViX(?B1GWJlq~jkQq^*4O)t?45VNVi)ZK}VL;Wp)e%>SKTI3VB;(he;V zWGg0F&!x}v%1s?^Uw=+Q3L~-Cw+*xOb)ei4Gp-@W9%&jK-!ZXw%85xzF1}Dw8@V(5EF-GLza{BIi5$5uSo!M8q%Uu}GJ68N2ywa#1$LA$Flt7=@SpI>xsD1)b4 zu08>1mSXW{$Bay>ZGrAig}SS9m`XaIbqfj z^yV$%kXH@;rXE*Zu2CBt&OYz1f6D*egUMO1rlaVo(5#DlN2i%t5&1#87<$MWPi!Ni zG{Moa=&a@MzUGVADs2(Mg`h`P=_x*R;~=)1vG)h_vgeuNd)YicjBz&_&I4PKM_{8C zO)?}*rpDs|TrnWLYzB|d5BP4YO<~j2v&)xCp!CCHg9NMnDTIc%nW>I-O)E1`_ zGX8s&o6o%F!@tdIGX5uhyx4!y@BTYqm7@u8LzhPRzyj#{p)|9mf7vA@Y9>WM$qhq! zhX^(&SfW9tAT9h%8~8O6XO%eah37B7IG#I+x)X+1D>%qBr383c39*nX`gr20$h;15E8tcwz~=u;ebGC zn%kC=kf9<8KrYU^t?4KViS)D{TwZn-0wv|vY?OR>D6*I{@+-Xlii<8z3ohGLQcc>& zwLX*?t@!MX9%@M1mGjWsRfiMkAFL2kAEnM8*C~}^H%8yV*E%AL$MN7?BT2a&rC$a0 z@og$%kN7kjKAc>s&~|5o-_nF+^89C0{KlnkpMqx51+cTCWr4lUeoyYaHG!z_7C*4s ziZIo~tYFDSkv=+^$HMq}&GuMdODhG?OD1?%U45Ro?}zcn^Pp9+v3=T81BY#r)48m2 z!5z7{;NwzB117Ec3Cznem{#m!kMC2Rw|v zl5)94>ma15o^P~leK93POD(tJL`0E}Ij_fYln;ScLAotJ+XoT-b~WyR(&8>4)U_EA zZO>iWl+yWLRgff6;ApgR!^nG6sgK|q$8wc9^p=lvld5yi8(41ye;CVkk}4Cfl020^ zfl2~gA3!IJh7n~=Z z1+`q#p`%NMh?wnDs`n~L%7qkz2*=k`R@YMqp)76o76S6={>`ib@yUna&}Iad{sUu#lf-_$ZO8VuJWX%VF+})^Ie1FfGQvY6 z;0WB_<7e>iri~86GUix!EU-{XSGY$f3tfw7zA+TvMVSX&^eIg8=J9U?95gc_hlX3_iKa)c(e+7RsLQ1Y6Z{YM2bhu4T@fIdJ2adXFQv+9*q>TRimnbnvkJkEWkj#HhV*VdZ z5(_uC&%l?BiT%IJeEmlz$-h*R{J%y2#U%Mea_VbfemJqQUt1g%k2l)z8Bi1^0Pbf-IY+#kVN6{#Q{*gigw^&(8VA`zha_3K|UF{ zXi4PLfx53Pa^%Hi{s?tbT<5$^wH@ak3LkG}N#}Ju1$@DmRDd;%T`u#kCO+QvpfhCN zUM}|z_BS#L+Vn0YcIwOe;|;$>SKjgh^4uUHzE%b)VqV{>9c|JnmbK2tKkZOqUTc7a zFt4>hUm=O_%}|9fdcs}Yz7Y2^-nyvvR)5_Hi>G@|C#I)(~Xw?&P zOCK0t7qxZmtl0McRo#c1;37-wGnqJ^+q`Fv+8tGmX1+*yvbFG zj>O-}PVsku+R?L_{c7K}l>Pj8qK@?x?zv+Szja~8yFtQr|Ae@ZIRkCQWMr5?Q7KwsFfY&3Mv6*9mby#oT{LD~kWJJ3 zK#X4wWz<*Td&}Yb=k)mX0 z7%re-rxY%rWak(zpqELmRCl7L$kA$^<380!@AZ4wukOLI68@OY5`^nc&>yER^~#+z zyns-naWKMNTk8R*h>5AzT;7V^7Vjk7I9#cUH92T5X!Hf)Of>;Hyte$Z6tP!uL^_h*EJxbNv4ed0&oqkR@`oNVU4 z-(>exfqYC0I1yA)v5xk4H>z;sacvY}REi=^cS#GTn;7`b*wOtEJJzEtEZ;)B;%+7% z;Vj~mIaSEsqhPGX(2FzEDJ|_xboc?W)U*z0i#|&>hG5Cn zMpSYbT*f*Xbke%?Rs1F&X};N#q12dly6A_d zu|59MEjE&?e==0>;94HPsjPC~{A3@{#mds3tdm1WRUuX8zx!rryw4%FOBZwHWq8%t zKEHwvnX0&`89sj+;%#n4fTU=sx669$zV@Rh>iG0#BX-zB?aHfgAF4#NrTV_L!o|;T z@_wJsR3X|2vf;AJS*brT2jbKnPoEU?!eKHIS1EVp@esC=gIp7dTT}4w*EEm*{VAD7Eor)vy3YA`Fs1L5s*6;5{Y z9Ns-^c6M<=9+9qa`HuBiakD@k`D1`&zIbxQuxYig002c@p@RDtKaWajZ1vm;Di2eH zI)_3?xxl*nd4^?S_?HKYoaOfsZMDZHViNZZ*{*O-~dLn#09>R@VWkq;v7R+cj^yOhv; zJkyOCgTC|xISvL}kE{5{I^G5oVdjA)CAP)rwOrAKp^gGJ_LV1H$EI>AJ$(^1IlFQ3 zWhc>L_QRn+aiMEZyS_2#1}?NhuQ@bdujfMyl=*^KS)hTsn5oUoWxZ#=Yt~J)=tvc> zCmm~@oNFC_Dlqx!UPJrI{OX*EiNgSqwa=RCNH^GT>53=Wp8E(*j$8&cgrKgXEq6v&`{qL$^ySpyH%#!VVQR;)WD@2ULcP@zJJYmf3oIM`06%bHb%8y88~NllLvn^ERS>*W z*DA%yKxJ0C&2afVGi)9hXyImKW)t2YvXoA^f!R7=$$AI(5*#J63u_;_cJA{~qiSR8 zqv+FwI(q2?HS+S zDAhO00pu2Xgn!M*g@&9_*G}?_koHY|U(n_RZxBt{{oxENcF-Wx=vw7(`VN&}Ne=IH z2AKe&ZzNiIvjbK;8Z*6%f*8@DX%T8cHQsGV3QChrA?(TUttkPVkAakp(Eh>B zXN}&6K2jxNZ>7^=x&qg$E(E62TQVVU$>OmvC|ViAFG(MWI<*xA!dV}~-^E#L5>wFkGuK4Q zLfSnWF~h+Y*bW?S^nKCcZbX%IUCV@dpKscCrj%uoItcvz2>iXsDE?MXF*x<fomc;23^#M}+CazqkwMAO$P zZG`;U6V)dn>iY`9ITu+PZlWokLR9=#rf<=r_7%=z`6v7)jB@`Vi;Kikwzq$)stlo| zz9w8bL{b%oh5#5mt*LuWYy4XLY}Vi&ljbU`=IW31aE^x;>r3>J1Xb&OkJ`k;_TlpS zq}!UU@$%)xS@wcL=q=J0!?E!Sf2a@9s-Qjf8B93ClAS}i8ux%-U{JVKNkIaoTTICs zBeRtCaHT2qo`=~%1~=WBFASZf${aKTFc_IX`Mb5~y+ilsY3=z#>kM}BN|U>jSib|s z4aPUX17J`w@dq;oW~q6XXx?bYHsbi5kH7!dyzvyU3rPNKqZ@Jm-8}q%-vIxMccpIP zgeHpeO^*hex(TyUGqjncNd!1QWSugU-pDbK9s4;D57296v=8KW^}_iZCEPzyHaqaV zN^FsB@Y9+@G%;jy;v(y5>+)i=8m)7V_o_Z?zD(Zxuus{WL-UCE^ZdCE!qP^5W ze5htzQ@=UjE_qnEWXJU9NcUE2!`A29IPb%YNZ1xhEtKGuE)p`YWItEnS?+SR+wv)F zw=SP$#Fby1v37GYeO%a|lAF9c%Xm84bvw`&>r?UA@Sycd;@AG%&w)6Z)9ai~bYck% z*lt+T6Ii7u79EJL-&8uoxK+5+={6q+hfMMT26fJq##$-p&BUsO`J+lH2N0Xk(ysJk z{4Qa6=>b3xJ8cULBs)ZOI%yfmSI;^%s@6(T3lo6Vpb`U?D_cYA@EK+=}nrn(D%y*TYeK8XU}1$SR>0GcnaVu+|&d- z$|JS2t`By%>5Lg?@=uj1Oq#hT;t;)$pYu9UOZh&a-!m$AL$csGB`r~o5s`~wk{Bx1 zepaA9_V}_Uh8TqDC8` zHjU?@`iZ^|`3(RiBmhM)NcKq*an^Sfnmoz6q|ueF^7j(lSO)Vs48imm5;o^_e}35v zXAuA6hN0*&aEg7-$DjZ0e4Oq-al2=*MeIn>q0H>cAIu~3en&;6k6#fi9^7@pZZ`hx8 zaFw7)_CZqjJI8pSyJyJR_ktL}*D`N8j&6(|=6xGcLGsLac*OYVIxENrdN?7{0AX71 zX~&~&(9K4M)85%-d$2|c- zY46M1kJZIYAiysj-AP5w=(4>GMAo4mjhvd5aFyzX5Y|N6Og6{D`_9dkPKj{G~9YUH?(Ejwu!;rO^|VzU<&0F31?u zRc=SiN^k??)CFZo%b7iCMSw+&u6RO*)EqHZ5U$qFPNME7wSIWjpY#_)56udw$EOoKk7^eX1nV(Chx4i%ogV5v^7_(Ox@8iARUIdQgz$(gjCwyv>D zX9%5G8Q5~aPrrN{s&&1`x!A0BUoNQ8(%iI0M6$-kx0plPOh(RJ;@%C?o^LGKi%Cmn zN8vDHD6M3Mq%xBEE7$K=b+kQl%)LtI!DQxEvIT-RRL)WRpo-zwp7E*N_X zYH_Io!uf~#2yJxZ2%Lt%$ksDg+N@Y%=$nT67p+ z0SkQ?Y6Yk>V=u+=6HE7@&xKqQej5t~_I#a96LOE*b?ECVP3>a-3I9LFE&ZaVogMvT zFNLR_r#Q`yXR@qJE1HJaMCR;eQYE^;v$EX&@+5huWk-*@0PYw z+3(sVvcRh%v*^W#sxLQ8VoH*0AzcTumXp?U%Wkv!TVojnzKWnRj4X>PpW-Bf+xiJ& zVL(F2LHqN?ma8b#vYIbd4JJ=#QTd_0poVhV2!EW6a-CO!qNk-40+!`VzyFnU8Iq^d zBXarNz)`UC(p)JZ-99RB=T(x6qPT;<4`a>Stqnm1&c~TDjN~bHr8Bfw&Eds$c!QnQ=b+MA5RQtl--Y}5bm6(g)wg;uH27*M1xmW-F6{GM(R~ol_r@obD z+V-(1VAh2=&>vJj*_zXoI2WA;-IzXU=gSPdg&oY&NuWkx{zg=189=hxuDc-BpsDNj zNt3r&FWKC3A+NsMWY6KBTvU`einB=5f}q-Ri^e|02AG)`i*<~2nQ!6FCQIp}SFDqh zkJFVeyYkj}hMc&9e%-pNWZUniJMMT4|H0l;3_Ek^6wx4Ue?~AD9ug3yikhuyiVf$1 z+FV3EJjGRVWiaE{r5Yt$ugS6#8*4EQnRnC%Ox5dedmLWyuFuYUGSEVpN~&l!U57yk zA`Ai;_`9BYjWd)}gkJ3$)on+AKe%ZfcnTUFy2oz!pO1S6bJI26PK*3doE7{^P&#k# zb1-Cx+!W{Nc47+HCM&K~JZ5)<8i;f8;Y{i@gMy0>l&f6v)VzwYKZ{n^s;{@Y@Pf2U z|3!_Uq-n0vm5do0Tx-JX9mOt*E8|PZ)Rkzon|o*J!qsQhJ{BFyz!N=(@ly<5X) zl5cD7h`_|md=(|;HDrWDC>*wh5#H5hZ48Hd4%e64#Lqkuwir!FNKA!%GaCEl5l1K2 zfHC#9v78sZZ)FQ81Z1RN))(M6vhk)-UacAd@c(NI=zNC5;O|4s z0xJ1#!|K8tWh>%NUBGmAK*U&Sss*n8t~o>s864Zd#H}1MoP;c380@U~B{LI9SRPgd z#2aBhAR{ zT#mR(u>II_jyL&oCv&IWo)_!nrCP!U{{Z~g{F>bTUS2zw&ryZccu#>iaAy1*9ik*17|@X!(k%6k0O7WKfey-1AlC+lrp%mIEy zWTjgZrLXZ(xx)(Y72+_nxvrah0p#O(u(n)7A`q{TkEAIOfAuk?d^~Oq2PvKdzrwJ) zP;AF6iCr7I4eC9v!_@BKg4L@1_7yb}^TGQpqlnu86+{Fj4 zb}=*6(zZB!4Wd9V5Y#@^9k5${q>ddZJy0BGtuMwukMI!A=L z@GBTcTn(A8$DddNF^8(au1_AXO^Ct+ZS{1G9fqJo4~Z6 zeNUU6W*9=-71G%8(mg1-&uJP`hiZPFf)Ihysp_3q<#+Y|A}T=5 z*&h_kr4KyYVew*gD2XSXHoNryVbj{94xKi-@14MSLXidP7*UTPDuy}IzVr1>4f2jC zXCg@2ioWjga-H2v3cWVfA?e8t;Qk#B&~LcM?S#HQoNJc#h1wq9z>A|}84>d3>gu+h z@3+2Vd=Z&VLT01O-MTiTRT_rY9)5DWW`)?2kQpLp3ouq6LjDaKs)tM5K6J(1R%GmB z#ugwmguHy)or&jY{tm-3Fu=(~=&+nK&N%wa((rODPWFTQ?gW432CB&J9?TZNS!+Y= zV)r4f2foL)Lkt)0EwQ&fMA&uL>KCX6Kh4042eol=a#PX<3IhD$2?%=O^j^sMi$e)9 zMADu&#VSYo9`z$%m2?Dc1_XJ7LlPvi=|y`6La zXwmlAHSU%C8m})fgbuA_ka9E8TM$eMJ&h}e&z5SLOnR+_j03k`!H7eZ#fC*ZZwNT~ zwsodz-d--YCAgz&`N5*iVr0>G^BcFqaOTQ-D^2Pl`RBF*Ic`g%y>t)(5p=i!hw7kg zEjvrI#;<8kZn
    -
    - ${accordionSessions} -
    + ${accordionSessions}
    From e408f6aa622cd7de3b11587b234d454cb7088b04 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 7 Feb 2018 19:49:57 +0200 Subject: [PATCH 137/166] More test prints --- .../system/database/databases/sql/SQLiteDB.java | 8 +++++--- .../com/djrapitops/plan/utilities/MiscUtils.java | 14 ++++++++++---- .../plan/system/database/databases/SQLiteTest.java | 11 +++++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java index d32b42b106..2467321aa6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java @@ -56,7 +56,7 @@ public Connection getNewConnection(String dbName) throws SQLException { String dbFilePath = new File(PlanPlugin.getInstance().getDataFolder(), dbName + ".db").getAbsolutePath(); Connection newConnection = getConnectionFor(dbFilePath); - Log.debug("SQLite: Opened a new Connection"); + Log.debug("SQLite " + dbName + ": Opened a new Connection"); newConnection.setAutoCommit(false); return newConnection; } @@ -130,8 +130,10 @@ public Connection getConnection() throws SQLException { @Override public void close() { stopConnectionPingTask(); - Log.debug("SQLite: Closed Connection"); - MiscUtils.close(connection); + if (connection != null) { + Log.debug("SQLite " + dbName + ": Closed Connection"); + MiscUtils.close(connection); + } super.close(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index 5a788d2785..722d24b52b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -116,8 +116,11 @@ public static void close(Closeable... close) { if (c != null) { try { c.close(); - } catch (IOException ignored) { - /* Ignored */ + } catch (IOException e) { + if (Settings.DEV_MODE.isTrue()) { + Log.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:"); + Log.toLog(MiscUtils.class, e); + } } } } @@ -128,8 +131,11 @@ public static void close(AutoCloseable... close) { if (c != null) { try { c.close(); - } catch (Exception ignored) { - /* Ignored */ + } catch (Exception e) { + if (Settings.DEV_MODE.isTrue()) { + Log.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:"); + Log.toLog(MiscUtils.class, e); + } } } } diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java index d7c56c6607..faf64d3b30 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java @@ -61,10 +61,12 @@ public class SQLiteTest { @BeforeClass public static void setUpClass() throws Exception { + System.out.println("--- Test Class Setup ---"); db = new SQLiteDB(); SystemMockUtil.setUp(temporaryFolder.getRoot()) .enableConfigSystem() .enableDatabaseSystem(db) + .enableServerInfoSystem() .enableServerInfoSystem(); StaticHolder.saveInstance(SQLDB.class, Plan.class); StaticHolder.saveInstance(SQLiteTest.class, Plan.class); @@ -74,6 +76,7 @@ public static void setUpClass() throws Exception { Settings.DEV_MODE.setTemporaryValue(true); db.init(); + System.out.println("--- Class Setup Complete ---\n"); } @AfterClass @@ -86,12 +89,12 @@ public static void tearDownClass() { @Before public void setUp() throws DBException, SQLException { - System.out.println("-- Clearing Test Database --"); + System.out.println("\n-- Clearing Test Database --"); db.remove().everything(); ServerTable serverTable = db.getServerTable(); serverTable.saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20)); assertEquals(ServerInfo.getServerUUID(), TestConstants.SERVER_UUID); - System.out.println("-- Clear Complete --"); + System.out.println("-- Clear Complete --\n"); } @Test @@ -755,8 +758,10 @@ public void testKillTableGetKillsOfServer() throws SQLException, DBInitException @Test public void testBackupAndRestore() throws SQLException, DBInitException { + System.out.println("- Creating Backup Database -"); SQLiteDB backup = new SQLiteDB("debug-backup" + MiscUtils.getTime()); backup.init(); + System.out.println("- Backup Database Created -"); saveAllData(db); @@ -852,9 +857,11 @@ public void testSaveSessionsWorldTimes() throws SQLException { public void testRegisterProcessorRegisterException() throws SQLException { assertFalse(db.getUsersTable().isRegistered(playerUUID)); assertFalse(db.getUserInfoTable().isRegistered(playerUUID)); + System.out.println("\n- Running RegisterProcessors -"); for (int i = 0; i < 200; i++) { new RegisterProcessor(playerUUID, 500L, 1000L, "name", 4).process(); } + System.out.println("- RegisterProcessors Run -\n"); assertTrue(db.getUsersTable().isRegistered(playerUUID)); assertTrue(db.getUserInfoTable().isRegistered(playerUUID)); } From b2f0e8c8c89d72e136b158a922fe7fcca6a91368 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 7 Feb 2018 20:16:51 +0200 Subject: [PATCH 138/166] Fixed Database tests that require DBSystem database override --- .../com/djrapitops/plan/system/database/DBSystem.java | 3 ++- .../plan/system/database/databases/sql/tables/Table.java | 4 +--- .../plan/system/database/databases/SQLiteTest.java | 8 ++++++-- Plan/src/test/java/utilities/mocks/SystemMockUtil.java | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java index c727274dfd..d0bf54c718 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/DBSystem.java @@ -85,7 +85,8 @@ public static Database getActiveDatabaseByName(String dbName) throws DBInitExcep throw new DBInitException(Locale.get(Msg.ENABLE_FAIL_WRONG_DB) + " " + dbName); } - public void setActiveDatabase(Database db) { + public void setActiveDatabase(Database db) throws DBException { + this.db.close(); this.db = db; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java index b68e7b9718..c9b96cc16b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/Table.java @@ -165,18 +165,16 @@ public SQLDB getDb() { } protected boolean execute(ExecStatement statement) throws SQLException { - boolean updatedSomething; Connection connection = null; try { connection = getConnection(); try (PreparedStatement preparedStatement = connection.prepareStatement(statement.getSql())) { - updatedSomething = statement.execute(preparedStatement); + return statement.execute(preparedStatement); } } finally { commit(connection); db.returnToPool(connection); } - return updatedSomething; } protected void executeBatch(ExecStatement statement) throws SQLException { diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java index faf64d3b30..54ac0a3549 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java @@ -66,7 +66,6 @@ public static void setUpClass() throws Exception { SystemMockUtil.setUp(temporaryFolder.getRoot()) .enableConfigSystem() .enableDatabaseSystem(db) - .enableServerInfoSystem() .enableServerInfoSystem(); StaticHolder.saveInstance(SQLDB.class, Plan.class); StaticHolder.saveInstance(SQLiteTest.class, Plan.class); @@ -89,6 +88,7 @@ public static void tearDownClass() { @Before public void setUp() throws DBException, SQLException { + assertEquals(db, Database.getActive()); System.out.println("\n-- Clearing Test Database --"); db.remove().everything(); ServerTable serverTable = db.getServerTable(); @@ -858,8 +858,12 @@ public void testRegisterProcessorRegisterException() throws SQLException { assertFalse(db.getUsersTable().isRegistered(playerUUID)); assertFalse(db.getUserInfoTable().isRegistered(playerUUID)); System.out.println("\n- Running RegisterProcessors -"); + List processors = new ArrayList<>(); for (int i = 0; i < 200; i++) { - new RegisterProcessor(playerUUID, 500L, 1000L, "name", 4).process(); + processors.add(new RegisterProcessor(playerUUID, 500L, 1000L, "name", 4)); + } + for (RegisterProcessor processor : processors) { + processor.process(); } System.out.println("- RegisterProcessors Run -\n"); assertTrue(db.getUsersTable().isRegistered(playerUUID)); diff --git a/Plan/src/test/java/utilities/mocks/SystemMockUtil.java b/Plan/src/test/java/utilities/mocks/SystemMockUtil.java index 4c35157630..7f32a0004c 100644 --- a/Plan/src/test/java/utilities/mocks/SystemMockUtil.java +++ b/Plan/src/test/java/utilities/mocks/SystemMockUtil.java @@ -6,6 +6,7 @@ import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.system.BukkitSystem; import com.djrapitops.plan.system.database.DBSystem; import com.djrapitops.plan.system.database.databases.sql.SQLDB; @@ -65,10 +66,10 @@ public SystemMockUtil enableServerInfoSystem() throws EnableException { return this; } - public SystemMockUtil enableDatabaseSystem(SQLDB db) throws EnableException { + public SystemMockUtil enableDatabaseSystem(SQLDB db) throws EnableException, DBException { DBSystem dbSystem = bukkitSystem.getDatabaseSystem(); - dbSystem.setActiveDatabase(db); dbSystem.enable(); + dbSystem.setActiveDatabase(db); return this; } } \ No newline at end of file From c218627ede84912e456f9d9d3a1d411f0feb58ba Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 8 Feb 2018 12:04:46 +0200 Subject: [PATCH 139/166] Fixed /plan m setup command not working & added more error cases to it --- .../commands/manage/ManageSetupCommand.java | 13 +++--- .../system/info/connection/ConnectionIn.java | 46 ++++++++++++------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index 4c8e58c9a3..d58fb3d848 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -1,9 +1,6 @@ package com.djrapitops.plan.command.commands.manage; -import com.djrapitops.plan.api.exceptions.connection.BadRequestException; -import com.djrapitops.plan.api.exceptions.connection.ForbiddenException; -import com.djrapitops.plan.api.exceptions.connection.UnauthorizedServerException; -import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; @@ -47,7 +44,7 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { return true; } String address = args[0].toLowerCase(); - if (!address.startsWith("http")) { + if (!address.startsWith("http") || address.endsWith("://")) { sender.sendMessage("§cMake sure you're using the full address (Starts with http:// or https://) - Check Bungee enable log for the full address."); return true; } @@ -67,9 +64,13 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { sender.sendMessage("§eConnection succeeded, but Receiving server was a Bukkit server. Use Bungee address instead."); } catch (UnauthorizedServerException e) { sender.sendMessage("§eConnection succeeded, but Receiving server didn't authorize this server. Contact Discord for support"); + } catch (ConnectionFailException e) { + sender.sendMessage("§eConnection failed: " + e.getMessage()); + } catch (InternalErrorException e) { + sender.sendMessage("§eConnection succeeded. " + e.getMessage() + ", check possible ErrorLog on receiving server's debug page."); } catch (WebException e) { Log.toLog(this.getClass(), e); - sender.sendMessage("§cConnection to Bungee WebServer failed: More info on console"); + sender.sendMessage("§cConnection to Bungee WebServer failed: More info in the error log."); } return true; } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java index a2ee8dd711..065520cb3e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionIn.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.system.info.request.SetupRequest; import com.djrapitops.plan.system.webserver.Request; import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; import java.io.ByteArrayOutputStream; @@ -26,32 +27,43 @@ public class ConnectionIn { public ConnectionIn(Request httpRequest, InfoRequest infoRequest) throws WebException { Verify.nullCheck(httpRequest, infoRequest); - Map variables = readVariables(httpRequest); - checkAuthentication(variables); - - this.variables = variables; + this.variables = readVariables(httpRequest); this.infoRequest = infoRequest; + + checkAuthentication(); } - private void checkAuthentication(Map variables) throws WebException { - String sender = variables.get("sender"); - Verify.nullCheck(sender, () -> new BadRequestException("Sender ('sender') variable not supplied in the request.")); - UUID serverUUID = UUID.fromString(sender); + private void checkAuthentication() throws WebException { + UUID serverUUID = getServerUUID(); try { - if (!Database.getActive().check().isServerInDatabase(serverUUID)) { - if (infoRequest instanceof SetupRequest) { - if (ConnectionSystem.isSetupAllowed()) { - return; - } else { - throw new ForbiddenException("Setup not enabled on this server, use commands to enable."); - } - } - throw new UnauthorizedServerException(sender + " (Sender) was not found from database"); + if (Database.getActive().check().isServerInDatabase(serverUUID)) { + return; } } catch (DBException e) { throw new TransferDatabaseException(e); } + + Log.debug("ConnectionIn: " + infoRequest.getClass().getSimpleName()); + + if (infoRequest instanceof SetupRequest) { + if (!ConnectionSystem.isSetupAllowed()) { + throw new ForbiddenException("Setup not enabled on this server, use commands to enable."); + } + } else { + throw new UnauthorizedServerException(serverUUID + " (Sender) was not found from database"); + } + } + + private UUID getServerUUID() throws BadRequestException { + String sender = variables.get("sender"); + Verify.nullCheck(sender, () -> new BadRequestException("Sender ('sender') variable not supplied in the request.")); + + try { + return UUID.fromString(sender); + } catch (IllegalArgumentException e) { + throw new BadRequestException("Sender ('sender') was not a valid UUID: " + e.getMessage()); + } } private Map readVariables(Request request) throws WebException { From 05d8d9fb48da82b3aeb9a11f46994153f69210b8 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 9 Feb 2018 13:32:15 +0200 Subject: [PATCH 140/166] Ensured that InfoSystem methods are all called from Async threads. --- .../plan/command/commands/AnalyzeCommand.java | 16 ++--- .../commands/manage/ManageSetupCommand.java | 47 +++++++----- .../plan/system/info/InfoSystem.java | 72 +++++++++++++++---- .../info/connection/ConnectionSystem.java | 7 ++ 4 files changed, 100 insertions(+), 42 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 4cc36e658c..dad3e17464 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -83,19 +83,13 @@ private void sendLink(Server server, ISender sender) { sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); } - private void sendWebUserNotificationIfNecessary(ISender sender) { + private void sendWebUserNotificationIfNecessary(ISender sender) throws DBException { if (WebServerSystem.getInstance().getWebServer().isAuthRequired() && CommandUtils.isPlayer(sender)) { - Processor.queue(() -> { - try { - boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName()); - if (!senderHasWebUser) { - sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); - } - } catch (Exception e) { - Log.toLog(this.getClass(), e); - } - }); + boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName()); + if (!senderHasWebUser) { + sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); + } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java index d58fb3d848..f1622ff9be 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageSetupCommand.java @@ -2,6 +2,7 @@ import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.settings.Permissions; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.locale.Locale; @@ -51,27 +52,35 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { if (address.endsWith("/")) { address = address.substring(0, address.length() - 1); } - try { - Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.set(false); - Settings.BUNGEE_COPY_CONFIG.set(true); - InfoSystem.getInstance().requestSetUp(address); + requestSetup(sender, address); - sender.sendMessage("§aConnection successful, Plan may restart in a few seconds.."); - } catch (ForbiddenException e) { - sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it."); - } catch (BadRequestException e) { - sender.sendMessage("§eConnection succeeded, but Receiving server was a Bukkit server. Use Bungee address instead."); - } catch (UnauthorizedServerException e) { - sender.sendMessage("§eConnection succeeded, but Receiving server didn't authorize this server. Contact Discord for support"); - } catch (ConnectionFailException e) { - sender.sendMessage("§eConnection failed: " + e.getMessage()); - } catch (InternalErrorException e) { - sender.sendMessage("§eConnection succeeded. " + e.getMessage() + ", check possible ErrorLog on receiving server's debug page."); - } catch (WebException e) { - Log.toLog(this.getClass(), e); - sender.sendMessage("§cConnection to Bungee WebServer failed: More info in the error log."); - } return true; } + + private void requestSetup(ISender sender, String address) { + Processor.queue(() -> { + try { + Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.set(false); + Settings.BUNGEE_COPY_CONFIG.set(true); + + InfoSystem.getInstance().requestSetUp(address); + + sender.sendMessage("§aConnection successful, Plan may restart in a few seconds.."); + } catch (ForbiddenException e) { + sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it."); + } catch (BadRequestException e) { + sender.sendMessage("§eConnection succeeded, but Receiving server was a Bukkit server. Use Bungee address instead."); + } catch (UnauthorizedServerException e) { + sender.sendMessage("§eConnection succeeded, but Receiving server didn't authorize this server. Contact Discord for support"); + } catch (ConnectionFailException e) { + sender.sendMessage("§eConnection failed: " + e.getMessage()); + } catch (InternalErrorException e) { + sender.sendMessage("§eConnection succeeded. " + e.getMessage() + ", check possible ErrorLog on receiving server's debug page."); + } catch (WebException e) { + Log.toLog(this.getClass(), e); + sender.sendMessage("§cConnection to Bungee WebServer failed: More info in the error log."); + } + }); + } } 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 7ff6cc598f..19c39860ad 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 @@ -18,6 +18,7 @@ import com.djrapitops.plan.system.info.request.SendDBSettingsRequest; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; @@ -30,6 +31,8 @@ *

    * Subclasses should decide how InfoRequests are run locally if necessary. * + * Everything should be called from an Async thread. + * * @author Rsl1122 */ public abstract class InfoSystem implements SubSystem { @@ -46,6 +49,14 @@ public static InfoSystem getInstance() { return infoSystem; } + /** + * Refreshes Player page. + *

    + * No calls from non-async thread found on 09.02.2018 + * + * @param player UUID of the player. + * @throws WebException If fails. + */ public void generateAndCachePlayerPage(UUID player) throws WebException { GenerateInspectPageRequest infoRequest = new GenerateInspectPageRequest(player); try { @@ -55,10 +66,14 @@ public void generateAndCachePlayerPage(UUID player) throws WebException { } } - public void generateAnalysisPageOfThisServer() throws WebException { - generateAnalysisPage(ServerInfo.getServerUUID()); - } - + /** + * Refreshes Analysis page. + * + * No calls from non-async thread found on 09.02.2018 + * + * @param serverUUID UUID of the server to analyze + * @throws WebException If fails. + */ public void generateAnalysisPage(UUID serverUUID) throws WebException { GenerateAnalysisPageRequest request = new GenerateAnalysisPageRequest(serverUUID); if (ServerInfo.getServerUUID().equals(serverUUID)) { @@ -68,6 +83,14 @@ public void generateAnalysisPage(UUID serverUUID) throws WebException { } } + /** + * Send an InfoRequest to another server or run locally if necessary. + * + * No calls from non-async thread found on 09.02.2018 + * + * @param infoRequest InfoRequest to send or run. + * @throws WebException If fails. + */ public void sendRequest(InfoRequest infoRequest) throws WebException { try { if (!connectionSystem.isServerAvailable()) { @@ -85,19 +108,29 @@ public void sendRequest(InfoRequest infoRequest) throws WebException { } } + /** + * Run the InfoRequest locally. + * + * No calls from non-async thread found on 09.02.2018 + * + * @param infoRequest InfoRequest to run. + * @throws WebException If fails. + */ public abstract void runLocally(InfoRequest infoRequest) throws WebException; @Override public void enable() throws EnableException { connectionSystem.enable(); - try { - updateNetworkPage(); - } catch (NoServersException e) { - /* Ignored */ - } catch (WebException e) { - // TODO Exception handling - Log.toLog(this.getClass(), e); - } + Processor.queue(() -> { + try { + updateNetworkPage(); + } catch (NoServersException e) { + /* Ignored */ + } catch (WebException e) { + // TODO Exception handling + Log.toLog(this.getClass(), e); + } + }); } @Override @@ -109,8 +142,23 @@ public ConnectionSystem getConnectionSystem() { return connectionSystem; } + /** + * Updates Network page. + * + * No calls from non-async thread found on 09.02.2018 + * + * @throws WebException If fails. + */ public abstract void updateNetworkPage() throws WebException; + /** + * Requests Set up from Bungee. + * + * No calls from non-async thread found on 09.02.2018 + * + * @param addressToRequestServer Address of Bungee server. + * @throws WebException If fails. + */ public void requestSetUp(String addressToRequestServer) throws WebException { if (Check.isBungeeAvailable()) { throw new BadRequestException("Method not available on Bungee."); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index 4e868b8440..f874af6f7a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.system.info.connection; +import com.djrapitops.plan.Plan; import com.djrapitops.plan.api.exceptions.connection.NoServersException; import com.djrapitops.plan.api.exceptions.connection.UnsupportedTransferDatabaseException; import com.djrapitops.plan.api.exceptions.connection.WebException; @@ -14,6 +15,7 @@ import com.djrapitops.plan.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.utilities.Verify; @@ -93,6 +95,11 @@ public ConnectionLog getConnectionLog() { protected Optional getServerWherePlayerIsOnline(GenerateInspectPageRequest infoRequest) { UUID playerUUID = infoRequest.getPlayerUUID(); + + if (Check.isBukkitAvailable() && Plan.getInstance().getServer().getPlayer(playerUUID) != null) { + return Optional.of(ServerInfo.getServerUUID()); + } + try { return Database.getActive().transfer().getServerPlayerIsOnlineOn(playerUUID); } catch (UnsupportedTransferDatabaseException e) { From 1d107ce5688d79f8e03d976228ec3e9134670230 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 10:53:33 +0200 Subject: [PATCH 141/166] Fixed HTTPS InfoRequest issues (#521) --- .../system/info/connection/InfoRequestPageHandler.java | 4 ++-- .../djrapitops/plan/system/webserver/ResponseHandler.java | 7 ++++--- .../com/djrapitops/plan/system/webserver/WebServer.java | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java index c9131d09c2..e08bd39de9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/InfoRequestPageHandler.java @@ -66,8 +66,8 @@ private int getResponseCodeFor(WebException e) { return 500; } else if (e instanceof ConnectionFailException) { return -1; + } else { + return 0; } - - return 0; } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java index 59ac55879e..e945c3931c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/ResponseHandler.java @@ -94,7 +94,9 @@ private Response getResponse(Request request, String targetString, List if (targetString.endsWith(".js")) { return ResponseCache.loadResponse(PageId.JS.of(targetString), () -> new JavaScriptResponse(targetString)); } - if (webServer.isAuthRequired()) { + boolean isNotInfoRequest = target.isEmpty() || !target.get(0).equals("info"); + boolean isAuthRequired = webServer.isAuthRequired() && isNotInfoRequest; + if (isAuthRequired) { authentication = request.getAuth(); if (!authentication.isPresent()) { if (webServer.isUsingHTTPS()) { @@ -108,9 +110,8 @@ private Response getResponse(Request request, String targetString, List if (pageHandler == null) { return DefaultResponses.NOT_FOUND.get(); } else { - boolean noAuthRequired = !webServer.isAuthRequired(); boolean isAuthorized = authentication.isPresent() && pageHandler.isAuthorized(authentication.get(), target); - if (noAuthRequired || isAuthorized) { + if (!isAuthRequired || isAuthorized) { return pageHandler.getResponse(request, target); } return forbiddenResponse(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java index 2cb3bb406c..237ac722f8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/WebServer.java @@ -189,8 +189,8 @@ public boolean isEnabled() { * Shuts down the server - Async thread is closed with shutdown boolean. */ public void stop() { - Log.info(Locale.get(Msg.DISABLE_WEBSERVER).toString()); if (server != null) { + Log.info(Locale.get(Msg.DISABLE_WEBSERVER).toString()); server.stop(0); } enabled = false; From 46e15a1196e1e685e45b7a864b59ff41ffde4b6a Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 10:53:50 +0200 Subject: [PATCH 142/166] Added more info to BasicAuth fail message --- .../plan/api/exceptions/WebUserAuthException.java | 5 +++++ .../plan/system/webserver/auth/BasicAuthentication.java | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java index 8ec1fc1eb0..06fbd90a49 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/exceptions/WebUserAuthException.java @@ -21,6 +21,11 @@ public WebUserAuthException(FailReason failReason) { this.failReason = failReason; } + public WebUserAuthException(FailReason failReason, String additionalInfo) { + super(failReason.getReason() + ": " + additionalInfo); + this.failReason = failReason; + } + public WebUserAuthException(Throwable cause) { super(FailReason.ERROR.getReason(), cause); this.failReason = FailReason.ERROR; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java index a40b58f0b3..5e3471a91c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/auth/BasicAuthentication.java @@ -14,7 +14,7 @@ /** * Authentication handling for Basic Auth. - * + *

    * Basic access authentication (Wikipedia): * https://en.wikipedia.org/wiki/Basic_access_authentication * @@ -44,14 +44,14 @@ public WebUser getWebUser() throws WebUserAuthException { Database database = Database.getActive(); if (!database.check().doesWebUserExists(user)) { - throw new WebUserAuthException(FailReason.USER_DOES_NOT_EXIST); + throw new WebUserAuthException(FailReason.USER_DOES_NOT_EXIST, user); } WebUser webUser = database.fetch().getWebUser(user); boolean correctPass = PassEncryptUtil.verifyPassword(passwordRaw, webUser.getSaltedPassHash()); if (!correctPass) { - throw new WebUserAuthException(FailReason.USER_PASS_MISMATCH); + throw new WebUserAuthException(FailReason.USER_PASS_MISMATCH, user); } return webUser; } catch (DBException | PassEncryptException e) { From 9e91ee61f821d1ac3203fa6579c21939d8320654 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 11:00:53 +0200 Subject: [PATCH 143/166] Prevented some issues with tasks running on reload --- .../main/java/com/djrapitops/plan/Plan.java | 4 ---- .../java/com/djrapitops/plan/PlanBungee.java | 2 -- .../djrapitops/plan/system/PlanSystem.java | 2 +- .../system/processing/ProcessingQueue.java | 24 +++---------------- .../plan/system/tasks/BukkitTaskSystem.java | 7 ++++++ 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 07282e9945..6dbac642f9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -30,11 +30,9 @@ import com.djrapitops.plugin.BukkitPlugin; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.systems.TaskCenter; import com.djrapitops.plugin.api.utility.log.DebugLog; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.settings.ColorScheme; -import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; /** @@ -101,8 +99,6 @@ public void onDisable() { Log.info(Locale.get(Msg.DISABLED).toString()); Benchmark.pluginDisabled(Plan.class); DebugLog.pluginDisabled(Plan.class); - TaskCenter.cancelAllKnownTasks(Plan.class); - Bukkit.getScheduler().cancelTasks(this); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 98d90d31f1..5cb9a593ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -12,7 +12,6 @@ import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.systems.TaskCenter; import com.djrapitops.plugin.api.utility.log.DebugLog; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.settings.ColorScheme; @@ -54,7 +53,6 @@ public void onDisable() { Log.info(Locale.get(Msg.DISABLED).toString()); Benchmark.pluginDisabled(PlanBungee.class); DebugLog.pluginDisabled(PlanBungee.class); - TaskCenter.cancelAllKnownTasks(PlanBungee.class); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index c911274900..8ffdb12676 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -99,6 +99,7 @@ public void enable() throws EnableException { @Override public void disable() { SubSystem[] systems = new SubSystem[]{ + taskSystem, hookHandler, cacheSystem, listenerSystem, @@ -107,7 +108,6 @@ public void disable() { webServerSystem, infoSystem, serverInfo, - taskSystem, configSystem, fileSystem, versionCheckSystem diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index 970ce3094e..f36bedbbd6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -1,16 +1,12 @@ package com.djrapitops.plan.system.processing; -import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.utilities.queue.Consumer; import com.djrapitops.plan.utilities.queue.Queue; import com.djrapitops.plan.utilities.queue.Setup; import com.djrapitops.plugin.api.Benchmark; -import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; -import com.djrapitops.plugin.task.AbsRunnable; -import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.utilities.Verify; import java.util.List; @@ -45,22 +41,9 @@ public void enable() { @Override public void disable() { List processors = stopAndReturnLeftovers(); - if (PlanPlugin.getInstance().isReloading()) { - RunnableFactory.createNew("Re-Add processors", new AbsRunnable() { - @Override - public void run() { - ProcessingQueue que = ProcessingQueue.getInstance(); - for (Processor processor : processors) { - que.queue(processor); - } - cancel(); - } - }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L); - } else { - Log.info("Processing unprocessed processors. (" + processors.size() + ")"); - for (Processor processor : processors) { - processor.process(); - } + Log.info("Processing unprocessed processors. (" + processors.size() + ")"); + for (Processor processor : processors) { + processor.process(); } } @@ -78,7 +61,6 @@ public void queue(Processor processor) { class ProcessConsumer extends Consumer { - ProcessConsumer(BlockingQueue q) { super(q, "ProcessQueueConsumer"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index 4ced6e0cf4..6ba7b1a8bf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -15,6 +15,7 @@ import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.ITask; import com.djrapitops.plugin.task.RunnableFactory; +import org.bukkit.Bukkit; /** * TaskSystem responsible for registering tasks for Bukkit. @@ -42,6 +43,12 @@ public void enable() { registerTasks(); } + @Override + public void disable() { + super.disable(); + Bukkit.getScheduler().cancelTasks(plugin); + } + private void registerTasks() { Benchmark.start("Task Registration"); From ec1ea81f93dc7c701c81270328f01e0c93a8d8d7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 11:15:37 +0200 Subject: [PATCH 144/166] Analysis DB Closed Exception on reload no longer logged. --- .../info/request/GenerateAnalysisPageRequest.java | 8 +++++++- .../plan/system/processing/ProcessingQueue.java | 6 +++++- .../test/java/utilities/mocks/BukkitMockUtil.java | 13 ++++++++++--- Plan/src/test/java/utilities/mocks/MockUtil.java | 4 ++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java index cc2240a353..8790c3a187 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateAnalysisPageRequest.java @@ -7,6 +7,7 @@ import com.djrapitops.plan.api.exceptions.connection.BadRequestException; import com.djrapitops.plan.api.exceptions.connection.InternalErrorException; import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.data.calculation.AnalysisData; import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.database.databases.Database; @@ -83,8 +84,13 @@ private String analyseAndGetHtml() throws InternalErrorException { AnalysisData analysisData = Analysis.runAnalysisFor(serverUUID, db, dataCache); return new AnalysisPage(analysisData).toHtml(); + } catch (DBException e) { + if (!e.getCause().getMessage().contains("Connection is closed")) { + Log.toLog(this.getClass(), e); + } + throw new InternalErrorException("Analysis failed due to exception", e); } catch (Exception e) { - Log.toLog(Analysis.class, e); + Log.toLog(this.getClass(), e); throw new InternalErrorException("Analysis failed due to exception", e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java index f36bedbbd6..f46b32f120 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/processing/ProcessingQueue.java @@ -43,7 +43,11 @@ public void disable() { List processors = stopAndReturnLeftovers(); Log.info("Processing unprocessed processors. (" + processors.size() + ")"); for (Processor processor : processors) { - processor.process(); + try { + processor.process(); + } catch (Exception e) { + Log.toLog(this.getClass(), e); + } } } diff --git a/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java index 021f91825f..3c447181f5 100644 --- a/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java +++ b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java @@ -8,9 +8,11 @@ import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.ThreadRunnable; +import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.plugin.InvalidDescriptionException; import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.scheduler.BukkitScheduler; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import utilities.Teardown; @@ -22,8 +24,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; -import static org.mockito.Mockito.doCallRealMethod; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; /** * Mocking Utility for Bukkit version of Plan. @@ -54,6 +55,7 @@ private BukkitMockUtil mockPlugin() { doCallRealMethod().when(planMock).getVersion(); doCallRealMethod().when(planMock).getColorScheme(); + return this; } @@ -65,7 +67,7 @@ public BukkitMockUtil withDataFolder(File tempFolder) { public BukkitMockUtil withLogging() { doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString()); TestLogger testLogger = new TestLogger(); - when(planMock.getLogger()).thenReturn(testLogger); + doReturn(testLogger).when(planMock).getLogger(); return this; } @@ -98,6 +100,11 @@ public BukkitMockUtil withServer() { FakeConsoleCmdSender sender = new FakeConsoleCmdSender(); when(serverMock.getConsoleSender()).thenReturn(sender); + BukkitScheduler bukkitScheduler = Mockito.mock(BukkitScheduler.class); + doReturn(bukkitScheduler).when(serverMock).getScheduler(); + + Bukkit.setServer(serverMock); + when(planMock.getServer()).thenReturn(serverMock); return this; } diff --git a/Plan/src/test/java/utilities/mocks/MockUtil.java b/Plan/src/test/java/utilities/mocks/MockUtil.java index 0994a5cd95..964b6c85b7 100644 --- a/Plan/src/test/java/utilities/mocks/MockUtil.java +++ b/Plan/src/test/java/utilities/mocks/MockUtil.java @@ -9,7 +9,7 @@ import java.io.File; import java.io.FileInputStream; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.doReturn; /** * Abstract MockUtil for methods that can be used for both Bungee and Bukkit. @@ -30,7 +30,7 @@ private void withPluginFile(String fileName) throws Exception { } try { File file = getFile("/" + fileName); - when(planMock.getResource(fileName)).thenReturn(new FileInputStream(file)); + doReturn(new FileInputStream(file)).when(planMock).getResource(fileName); } catch (NullPointerException e) { System.out.println("File is missing! " + fileName); } From 723e8f7391d43f87898917e5cebcf6ab04b5d8bf Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 11:18:52 +0200 Subject: [PATCH 145/166] Fixed some test issues --- .../test/java/com/djrapitops/plan/system/BukkitSystemTest.java | 2 +- Plan/src/test/java/utilities/mocks/BukkitMockUtil.java | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java index bfa359cba0..14ae63ef58 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/BukkitSystemTest.java @@ -19,7 +19,7 @@ * * @author Rsl1122 */ -@RunWith(MockitoJUnitRunner.class) +@RunWith(MockitoJUnitRunner.Silent.class) public class BukkitSystemTest { @ClassRule diff --git a/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java index 3c447181f5..55e82dbab2 100644 --- a/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java +++ b/Plan/src/test/java/utilities/mocks/BukkitMockUtil.java @@ -8,7 +8,6 @@ import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.ThreadRunnable; -import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.plugin.InvalidDescriptionException; import org.bukkit.plugin.PluginDescriptionFile; @@ -103,8 +102,6 @@ public BukkitMockUtil withServer() { BukkitScheduler bukkitScheduler = Mockito.mock(BukkitScheduler.class); doReturn(bukkitScheduler).when(serverMock).getScheduler(); - Bukkit.setServer(serverMock); - when(planMock.getServer()).thenReturn(serverMock); return this; } From 8de5012ae53458fd641bf5a03f9900b2841e01ec Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 11:26:13 +0200 Subject: [PATCH 146/166] Fixed "Last Seen" displaying Jan 1 1970 XX:59 for new registers --- Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java index 13dc4b855f..ba2b84f4db 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/PlayerProfile.java @@ -177,8 +177,7 @@ public long getLastSeen(UUID serverUUID) { } public long getLastSeen(Stream s) { - OptionalLong max = s.mapToLong(Session::getSessionEnd) - .max(); + OptionalLong max = s.mapToLong(session -> Math.max(session.getSessionStart(), session.getSessionEnd())).max(); if (max.isPresent()) { return max.getAsLong(); } From b18396192ff32800c49d50a0304f733bb0e2b8f1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 11:31:50 +0200 Subject: [PATCH 147/166] Replaced Session End with Session Length on Session Accordion Headers --- .../html/structure/ServerAccordionCreator.java | 2 +- .../structure/SessionTabStructureCreator.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java index 5ef0d9ad1a..ef48fa76f6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/ServerAccordionCreator.java @@ -19,7 +19,7 @@ import java.util.UUID; /** - * HTML utility class for creating a Session Accordion. + * HTML utility class for creating a Server Accordion. * * @author Rsl1122 */ diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java index 44aa4c7117..cc53771a7d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/SessionTabStructureCreator.java @@ -51,7 +51,7 @@ public static String[] createStructure(Map>> ses maxSessions = 50; } - boolean appendWorldPerc = Settings.APPEND_WORLD_PERC.isTrue(); + boolean appendWorldPercentage = Settings.APPEND_WORLD_PERC.isTrue(); for (Session session : allSessions) { if (i >= maxSessions) { @@ -72,12 +72,12 @@ public static String[] createStructure(Map>> ses String name = DataCache.getInstance().getName(uuid); String link = PlanAPI.getInstance().getPlayerInspectPageLink(name); - String dotSeparated2 = appendWorldPerc + String info = appendWorldPercentage ? HtmlStructure.separateWithDots(sessionStart, SessionsTableCreator.getLongestWorldPlayed(session)) : sessionStart; - String dotSeparated = appendName ? - HtmlStructure.separateWithDots(name, dotSeparated2) : - HtmlStructure.separateWithDots(serverName, dotSeparated2); + String nameAndInfo = appendName ? + HtmlStructure.separateWithDots(name, info) : + HtmlStructure.separateWithDots(serverName, info); String htmlID = "" + session.getSessionStart() + sessionID + i; @@ -93,11 +93,12 @@ public static String[] createStructure(Map>> ses html.append("

    ") .append(""); // Closes panel heading From 54b6817e4f8d4164f4094a287af40c102bf7b9c3 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 11:39:51 +0200 Subject: [PATCH 148/166] Fixed Timezone issues (#519) --- Plan/src/main/resources/web/js/charts/punchCard.js | 3 +++ Plan/src/main/resources/web/network.html | 7 +++---- Plan/src/main/resources/web/player.html | 7 +++---- Plan/src/main/resources/web/server.html | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Plan/src/main/resources/web/js/charts/punchCard.js b/Plan/src/main/resources/web/js/charts/punchCard.js index c65f7b7881..359986e3d4 100644 --- a/Plan/src/main/resources/web/js/charts/punchCard.js +++ b/Plan/src/main/resources/web/js/charts/punchCard.js @@ -12,6 +12,9 @@ function punchCard(id, punchcardSeries) { }, tickInterval: 3600000 }, + time: { + timezoneOffset: 0 + }, yAxis: { categories: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'] }, diff --git a/Plan/src/main/resources/web/network.html b/Plan/src/main/resources/web/network.html index 4ecb666b87..e3ee8d3e23 100644 --- a/Plan/src/main/resources/web/network.html +++ b/Plan/src/main/resources/web/network.html @@ -317,11 +317,10 @@

    Network Online Activity

    @@ -1085,9 +1121,9 @@

    Command Usage

    tpsChart('tpsGraph', tpsSeries, playersOnlineSeries); resourceChart('resourceGraph', cpuSeries, ramSeries, playersOnlineSeries); worldChart('worldGraph', entitySeries, chunkSeries, playersOnlineSeries); - worldMap('worldMap', '${worldMapColLow}', '${worldMapColHigh}', mapSeries); + worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, mapSeries); punchCard('punchCard', punchcardSeries); - healthGauge('healthGauge', [${healthIndex}]); + healthGauge('healthGauge', [v.data.healthIndex]); ${sessionTabGraphViewFunctions} /**/ From be58984d64c8f06fed66294c4d984abc0a809717 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 20:03:13 +0200 Subject: [PATCH 150/166] Prepared to add multiple axis to performance charts by cleaning series. --- Plan/src/main/resources/web/server.html | 209 +++++++++++++----------- 1 file changed, 113 insertions(+), 96 deletions(-) diff --git a/Plan/src/main/resources/web/server.html b/Plan/src/main/resources/web/server.html index 5a92e1166f..c5e6817512 100644 --- a/Plan/src/main/resources/web/server.html +++ b/Plan/src/main/resources/web/server.html @@ -878,7 +878,9 @@

    Geolocations

    Command Usage

    -

    Used Commands: ${commandCount} Unique: ${commandUniqueCount}

    +

    Used + Commands: ${commandCount} + Unique: ${commandUniqueCount}

    @@ -997,94 +999,109 @@

    Command Usage

    }; // HighCharts Series - var playersOnlineSeries = { - name: 'Players Online', - data: v.data.playersOnline, - type: 'areaspline', - color: v.colors.playersOnline, - tooltip: { - valueDecimals: 0 - } - }; - var tpsSeries = { - name: 'TPS', - data: v.data.tps, - type: 'spline', - zones: [{ - value: v.values.tpsMed, - color: v.colors.tpsLow - }, { - value: v.values.tpsHigh, - color: v.colors.tpsMed - }, { - value: 30, - color: v.colors.tpsHigh - }], - tooltip: { - valueDecimals: 2 - } - }; - var cpuSeries = { - name: 'CPU Usage (%)', - data: v.data.cpu, - type: 'spline', - color: v.colors.cpu, - tooltip: { - valueDecimals: 2 - } - }; - var ramSeries = { - name: 'RAM Usage (MB)', - data: v.data.ram, - type: 'spline', - color: v.colors.ram, - tooltip: { - valueDecimals: 0 - } - }; - var entitySeries = { - name: 'Loaded Entities', - data: v.data.entities, - type: 'spline', - color: v.colors.entities, - tooltip: { - valueDecimals: 0 - } - }; - var chunkSeries = { - name: 'Loaded Chunks', - data: v.data.chunks, - type: 'spline', - color: v.colors.chunks, + var s = { + name: { + playersOnline: 'Players Online', + tps: 'TPS', + cpu: 'CPU Usage (%)', + ram: 'RAM Usage (MB)', + entities: 'Loaded Entities', + chunks: 'Loaded Chunks' + }, tooltip: { - valueDecimals: 0 + twoDecimals: { + valueDecimals: 2 + }, + zeroDecimals: { + valueDecimals: 0 + } + }, + type: { + areaSpline: 'areaspline', + spline: 'spline' + }, + zones: { + tps: [{ + value: v.values.tpsMed, + color: v.colors.tpsLow + }, { + value: v.values.tpsHigh, + color: v.colors.tpsMed + }, { + value: 30, + color: v.colors.tpsHigh + }] } }; - var activitySeries = { - name: 'Players', - colorByPoint: true, - data: v.data.activityPie - }; - var worldSeries = { - name: 'World Playtime', - colorByPoint: true, - data: v.data.worldPie - }; - var gmSeries = v.data.worldPieDrillDown; - var mapSeries = { - name: 'Players', - type: 'map', - mapData: Highcharts.maps['custom/world'], - data: v.data.geolocations, - joinBy: ['iso-a3', 'code'] - }; - var punchcardSeries = { - name: 'Relative Activity', - color: v.colors.punchCard, - data: v.data.punchCard + var series = { + playersOnline: { + name: s.name.playersOnline, + type: s.type.areaSpline, + tooltip: s.tooltip.zeroDecimals, + data: v.data.playersOnline, + color: v.colors.playersOnline + }, + tps: { + name: s.name.tps, + type: s.type.spline, + zones: s.zones.tps, + tooltip: s.tooltip.twoDecimals, + data: v.data.tps + }, + cpu: { + name: s.name.cpu, + type: s.type.spline, + tooltip: s.tooltip.twoDecimals, + data: v.data.cpu, + color: v.colors.cpu + }, + ram: { + name: s.name.ram, + type: s.type.spline, + tooltip: s.tooltip.zeroDecimals, + data: v.data.ram, + color: v.colors.ram + }, + entities: { + name: s.name.entities, + type: s.type.spline, + tooltip: s.tooltip.zeroDecimals, + data: v.data.entities, + color: v.colors.entities + }, + chunks: { + name: s.name.chunks, + type: s.type.spline, + tooltip: s.tooltip.zeroDecimals, + data: v.data.chunks, + colors: v.colors.chunks + }, + activityPie: { + name: 'Players', + colorByPoint: true, + data: v.data.activityPie + }, + worldPie: { + name: 'World Playtime', + colorByPoint: true, + data: v.data.worldPie + }, + worldPieDrillDown: v.data.worldPieDrillDown, + geolocations: { + name: 'Players', + type: 'map', + mapData: Highcharts.maps['custom/world'], + data: v.data.geolocations, + joinBy: ['iso-a3', 'code'] + }, + punchCard: { + name: 'Relative Activity', + color: v.colors.punchCard, + data: v.data.punchCard + }, + activityStack: v.data.activityStack, + activityStackCategories: v.data.activityStackCategories }; - var activityStackSeries = v.data.activityStack; - var activityCategories = v.data.activityStackCategories @@ -1112,17 +1129,17 @@

    Command Usage

    openFunc(slideIndex)(); // Chart draw scripts - activityPie('activityPie', activitySeries); - stackChart('activityStackGraph', activityCategories, activityStackSeries, 'Players'); - worldPie('worldPie', worldSeries, gmSeries); - playersChart('playerChartDay', playersOnlineSeries, 3); - playersChart('playerChartMonth', playersOnlineSeries, 2); - performanceChart('performanceGraph', playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries); - tpsChart('tpsGraph', tpsSeries, playersOnlineSeries); - resourceChart('resourceGraph', cpuSeries, ramSeries, playersOnlineSeries); - worldChart('worldGraph', entitySeries, chunkSeries, playersOnlineSeries); - worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, mapSeries); - punchCard('punchCard', punchcardSeries); + activityPie('activityPie', series.activityPie); + stackChart('activityStackGraph', series.activityStackCategories, series.activityStack, 'Players'); + worldPie('worldPie', series.worldPie, series.worldPieDrillDown); + playersChart('playerChartDay', series.playersOnline, 3); + playersChart('playerChartMonth', series.playersOnline, 2); + performanceChart('performanceGraph', series.playersOnline, series.tps, series.cpu, series.ram, series.entities, series.chunks); + tpsChart('tpsGraph', series.tps, series.playersOnline); + resourceChart('resourceGraph', series.cpu, series.ram, series.playersOnline); + worldChart('worldGraph', series.entities, series.chunks, series.playersOnline); + worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, series.geolocations); + punchCard('punchCard', series.punchCard); healthGauge('healthGauge', [v.data.healthIndex]); ${sessionTabGraphViewFunctions} From 431d758212bfd937e8e01e1afbc5beb3d1929a8c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 20:25:19 +0200 Subject: [PATCH 151/166] Added yAxis to all Performance tab charts (#492) Far more readable. --- .../web/js/charts/performanceGraph.js | 98 +++++++++++++------ .../resources/web/js/charts/resourceGraph.js | 94 +++++++++++------- .../main/resources/web/js/charts/tpsGraph.js | 88 ++++++++++------- .../resources/web/js/charts/worldGraph.js | 94 +++++++++++------- Plan/src/main/resources/web/server.html | 87 +++++++++++----- 5 files changed, 296 insertions(+), 165 deletions(-) diff --git a/Plan/src/main/resources/web/js/charts/performanceGraph.js b/Plan/src/main/resources/web/js/charts/performanceGraph.js index 8796a31f90..4914a317a0 100644 --- a/Plan/src/main/resources/web/js/charts/performanceGraph.js +++ b/Plan/src/main/resources/web/js/charts/performanceGraph.js @@ -1,32 +1,72 @@ function performanceChart(id, playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries) { - Highcharts.stockChart(id, { - rangeSelector: { - selected: 2, - buttons: [{ - type: 'hour', - count: 12, - text: '12h' - },{ - type: 'hour', - count: 24, - text: '24h' - },{ - type: 'day', - count: 7, - text: '7d' - },{ - type: 'month', - count: 1, - text: '30d' - },{ - type: 'all', - text: 'All' - }] - }, - title: {text: ''}, - legend: { - enabled: true, + Highcharts.stockChart(id, { + rangeSelector: { + selected: 2, + buttons: [{ + type: 'hour', + count: 12, + text: '12h' + }, { + type: 'hour', + count: 24, + text: '24h' + }, { + type: 'day', + count: 7, + text: '7d' + }, { + type: 'month', + count: 1, + text: '30d' + }, { + type: 'all', + text: 'All' + }] }, - series: [playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries] - }); + title: {text: ''}, + yAxis: [{ + labels: { + formatter: function () { + return this.value + ' P'; + } + } + }, { + opposite: true, + labels: { + formatter: function () { + return this.value + ' TPS'; + } + } + }, { + opposite: true, + labels: { + formatter: function () { + return this.value + '%'; + } + } + }, { + labels: { + formatter: function () { + return this.value + ' MB'; + } + } + }, { + opposite: true, + labels: { + formatter: function () { + return this.value + ' E'; + } + } + }, { + labels: { + formatter: function () { + return this.value + ' C'; + } + } + }], + legend: { + enabled: true + }, + series: [playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries] + }); } \ No newline at end of file diff --git a/Plan/src/main/resources/web/js/charts/resourceGraph.js b/Plan/src/main/resources/web/js/charts/resourceGraph.js index b949c9ec75..6d411fa63e 100644 --- a/Plan/src/main/resources/web/js/charts/resourceGraph.js +++ b/Plan/src/main/resources/web/js/charts/resourceGraph.js @@ -1,40 +1,60 @@ function resourceChart(id, cpuSeries, ramSeries, playersOnlineSeries) { - Highcharts.stockChart(id, { - rangeSelector: { - selected: 1, - buttons: [{ - type: 'hour', - count: 12, - text: '12h' - },{ - type: 'hour', - count: 24, - text: '24h' - },{ - type: 'day', - count: 7, - text: '7d' - },{ - type: 'month', - count: 1, - text: '30d' - },{ - type: 'all', - text: 'All' - }] - }, - tooltip: { - split: true - }, - title: {text: ''}, - plotOptions: { - areaspline: { - fillOpacity: 0.4 - } - }, - legend: { - enabled: true, + Highcharts.stockChart(id, { + rangeSelector: { + selected: 1, + buttons: [{ + type: 'hour', + count: 12, + text: '12h' + }, { + type: 'hour', + count: 24, + text: '24h' + }, { + type: 'day', + count: 7, + text: '7d' + }, { + type: 'month', + count: 1, + text: '30d' + }, { + type: 'all', + text: 'All' + }] }, - series: [cpuSeries, ramSeries, playersOnlineSeries] - }); + tooltip: { + split: true + }, + title: {text: ''}, + plotOptions: { + areaspline: { + fillOpacity: 0.4 + } + }, + yAxis: [{ + labels: { + formatter: function () { + return this.value + ' Players'; + } + } + }, { + opposite: true, + labels: { + formatter: function () { + return this.value + '%'; + } + } + }, { + labels: { + formatter: function () { + return this.value + ' MB'; + } + } + }], + legend: { + enabled: true + }, + series: [cpuSeries, ramSeries, playersOnlineSeries] + }); } \ No newline at end of file diff --git a/Plan/src/main/resources/web/js/charts/tpsGraph.js b/Plan/src/main/resources/web/js/charts/tpsGraph.js index 5ecb4dd7a2..5985a15664 100644 --- a/Plan/src/main/resources/web/js/charts/tpsGraph.js +++ b/Plan/src/main/resources/web/js/charts/tpsGraph.js @@ -1,40 +1,54 @@ function tpsChart(id, tpsSeries, playersOnlineSeries) { - Highcharts.stockChart(id, { - rangeSelector: { - selected: 1, - buttons: [{ - type: 'hour', - count: 12, - text: '12h' - },{ - type: 'hour', - count: 24, - text: '24h' - },{ - type: 'day', - count: 7, - text: '7d' - },{ - type: 'month', - count: 1, - text: '30d' - },{ - type: 'all', - text: 'All' - }] - }, - tooltip: { - split: true - }, - title: {text: ''}, - plotOptions: { - areaspline: { - fillOpacity: 0.4 - } - }, - legend: { - enabled: true, + Highcharts.stockChart(id, { + rangeSelector: { + selected: 1, + buttons: [{ + type: 'hour', + count: 12, + text: '12h' + }, { + type: 'hour', + count: 24, + text: '24h' + }, { + type: 'day', + count: 7, + text: '7d' + }, { + type: 'month', + count: 1, + text: '30d' + }, { + type: 'all', + text: 'All' + }] }, - series: [tpsSeries, playersOnlineSeries] - }); + tooltip: { + split: true + }, + title: {text: ''}, + plotOptions: { + areaspline: { + fillOpacity: 0.4 + } + }, + yAxis: [{ + labels: { + formatter: function () { + return this.value + ' Players'; + } + } + }, { + opposite: true, + labels: { + formatter: function () { + return this.value + ' TPS'; + } + } + }], + legend: { + enabled: true + }, + series: [tpsSeries, playersOnlineSeries] + }); } \ No newline at end of file diff --git a/Plan/src/main/resources/web/js/charts/worldGraph.js b/Plan/src/main/resources/web/js/charts/worldGraph.js index ae0636288a..32b85cc66e 100644 --- a/Plan/src/main/resources/web/js/charts/worldGraph.js +++ b/Plan/src/main/resources/web/js/charts/worldGraph.js @@ -1,40 +1,60 @@ function worldChart(id, entitySeries, chunkSeries, playersOnlineSeries) { - Highcharts.stockChart(id, { - rangeSelector: { - selected: 1, - buttons: [{ - type: 'hour', - count: 12, - text: '12h' - },{ - type: 'hour', - count: 24, - text: '24h' - },{ - type: 'day', - count: 7, - text: '7d' - },{ - type: 'month', - count: 1, - text: '30d' - },{ - type: 'all', - text: 'All' - }] - }, - tooltip: { - split: true - }, - title: {text: ''}, - plotOptions: { - areaspline: { - fillOpacity: 0.4 - } - }, - legend: { - enabled: true, + Highcharts.stockChart(id, { + rangeSelector: { + selected: 1, + buttons: [{ + type: 'hour', + count: 12, + text: '12h' + }, { + type: 'hour', + count: 24, + text: '24h' + }, { + type: 'day', + count: 7, + text: '7d' + }, { + type: 'month', + count: 1, + text: '30d' + }, { + type: 'all', + text: 'All' + }] }, - series: [entitySeries, chunkSeries, playersOnlineSeries] - }); + tooltip: { + split: true + }, + title: {text: ''}, + plotOptions: { + areaspline: { + fillOpacity: 0.4 + } + }, + yAxis: [{ + labels: { + formatter: function () { + return this.value + ' Players'; + } + } + }, { + opposite: true, + labels: { + formatter: function () { + return this.value + ' Entities'; + } + } + }, { + labels: { + formatter: function () { + return this.value + ' Chunks'; + } + } + }], + legend: { + enabled: true + }, + series: [entitySeries, chunkSeries, playersOnlineSeries] + }); } \ No newline at end of file diff --git a/Plan/src/main/resources/web/server.html b/Plan/src/main/resources/web/server.html index c5e6817512..2a9d3ec5a8 100644 --- a/Plan/src/main/resources/web/server.html +++ b/Plan/src/main/resources/web/server.html @@ -962,22 +962,6 @@

    Command Usage

    // Replaced Variables var v = { - data: { - playersOnline: ${playersOnlineSeries}, - tps: ${tpsSeries}, - cpu: ${cpuSeries}, - ram: ${ramSeries}, - entities: ${entitySeries}, - chunks: ${chunkSeries}, - activityPie: ${activityPieSeries}, - worldPie: ${worldSeries}, - worldPieDrillDown: ${gmSeries}, - geolocations: ${geoMapSeries}, - punchCard: ${punchCardSeries}, - activityStack: ${activityStackSeries}, - activityStackCategories: ${activityStackCategories}, - healthIndex: ${healthIndex} - }, colors: { playersOnline: '${playersGraphColor}', tpsLow: '${tpsLowColor}', @@ -994,8 +978,23 @@

    Command Usage

    values: { tpsMed: ${tpsMedium}, tpsHigh: ${tpsHigh} + }, + data: { + playersOnline: ${playersOnlineSeries}, + tps: ${tpsSeries}, + cpu: ${cpuSeries}, + ram: ${ramSeries}, + entities: ${entitySeries}, + chunks: ${chunkSeries}, + activityPie: ${activityPieSeries}, + worldPie: ${worldSeries}, + worldPieDrillDown: ${gmSeries}, + geolocations: ${geoMapSeries}, + punchCard: ${punchCardSeries}, + activityStack: ${activityStackSeries}, + activityStackCategories: ${activityStackCategories}, + healthIndex: ${healthIndex} } - }; // HighCharts Series @@ -1039,42 +1038,80 @@

    Command Usage

    type: s.type.areaSpline, tooltip: s.tooltip.zeroDecimals, data: v.data.playersOnline, - color: v.colors.playersOnline + color: v.colors.playersOnline, + yAxis: 0 }, tps: { name: s.name.tps, type: s.type.spline, zones: s.zones.tps, tooltip: s.tooltip.twoDecimals, - data: v.data.tps + data: v.data.tps, + yAxis: 1 }, cpu: { name: s.name.cpu, type: s.type.spline, tooltip: s.tooltip.twoDecimals, data: v.data.cpu, - color: v.colors.cpu + color: v.colors.cpu, + yAxis: 2 + }, + cpu_alt: { + name: s.name.cpu, + type: s.type.spline, + tooltip: s.tooltip.twoDecimals, + data: v.data.cpu, + color: v.colors.cpu, + yAxis: 1 }, ram: { name: s.name.ram, type: s.type.spline, tooltip: s.tooltip.zeroDecimals, data: v.data.ram, - color: v.colors.ram + color: v.colors.ram, + yAxis: 3 + }, + ram_alt: { + name: s.name.ram, + type: s.type.spline, + tooltip: s.tooltip.zeroDecimals, + data: v.data.ram, + color: v.colors.ram, + yAxis: 2 }, entities: { name: s.name.entities, type: s.type.spline, tooltip: s.tooltip.zeroDecimals, data: v.data.entities, - color: v.colors.entities + color: v.colors.entities, + yAxis: 4 + }, + entities_alt: { + name: s.name.entities, + type: s.type.spline, + tooltip: s.tooltip.zeroDecimals, + data: v.data.entities, + color: v.colors.entities, + yAxis: 1 }, chunks: { name: s.name.chunks, type: s.type.spline, tooltip: s.tooltip.zeroDecimals, data: v.data.chunks, - colors: v.colors.chunks + color: v.colors.chunks, + yAxis: 5 + }, + chunks_alt: { + name: s.name.chunks, + type: s.type.spline, + tooltip: s.tooltip.zeroDecimals, + data: v.data.chunks, + color: v.colors.chunks, + yAxis: 2 }, activityPie: { name: 'Players', @@ -1136,8 +1173,8 @@

    Command Usage

    playersChart('playerChartMonth', series.playersOnline, 2); performanceChart('performanceGraph', series.playersOnline, series.tps, series.cpu, series.ram, series.entities, series.chunks); tpsChart('tpsGraph', series.tps, series.playersOnline); - resourceChart('resourceGraph', series.cpu, series.ram, series.playersOnline); - worldChart('worldGraph', series.entities, series.chunks, series.playersOnline); + resourceChart('resourceGraph', series.cpu_alt, series.ram_alt, series.playersOnline); + worldChart('worldGraph', series.entities_alt, series.chunks_alt, series.playersOnline); worldMap('worldMap', v.colors.geolocationsLow, v.colors.geolocationsHigh, series.geolocations); punchCard('punchCard', series.punchCard); healthGauge('healthGauge', [v.data.healthIndex]); From 26029e78530854784587a293ecf80b9703c9b508 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 20:33:33 +0200 Subject: [PATCH 152/166] Increased Performance tab chart height --- Plan/src/main/resources/web/server.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plan/src/main/resources/web/server.html b/Plan/src/main/resources/web/server.html index 2a9d3ec5a8..313e6aac4f 100644 --- a/Plan/src/main/resources/web/server.html +++ b/Plan/src/main/resources/web/server.html @@ -683,16 +683,16 @@

    World Playtime

    -
    +
    -
    +
    -
    +
    -
    +
    From dc7cc2daffc2be2c3c358ec85e7b223ed45df965 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 20:51:37 +0200 Subject: [PATCH 153/166] Bungee now sends a Wide Network page content generation request. --- .../djrapitops/plan/system/PlanSystem.java | 2 +- .../connection/BukkitConnectionSystem.java | 25 +++++++----- .../info/connection/ConnectionSystem.java | 1 + .../GenerateNetworkPageContentRequest.java | 40 +++++++++++++++++++ .../tasks/bungee/EnableConnectionTask.java | 9 +++-- 5 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateNetworkPageContentRequest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 8ffdb12676..5cd4d46e66 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -83,9 +83,9 @@ public void enable() throws EnableException { configSystem, databaseSystem, webServerSystem, + processingQueue, serverInfo, infoSystem, - processingQueue, cacheSystem, listenerSystem, taskSystem, diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java index 0bb6843064..7b48d74fbc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/BukkitConnectionSystem.java @@ -11,6 +11,7 @@ import com.djrapitops.plan.system.info.request.*; import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.ServerInfo; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.locale.Msg; @@ -38,17 +39,19 @@ public BukkitConnectionSystem() { } private void refreshServerMap() { - if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.SECOND.ms() * 15L) { - try { - Database database = Database.getActive(); - Optional bungeeInformation = database.fetch().getBungeeInformation(); - bungeeInformation.ifPresent(server -> mainServer = server); - bukkitServers = database.fetch().getBukkitServers(); - latestServerMapRefresh = MiscUtils.getTime(); - } catch (DBException e) { - Log.toLog(this.getClass(), e); + Processor.queue(() -> { + if (latestServerMapRefresh < MiscUtils.getTime() - TimeAmount.SECOND.ms() * 15L) { + try { + Database database = Database.getActive(); + Optional bungeeInformation = database.fetch().getBungeeInformation(); + bungeeInformation.ifPresent(server -> mainServer = server); + bukkitServers = database.fetch().getBukkitServers(); + latestServerMapRefresh = MiscUtils.getTime(); + } catch (DBException e) { + Log.toLog(this.getClass(), e); + } } - } + }); } @Override @@ -116,7 +119,7 @@ public void enable() { } if (usingBungeeWebServer && usingAlternativeIP) { String webServerAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress(); - Log.info("Make sure that this address points to the Bukkit Server: " + webServerAddress); + Log.info("Make sure that this address points to THIS Bukkit Server: " + webServerAddress); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java index f874af6f7a..0cdf675899 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionSystem.java @@ -120,6 +120,7 @@ private Map loadDataRequests() { putRequest(requests, GenerateAnalysisPageRequest.createHandler()); putRequest(requests, GenerateInspectPageRequest.createHandler()); putRequest(requests, GenerateInspectPluginsTabRequest.createHandler()); + putRequest(requests, GenerateNetworkPageContentRequest.createHandler()); putRequest(requests, SaveDBSettingsRequest.createHandler()); putRequest(requests, SendDBSettingsRequest.createHandler()); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateNetworkPageContentRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateNetworkPageContentRequest.java new file mode 100644 index 0000000000..33d83d8650 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/GenerateNetworkPageContentRequest.java @@ -0,0 +1,40 @@ +/* + * 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.info.request; + +import com.djrapitops.plan.api.exceptions.connection.WebException; +import com.djrapitops.plan.system.info.InfoSystem; +import com.djrapitops.plan.system.webserver.response.DefaultResponses; +import com.djrapitops.plan.system.webserver.response.Response; + +import java.util.Map; + +/** + * InfoRequest for generating network page content of a Bukkit server. + * + * @author Rsl1122 + */ +public class GenerateNetworkPageContentRequest implements WideRequest, GenerateRequest { + + public static GenerateNetworkPageContentRequest createHandler() { + return new GenerateNetworkPageContentRequest(); + } + + @Override + public void placeDataToDatabase() { + /* No Data needed on a GenerateRequest.*/ + } + + @Override + public Response handleRequest(Map variables) throws WebException { + InfoSystem.getInstance().updateNetworkPage(); + return DefaultResponses.SUCCESS.get(); + } + + @Override + public void runLocally() throws WebException { + InfoSystem.getInstance().updateNetworkPage(); + } +} \ No newline at end of file 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 9a4e436273..33204938b7 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,5 +1,8 @@ package com.djrapitops.plan.system.tasks.bungee; +import com.djrapitops.plan.system.info.connection.ConnectionSystem; +import com.djrapitops.plan.system.info.connection.WebExceptionLogger; +import com.djrapitops.plan.system.info.request.GenerateNetworkPageContentRequest; import com.djrapitops.plugin.task.AbsRunnable; public class EnableConnectionTask extends AbsRunnable { @@ -10,9 +13,9 @@ public EnableConnectionTask() { @Override public void run() { -// TODO Config InfoRequests. - // infoManager.attemptConnection(); -// infoManager.sendConfigSettings(); + WebExceptionLogger.logIfOccurs(this.getClass(), + () -> ConnectionSystem.getInstance().sendWideInfoRequest(new GenerateNetworkPageContentRequest()) + ); cancel(); } } From 2b7f194d377e27d13a15f56506874a46e41ee927 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 10 Feb 2018 21:04:52 +0200 Subject: [PATCH 154/166] Fixed Network Settings transfer. (Fixed TransferTable clean method) --- .../database/databases/sql/tables/TransferTable.java | 4 ++-- .../system/settings/network/NetworkSettings.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java index 7877fc22c2..c959d680bc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -85,13 +85,13 @@ public void clean() throws SQLException { execute(new ExecStatement(sql) { @Override public void prepare(PreparedStatement statement) throws SQLException { - statement.setLong(1, MiscUtils.getTime() + TimeAmount.MINUTE.ms()); + statement.setLong(1, MiscUtils.getTime()); statement.setString(2, "onlineStatus"); } }); sql = "DELETE FROM " + tableName + " WHERE " + columnSenderID + " = " + serverTable.statementSelectServerID + - " AND " + columnInfoType + " != ?"; + " AND " + columnInfoType + " = ?"; execute(new ExecStatement(sql) { @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java index 5153d7a923..e4ee485109 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/network/NetworkSettings.java @@ -54,8 +54,6 @@ public static void placeSettingsToDB() { return; } - Log.debug("Saving Config settings to database."); - Processor.queue(() -> { try { new NetworkSettings().placeToDatabase(); @@ -66,22 +64,25 @@ public static void placeSettingsToDB() { } public void loadFromDatabase() throws DBException, UnsupportedTransferDatabaseException { + Log.debug("NetworkSettings: Fetch Config settings from database.."); Optional encodedConfigSettings = Database.getActive().transfer().getEncodedConfigSettings(); if (!encodedConfigSettings.isPresent()) { - Log.debug("No Config settings in database."); + Log.debug("NetworkSettings: No Config settings in database."); return; } String configSettings = Base64Util.decode(encodedConfigSettings.get()); Map pathValueMap = getPathsAndValues(configSettings); + Log.debug("NetworkSettings: Updating Settings"); ServerSpecificSettings.updateSettings(pathValueMap); } private Map getPathsAndValues(String configSettings) { Map pathValueMap = new HashMap<>(); + Log.debug("NetworkSettings: Reading Config String.."); String[] settings = configSettings.split(SPLIT); UUID thisServerUUID = ServerInfo.getServerUUID(); for (String settingAndVal : settings) { @@ -108,6 +109,7 @@ private Map getPathsAndValues(String configSettings) { public void placeToDatabase() throws DBException, UnsupportedTransferDatabaseException { Map configValues = getConfigValues(); + Log.debug("NetworkSettings: Building Base64 String.."); StringBuilder transferBuilder = new StringBuilder(); int size = configValues.size(); int i = 0; @@ -125,10 +127,12 @@ public void placeToDatabase() throws DBException, UnsupportedTransferDatabaseExc String base64 = Base64Util.encode(transferBuilder.toString()); + Log.debug("NetworkSettings: Saving Config settings to database.."); Database.getActive().transfer().storeConfigSettings(base64); } private Map getConfigValues() throws DBException { + Log.debug("NetworkSettings: Loading Config Values.."); Map configValues = new HashMap<>(); addConfigValue(configValues, Settings.DB_TYPE, "mysql"); Settings[] sameStrings = new Settings[]{ @@ -138,6 +142,7 @@ private Map getConfigValues() throws DBException { Settings.FORMAT_MINUTES, Settings.FORMAT_MONTHS, Settings.FORMAT_MONTH, Settings.FORMAT_YEAR, Settings.FORMAT_YEARS, Settings.FORMAT_ZERO_SECONDS }; + Log.debug("NetworkSettings: Adding Config Values.."); for (Settings setting : sameStrings) { addConfigValue(configValues, setting, setting.toString()); } @@ -159,6 +164,7 @@ private void addConfigValue(Map configValues, UUID serverUUID, S } private void addServerSpecificValues(Map configValues) throws DBException { + Log.debug("NetworkSettings: Adding Server-specific Config Values.."); ServerSpecificSettings settings = Settings.serverSpecific(); for (UUID serverUUID : Database.getActive().fetch().getServerUUIDs()) { From ea873f798edfa056cf4ff2bdd068e5ed6cac7bd8 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 14:36:47 +0200 Subject: [PATCH 155/166] Prevented some error logs on reload --- .../plan/system/settings/theme/Theme.java | 5 +++++ .../system/tasks/bukkit/BootAnalysisTask.java | 22 +++++++++++++------ .../tasks/bukkit/PeriodicAnalysisTask.java | 18 +++++++++++---- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java index 9c3b139649..e396a02be0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java @@ -4,6 +4,7 @@ */ package com.djrapitops.plan.system.settings.theme; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.settings.Settings; @@ -69,6 +70,10 @@ public String getColor(ThemeVal variable) { } else { return value; } + } catch (IllegalStateException e) { + if (!PlanPlugin.getInstance().isReloading()) { + Log.error("Something went wrong with getting variable " + variable.name() + " for: " + path); + } } catch (Exception | NoSuchFieldError e) { Log.error("Something went wrong with getting variable " + variable.name() + " for: " + path); } 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 a3f13e6ab1..90cd494880 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,5 +1,6 @@ package com.djrapitops.plan.system.tasks.bukkit; +import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.connection.WebExceptionLogger; import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest; @@ -18,13 +19,20 @@ public BootAnalysisTask() { @Override public void run() { - String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString(); - Log.info(bootAnalysisRunMsg); - if (!Analysis.isAnalysisBeingRun()) { - WebExceptionLogger.logIfOccurs(this.getClass(), () -> - InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) - ); + try { + String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString(); + Log.info(bootAnalysisRunMsg); + if (!Analysis.isAnalysisBeingRun()) { + WebExceptionLogger.logIfOccurs(this.getClass(), () -> + InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) + ); + } + } catch (IllegalStateException e) { + if (!PlanPlugin.getInstance().isReloading()) { + Log.toLog(this.getClass(), e); + } + } finally { + cancel(); } - 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 c0c780a044..ac4c04f179 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,10 +1,12 @@ package com.djrapitops.plan.system.tasks.bukkit; +import com.djrapitops.plan.PlanPlugin; 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; public class PeriodicAnalysisTask extends AbsRunnable { @@ -15,10 +17,18 @@ public PeriodicAnalysisTask() { @Override public void run() { - if (!Analysis.isAnalysisBeingRun()) { - WebExceptionLogger.logIfOccurs(this.getClass(), () -> - InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) - ); + try { + if (!Analysis.isAnalysisBeingRun()) { + WebExceptionLogger.logIfOccurs(this.getClass(), () -> + InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID())) + ); + } + } catch (IllegalStateException e) { + if (!PlanPlugin.getInstance().isReloading()) { + Log.toLog(this.getClass(), e); + } + } finally { + cancel(); } } } From 22bbf3afc018141003aeedf7ae7909dcf2b7883c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:06:24 +0200 Subject: [PATCH 156/166] Moved back to Check.isPaperAvailable for PaperTPSTask --- .../com/djrapitops/plan/system/tasks/BukkitTaskSystem.java | 5 ++--- .../java/com/djrapitops/plan/system/tasks/TPSCountTimer.java | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index 6ba7b1a8bf..087ad67444 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -11,6 +11,7 @@ import com.djrapitops.plan.system.tasks.bukkit.*; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.api.Benchmark; +import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.task.ITask; @@ -29,9 +30,7 @@ public class BukkitTaskSystem extends TaskSystem { private final Plan plugin; public BukkitTaskSystem(Plan plugin) { - String serverName = plugin.getServer().getServerName(); - boolean isPaper = serverName.equals("Paper") || serverName.equals("TacoSpigot"); - tpsCountTimer = isPaper + tpsCountTimer = Check.isPaperAvailable() ? new PaperTPSCountTimer(plugin) : new BukkitTPSCountTimer(plugin); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java index a162d42dbb..4a3d029287 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java @@ -2,6 +2,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.data.container.TPS; +import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.task.AbsRunnable; @@ -36,7 +37,7 @@ public void run() { addNewTPSEntry(nanoTime, now); if (history.size() >= 60) { - new TPSInsertProcessor(new ArrayList<>(history)).queue(); + Processor.queue(new TPSInsertProcessor(new ArrayList<>(history))); history.clear(); } } From 63b48bb2ee1565e69fb388921620eec5fa2f4b52 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:10:38 +0200 Subject: [PATCH 157/166] Prevented PluginData elements causing player page to fail in some cases --- .../main/java/com/djrapitops/plan/data/plugin/HookHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java index a37f0fa7cf..6654bcdf66 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/plugin/HookHandler.java @@ -97,7 +97,7 @@ public Map getInspectContainersFor(UUID uuid) { if (container != null && !container.isEmpty()) { containers.put(pluginData, container); } - } catch (Exception e) { + } catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) { String sourcePlugin = pluginData.getSourcePlugin(); Log.error("PluginData caused exception: " + sourcePlugin); Log.toLog(this.getClass().getName() + " " + sourcePlugin, e); From 10537425333bd87ef42e47088e9ab44de5553edd Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:11:21 +0200 Subject: [PATCH 158/166] Fixed NoClassDefFoundError for 1.7.10 on enable --- .../plan/system/update/VersionCheckSystem.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java index 22122f9a26..5051d24418 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/update/VersionCheckSystem.java @@ -51,8 +51,14 @@ private void checkForNewVersion() { String githubVersionUrl = "https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml"; String spigotUrl = "https://www.spigotmc.org/resources/plan-player-analytics.32536/"; try { - newVersionAvailable = Version.checkVersion(currentVersion, githubVersionUrl) - || Version.checkVersion(currentVersion, spigotUrl); + newVersionAvailable = Version.checkVersion(currentVersion, githubVersionUrl); + if (!newVersionAvailable) { + try { + newVersionAvailable = Version.checkVersion(currentVersion, spigotUrl); + } catch (NoClassDefFoundError ignore) { + /* 1.7.4 Does not have google gson JSONParser */ + } + } if (newVersionAvailable) { String newVersionNotification = "New Version is available at " + spigotUrl; Log.infoColor("§a----------------------------------------"); From 69c8111be8748dff70b4ade1bef1491f8ba1ae71 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:13:58 +0200 Subject: [PATCH 159/166] Removed tab: {height: 100%;} that was causing second scrollbar --- Plan/src/main/resources/web/css/main.css | 1 - 1 file changed, 1 deletion(-) diff --git a/Plan/src/main/resources/web/css/main.css b/Plan/src/main/resources/web/css/main.css index 4ff663d1a3..0f11586e4a 100644 --- a/Plan/src/main/resources/web/css/main.css +++ b/Plan/src/main/resources/web/css/main.css @@ -88,7 +88,6 @@ .tab { width: 0; - height: 100%; float: left; } From cdbd8f9496b23cc97989665a5da60c5320e1cf62 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:23:42 +0200 Subject: [PATCH 160/166] Reversed PunchCard days: (Now top -> bottom = Monday -> Sunday) --- .../main/resources/web/js/charts/punchCard.js | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Plan/src/main/resources/web/js/charts/punchCard.js b/Plan/src/main/resources/web/js/charts/punchCard.js index 359986e3d4..f7c3280f9a 100644 --- a/Plan/src/main/resources/web/js/charts/punchCard.js +++ b/Plan/src/main/resources/web/js/charts/punchCard.js @@ -1,26 +1,30 @@ function punchCard(id, punchcardSeries) { - Highcharts.chart(id, { - chart: { - defaultSeriesType: 'scatter' - }, - title: {text: ''}, - xAxis: { - type: 'datetime', - dateTimeLabelFormats: { + Highcharts.chart(id, { + chart: { + defaultSeriesType: 'scatter' + }, + title: {text: ''}, + xAxis: { + type: 'datetime', + dateTimeLabelFormats: { hour: '%I %P', day: '%H %P' - }, - tickInterval: 3600000 - }, + }, + tickInterval: 3600000 + }, time: { - timezoneOffset: 0 + timezoneOffset: 0 + }, + yAxis: { + title: { + text: "Day of the Week" + }, + reversed: true, + categories: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + }, + tooltip: { + pointFormat: 'Activity: {point.z}' }, - yAxis: { - categories: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'] - }, - tooltip: { - pointFormat: 'Activity: {point.z}' - }, - series: [punchcardSeries] - }); + series: [punchcardSeries] + }); } \ No newline at end of file From 66b145f7f97a714553186329001557def3d4cd28 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:44:25 +0200 Subject: [PATCH 161/166] Fixed Bukkit server nagging about internal error when setup succeeded. --- .../info/request/SaveDBSettingsRequest.java | 16 +++++++++------- .../info/request/SendDBSettingsRequest.java | 11 ++++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java index 55d66e35cc..ef3b2a254b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SaveDBSettingsRequest.java @@ -62,13 +62,15 @@ public Response handleRequest(Map variables) throws WebException return new BadRequestResponse("Bungee config settings overridden on this server."); } - setSettings(variables); - Log.info("----------------------------------"); - Log.info("The Received Bungee Database Settings, restarting Plan.."); - Log.info("----------------------------------"); - Plan.getInstance().reloadPlugin(true); - - return DefaultResponses.SUCCESS.get(); + try { + setSettings(variables); + Log.info("----------------------------------"); + Log.info("The Received Bungee Database Settings, restarting Plan.."); + Log.info("----------------------------------"); + return DefaultResponses.SUCCESS.get(); + } finally { + Plan.getInstance().reloadPlugin(true); + } } private void setSettings(Map variables) throws BadRequestException { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java index f0db5ac7f8..8097da8a02 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/request/SendDBSettingsRequest.java @@ -5,6 +5,7 @@ package com.djrapitops.plan.system.info.request; import com.djrapitops.plan.api.exceptions.connection.BadRequestException; +import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException; import com.djrapitops.plan.api.exceptions.connection.WebException; import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.info.server.Server; @@ -15,6 +16,7 @@ import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.utilities.Verify; +import java.net.SocketException; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -74,7 +76,14 @@ public Response handleRequest(Map variables) throws WebException Server bukkit = new Server(-1, serverUUID, serverName, address, -1); - InfoSystem.getInstance().getConnectionSystem().sendInfoRequest(new SaveDBSettingsRequest(), bukkit); + try { + InfoSystem.getInstance().getConnectionSystem().sendInfoRequest(new SaveDBSettingsRequest(), bukkit); + } catch (ConnectionFailException e) { + Throwable cause = e.getCause(); + if (!(cause instanceof SocketException) || !cause.getMessage().contains("Unexpected end of file from server")) { + throw e; + } + } return DefaultResponses.SUCCESS.get(); } From 663a4d7642c983db70bd87856c5f4b1ed0975a23 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:46:41 +0200 Subject: [PATCH 162/166] Better error message after trying to access analysis of offline server --- .../djrapitops/plan/system/info/connection/ConnectionOut.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java index 552d06e627..0bb6ad7283 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionOut.java @@ -146,7 +146,7 @@ public void sendRequest() throws WebException { Log.toLog(this.getClass(), e); } ConnectionLog.logConnectionTo(toServer, infoRequest, -1); - throw new ConnectionFailException("Connection failed to address: " + address, e); + throw new ConnectionFailException("Connection failed to address: " + address + "
    Make sure the server is online.", e); } finally { if (connection != null) { connection.disconnect(); From 3d6c080ac2edf004864a4c2180b09a7e6f97db83 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sun, 11 Feb 2018 15:47:52 +0200 Subject: [PATCH 163/166] Better error message after player's UUID was not found. --- .../plan/system/webserver/pages/PlayerPageHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java index a081c118d7..493cdc2331 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/pages/PlayerPageHandler.java @@ -43,7 +43,7 @@ public Response getResponse(Request request, List target) throws WebExce UUID uuid = UUIDUtility.getUUIDOf(playerName); if (uuid == null) { - return notFound("Player has no UUID"); + return notFound("Player UUID was not found in the database."); } try { From 9d3def37afb5389d19f2f2115eab0c0a8999b673 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 12 Feb 2018 14:37:06 +0200 Subject: [PATCH 164/166] Connection fail log warning should be less common. --- .../system/info/connection/ConnectionLog.java | 13 +++++++- .../info/connection/WebExceptionLogger.java | 32 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java index b99856c84a..1064d5ff08 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/ConnectionLog.java @@ -56,7 +56,7 @@ public Map> getLog() { return log; } - public static class Entry { + public static class Entry implements Comparable { private final int responseCode; private final long timeSent; @@ -73,6 +73,17 @@ public int getResponseCode() { public long getTimeSent() { return timeSent; } + + /** + * Most recent first. + * + * @param o + * @return + */ + @Override + public int compareTo(Entry o) { + return -Long.compare(this.timeSent, o.timeSent); + } } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java index d61bca6a2a..229833265c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java @@ -7,6 +7,11 @@ import com.djrapitops.plan.api.exceptions.connection.*; import com.djrapitops.plugin.api.utility.log.Log; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + /** * Class that decides what to do with WebExceptions. * @@ -17,7 +22,11 @@ public class WebExceptionLogger { public static void logIfOccurs(Class c, ExceptionLoggingAction action) { try { action.performAction(); - } catch (ConnectionFailException | UnsupportedTransferDatabaseException | UnauthorizedServerException + } catch (ConnectionFailException e) { + if (shouldLog(e)) { + Log.warn(e.getMessage()); + } + } catch (UnsupportedTransferDatabaseException | UnauthorizedServerException | NotFoundException | NoServersException e) { Log.warn(e.getMessage()); } catch (WebException e) { @@ -25,6 +34,27 @@ public static void logIfOccurs(Class c, ExceptionLoggingAction action) { } } + private static boolean shouldLog(ConnectionFailException e) { + String address = null; + if (e.getMessage().contains("to address")) { + String[] split = e.getMessage().split("to address: "); + if (split.length == 2) { + String[] split2 = split[1].split("
    "); + if (split2.length == 2) { + address = split2[0]; + } + } + } + Map> logEntries = ConnectionLog.getLogEntries(); + Map entries = logEntries.get("Out: " + address); + if (entries != null) { + List connections = new ArrayList<>(entries.values()); + Collections.sort(connections); + return connections.isEmpty() || connections.get(0).getResponseCode() != -1; + } + return true; + } + public interface ExceptionLoggingAction { void performAction() throws WebException; From 78b4abc0a39619ef26f631492e5f4c74bef2d60c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 12 Feb 2018 14:39:39 +0200 Subject: [PATCH 165/166] Removed DEV from version --- .../info/connection/WebExceptionLogger.java | 25 ++++++++++++------- Plan/src/main/resources/bungee.yml | 2 +- Plan/src/main/resources/plugin.yml | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java index 229833265c..13297b4630 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/connection/WebExceptionLogger.java @@ -35,15 +35,9 @@ public static void logIfOccurs(Class c, ExceptionLoggingAction action) { } private static boolean shouldLog(ConnectionFailException e) { - String address = null; - if (e.getMessage().contains("to address")) { - String[] split = e.getMessage().split("to address: "); - if (split.length == 2) { - String[] split2 = split[1].split("
    "); - if (split2.length == 2) { - address = split2[0]; - } - } + String address = getAddress(e); + if (address == null) { + return true; } Map> logEntries = ConnectionLog.getLogEntries(); Map entries = logEntries.get("Out: " + address); @@ -55,6 +49,19 @@ private static boolean shouldLog(ConnectionFailException e) { return true; } + private static String getAddress(ConnectionFailException e) { + if (e.getMessage().contains("to address")) { + String[] split = e.getMessage().split("to address: "); + if (split.length == 2) { + String[] split2 = split[1].split("
    "); + if (split2.length == 2) { + return split2[0]; + } + } + } + return null; + } + public interface ExceptionLoggingAction { void performAction() throws WebException; diff --git a/Plan/src/main/resources/bungee.yml b/Plan/src/main/resources/bungee.yml index 64262e20b5..4e3f5d37c4 100644 --- a/Plan/src/main/resources/bungee.yml +++ b/Plan/src/main/resources/bungee.yml @@ -1,4 +1,4 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.PlanBungee -version: 4.1.5-DEV \ No newline at end of file +version: 4.1.5 \ No newline at end of file diff --git a/Plan/src/main/resources/plugin.yml b/Plan/src/main/resources/plugin.yml index 0df33d66e7..d9572022f4 100644 --- a/Plan/src/main/resources/plugin.yml +++ b/Plan/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.Plan -version: 4.1.5-DEV +version: 4.1.5 softdepend: - EssentialsX - Towny From cb1290340a79d649ef82adcf599387f5792c73ce Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 12 Feb 2018 14:46:17 +0200 Subject: [PATCH 166/166] Transfer ops for player online. Not going to risk it though. --- .../database/databases/operation/TransferOperations.java | 2 ++ .../database/databases/sql/operation/SQLTransferOps.java | 9 +++++++++ .../com/djrapitops/plan/utilities/FormatUtilsTest.java | 2 ++ 3 files changed, 13 insertions(+) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index e3035223ef..9829891433 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -31,6 +31,8 @@ public interface TransferOperations { void storeConfigSettings(String encodedSettingString) throws DBException; + void playerOnline(UUID playerUUID) throws DBException; + // Get Map getEncodedPlayerHtml() throws DBException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java index 2fec2025ea..6611a10cee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java @@ -122,4 +122,13 @@ public Optional getEncodedConfigSettings() throws DBException { throw SQLErrorUtil.getExceptionFor(e); } } + + @Override + public void playerOnline(UUID playerUUID) throws DBException { + try { + transferTable.storePlayerOnlineOnThisServer(playerUUID); + } catch (SQLException e) { + throw SQLErrorUtil.getExceptionFor(e); + } + } } \ No newline at end of file diff --git a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java index 0410e230f8..e2066fc4a2 100644 --- a/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/utilities/FormatUtilsTest.java @@ -10,6 +10,7 @@ import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; import utilities.RandomData; +import utilities.Teardown; import utilities.mocks.SystemMockUtil; import utilities.mocks.objects.MockUtils; @@ -30,6 +31,7 @@ public class FormatUtilsTest { public static void setUpClass() throws Exception { SystemMockUtil.setUp(temporaryFolder.getRoot()) .enableConfigSystem(); + Teardown.resetSettingsTempValues(); } @Test