From cefe17ead839760857fca9f3973a98adf3bd80e1 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 25 Jan 2018 16:02:05 +0200 Subject: [PATCH] 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 fad8fb473..b4637e807 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 @@ import org.bukkit.configuration.file.FileConfiguration; /** * 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 d063b03a5..f61495c84 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.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.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 class PlanBungee extends BungeePlugin implements PlanPlugin { 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 class PlanBungee extends BungeePlugin implements PlanPlugin { 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 8c5a12b0f..496248027 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 @@ package com.djrapitops.plan.api.exceptions; public class PassEncryptException extends Exception { - public PassEncryptException() { - } - public PassEncryptException(String s) { super(s); } @@ -13,11 +10,4 @@ public class PassEncryptException extends Exception { 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 1ee152878..ac0f802b6 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 class PlanBungeeCommand extends TreeCommand { 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 8e7ba2efe..ec060ea6a 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 class PlanCommand extends TreeCommand { 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 dc3aeb428..25cd0b7e1 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.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.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.CommandType; 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 class AnalyzeCommand extends SubCommand { 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 @@ public class AnalyzeCommand extends SubCommand { 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 5aa5af2c0..7021b997e 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 @@ import com.djrapitops.plugin.command.SubCommand; */ 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 e1c5f4bf6..1d826081e 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 class InfoCommand extends SubCommand { 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 a0556bb31..b4b50ac8e 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 class InspectCommand extends SubCommand { } } 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 1726cc496..b3a035ec3 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 class ManageCommand extends TreeCommand { 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 fe2302622..57f89eca5 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 @@ import com.djrapitops.plugin.command.SubCommand; */ 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 74f32c9c5..96487c5b4 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 @@ import com.djrapitops.plugin.task.RunnableFactory; */ 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 c0538e04b..f177e96be 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 0b485b18c..01604a48f 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 @@ import com.djrapitops.plugin.utilities.Verify; */ 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 28ea80b7c..cefb1a465 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 baad80760..1589ff4d8 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.AnalysisUtils; 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.ActivityPie; 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 @@ public class AnalysisData extends RawData { addValue("playersOnline", ServerProfile.getPlayersOnline()); } - public long getRefreshDate() { - return refreshDate; - } - public void analyze(ServerProfile profile) { long now = MiscUtils.getTime(); refreshDate = now; @@ -167,7 +162,7 @@ public class AnalysisData extends RawData { 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 6a4117091..ca4b02b6e 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 class PlayerProfile implements OfflinePlayer { // 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 6c99b9c74..35cb71034 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 class UserInfo { 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 class UserInfo { 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 759f04344..6a3ced105 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 @@ import java.util.List; * * @author Rsl1122 */ -public final class TableContainer { +public class TableContainer { private final String[] header; private List values; @@ -38,18 +38,18 @@ public final class TableContainer { 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 @@ public final class TableContainer { 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 598e1bc00..b37cb143e 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 class PluginsConfigSection { } 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 b84dab53d..6070b67d9 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.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.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 class SessionCache { 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 a8c99af8c..f60527b53 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 abstract class DBSystem implements SubSystem { 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 abstract class DBSystem implements SubSystem { 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 59ace042b..dff787a03 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 @@ import com.djrapitops.plan.utilities.NullCheck; */ 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 35c73d24e..3f088be73 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 abstract class SQLDB extends Database { try { setupDataSource(); setupDatabase(); - open = true; } finally { Benchmark.stop("Database", benchName); Log.logDebug("Database"); @@ -229,8 +227,8 @@ public abstract class SQLDB extends Database { @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 abstract class SQLDB extends Database { 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 15a41f0f1..53e8e36dc 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 class ServerTable extends Table { 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 4f6045e0b..dc51f738d 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 @@ 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.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 abstract class InfoSystem implements SubSystem { 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 c9a58b115..0c15fee69 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.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; @@ -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 @@ public class BukkitConnectionSystem extends ConnectionSystem { 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 @@ public class BukkitConnectionSystem extends ConnectionSystem { 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 @@ public class BukkitConnectionSystem extends ConnectionSystem { 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 @@ public class BukkitConnectionSystem extends ConnectionSystem { @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 5c256b395..5a08412de 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.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; @@ -30,17 +28,15 @@ import java.util.UUID; 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 @@ public class BungeeConnectionSystem extends ConnectionSystem { 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 @@ public class BungeeConnectionSystem extends ConnectionSystem { @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 366811aab..8e35a2d81 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 class ConnectionLog { } 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 class ConnectionLog { 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 982f6bea5..d8cc0d87e 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 c355695f2..0cf8b50d9 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.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.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 class CacheAnalysisPageRequest implements CacheRequest { 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 3ff1a0ee0..241d19fb6 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.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.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 class CacheInspectPageRequest implements CacheRequest { 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 cd54ad203..84be99fd9 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 e3f12d5c3..b2dc6a15d 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 @@ package com.djrapitops.plan.system.info.server; 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 class ServerInfoFile extends Config { 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 12191c9a9..1d2d4c107 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 @@ public class BukkitListenerSystem extends ListenerSystem { 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 e5c22ab80..4b4e717d1 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 67687c794..6f5805072 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 @@ import org.bukkit.projectiles.ProjectileSource; */ 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 class DeathEventListener implements Listener { 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 39956f151..3e04d6a62 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 @@ import java.util.UUID; */ 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 class GamemodeChangeListener implements Listener { 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 ea7b134c4..d69935576 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 @@ package com.djrapitops.plan.system.listeners.bukkit; 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 class PlayerOnlineListener implements Listener { 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 467e8735f..3df7403f7 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 @@ 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.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 @@ class ProcessConsumer extends Consumer { 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 000000000..d65f6d724 --- /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 e107873c7..875393bb6 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 @@ import com.djrapitops.plugin.api.utility.log.Log; * * @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 f47a9f774..000000000 --- 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 7c87c8059..970978a8b 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 ac30c9fa5..9bc77adc6 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 @@ import java.util.List; * * @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 ed0be671f..b56ad17c8 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 class InspectCacheRequestProcessor extends PlayerProcessor { @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 9d11a84f6..a1bb9fbeb 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 @@ 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.plan.system.processing.Processor; import com.djrapitops.plugin.api.utility.log.Log; /** @@ -14,11 +14,7 @@ import com.djrapitops.plugin.api.utility.log.Log; * * @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 f15c7448b..000000000 --- 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 94ee3983e..95ede6639 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 class KillProcessor extends PlayerProcessor { 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 708595e22..0ace17488 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 class NameProcessor extends PlayerProcessor { @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 @@ public class NameProcessor extends PlayerProcessor { 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 d65f4fd23..006e78218 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 @@ import java.util.UUID; * * @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 8dae1a0a9..f3613f532 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.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.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 80703f0bf..212571073 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 class WorldAliasSettings { } 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 a79b52af5..caf584872 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 abstract class ConfigSystem implements SubSystem { /** * 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 879180841..045f71390 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 @@ public class Locale { .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 3a03c2c3b..7ac666ce9 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 class Request { 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 73e0d9297..3be7cc265 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 f63ce00dc..53540f8e3 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.PunchCardGraph; 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 class InspectPage extends Page { 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 class InspectPage extends Page { 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 class InspectPage extends Page { 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 1d0d9a7b8..1f0f25b63 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 class ForbiddenResponse extends ErrorResponse { } 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 1ce343236..3aef2ad4c 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 class NotFoundResponse extends ErrorResponse { } 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 218aa20ee..2fa5a07f3 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.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; @@ -25,11 +23,8 @@ import java.net.SocketTimeoutException; 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 abstract class 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 @@ public abstract class WebAPI { 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 @@ public abstract class WebAPI { 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 f61f6eef7..000000000 --- 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 0e4f0a50e..000000000 --- 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 0abc9ccfb..000000000 --- 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 80648ed64..5b5a62961 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 @@ import java.util.UUID; /** * @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 class ConfigurationWebAPI extends WebAPI { } @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 4507dbe65..000000000 --- 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 47f1e50fe..000000000 --- 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 741abac3b..000000000 --- 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 d8b3c317d..000000000 --- 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 b54d10ee0..000000000 --- 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 8161fc5e2..000000000 --- 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 80e9962a5..000000000 --- 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 cb6115685..5130d7b30 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 @@ import java.util.UUID; * * @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 class PostOriginalBukkitSettingsWebAPI extends WebAPI { 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 9fddbc5d3..000000000 --- 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 d62d99633..000000000 --- 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 c3c65eae7..1cbd9a8db 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 class FormatUtils { /** * 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 c3a6d0a60..5c162a208 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 @@ public class 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 2e08101a9..5a788d278 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 class MiscUtils { 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 e2afd52e9..2b3d8a124 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 class AnalysisUtils { 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 c6b550cdd..7bc24d362 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.Arrays; 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 f857d32d7..2c0b84783 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 f1969c196..5078a1433 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 @@ package com.djrapitops.plan.utilities.analysis; 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 class MathUtils { .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 129de42f2..b537e44ce 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 class MapComparator { 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 06c6b8922..2ac257394 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 com.djrapitops.plan.utilities.html.graphs.pie.PieSlice; 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 6ed0c3101..4b5b4c316 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 @@ import java.util.Comparator; /** * @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 519640e9a..16ebaf43b 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 com.djrapitops.plan.data.plugin.PluginData; 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 b26a12adc..90db064d2 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 com.djrapitops.plan.utilities.analysis.Point; 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 d1c90df18..04e8478ad 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 com.djrapitops.plan.data.container.Session; 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 f783df30b..14056d10b 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 com.djrapitops.plan.data.container.Session; 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 40719156d..92a8d4d69 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 class AnalysisExport extends SpecificExport { @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 445fab3cb..c249d37a4 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.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; import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.utility.log.Log; @@ -41,7 +40,7 @@ public class HtmlExport extends SpecificExport { 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 class HtmlExport extends SpecificExport { 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 3d9a50fcc..c70a2a2da 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 class PlayerExport extends SpecificExport { @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 9119838e6..389d76db2 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 @@ public abstract class SpecificExport extends AbsRunnable { .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 6a6f2bdf7..f10aa2af5 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 class HtmlStructure { "})"; } - 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 2b0ecb676..159fa94f5 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.analysis.AnalysisUtils; 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 class SessionTabStructureCreator { 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 27b567d87..000000000 --- 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 000000000..72c6a674e --- /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 344dd382c..000000000 --- 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 000000000..d21c77972 --- /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 02ba41c31..000000000 --- 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 000000000..057cec7b3 --- /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 7a8b208bc..000000000 --- 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 000000000..38a2ec0a6 --- /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 f67591905..000000000 --- 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 95e900a4f..7694d15b8 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 @@ public abstract class Consumer extends AbsRunnable { } } - 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 d434bcf1d..097cc5520 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.api.utility.log.Log; 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 class API { * 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