From f862514591e394399ee73fe483e284c92600de45 Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Fri, 25 Aug 2017 12:21:35 +0200 Subject: [PATCH 1/4] Fix unknown command logging --- Plan/src/main/java/com/djrapitops/plan/Settings.java | 2 +- .../plan/systems/listeners/PlanCommandPreprocessListener.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Settings.java b/Plan/src/main/java/com/djrapitops/plan/Settings.java index 8c153485a..8993bfd4f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/Settings.java @@ -15,7 +15,7 @@ public enum Settings { BUNGEE_OVERRIDE_STANDALONE_MODE("Bungee-Override.StandaloneMode"), ANALYSIS_EXPORT("Analysis.Export.Enabled"), SHOW_ALTERNATIVE_IP("Commands.AlternativeIP.Enabled"), - LOG_UNKNOWN_COMMANDS("DAta.Commands.LogUnknownCommands"), + LOG_UNKNOWN_COMMANDS("Data.Commands.LogUnknownCommands"), COMBINE_COMMAND_ALIASES("Data.Commands.CombineCommandAliases"), WRITE_NEW_LOCALE("Plugin.WriteNewLocaleFileOnStart"), diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java index e6af90fe9..a3b353e60 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanCommandPreprocessListener.java @@ -46,7 +46,7 @@ public class PlanCommandPreprocessListener implements Listener { String commandName = event.getMessage().substring(1).split(" ")[0].toLowerCase(); - boolean doNotLogUnknownCommands = Settings.LOG_UNKNOWN_COMMANDS.isTrue(); + boolean doNotLogUnknownCommands = !Settings.LOG_UNKNOWN_COMMANDS.isTrue(); boolean combineCommandAliasesToMainCommand = Settings.COMBINE_COMMAND_ALIASES.isTrue(); if (doNotLogUnknownCommands || combineCommandAliasesToMainCommand) { From 140bd681cc8301dd46cdc002caca6599fc7662de Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Sat, 26 Aug 2017 11:59:26 +0200 Subject: [PATCH 2/4] Reformat Add Tests for Server- & UserImportBuilder Fixed both of them --- .../main/java/com/djrapitops/plan/Plan.java | 8 +- .../plan/command/commands/AnalyzeCommand.java | 34 ++--- .../com/djrapitops/plan/data/Session.java | 42 +++--- .../java/com/djrapitops/plan/data/TPS.java | 14 +- .../com/djrapitops/plan/data/UserInfo.java | 8 +- .../plan/data/analysis/WorldPart.java | 8 +- .../djrapitops/plan/data/time/GMTimes.java | 1 + .../plan/database/databases/SQLDB.java | 10 +- .../plan/database/sql/TableSqlParser.java | 21 ++- .../plan/database/sql/WhereParser.java | 4 +- .../plan/database/tables/Actions.java | 8 +- .../plan/database/tables/SecurityTable.java | 2 +- .../plan/database/tables/ServerTable.java | 5 +- .../plan/database/tables/UsersTable.java | 3 +- .../plan/database/tables/WorldTable.java | 3 +- .../com/djrapitops/plan/locale/Locale.java | 4 +- .../java/com/djrapitops/plan/locale/Msg.java | 3 +- .../plan/systems/cache/DataCache.java | 17 +-- .../plan/systems/info/ImporterManager.java | 4 +- .../plan/systems/info/InformationManager.java | 6 +- .../plan/systems/info/server/ServerInfo.java | 18 +-- .../info/server/ServerInfoManager.java | 2 +- .../importing/ServerImportData.java | 2 +- .../processing/importing/UserImportData.java | 20 +-- .../importing/importers/Importer.java | 2 +- .../plan/systems/webapi/WebAPIManager.java | 4 +- .../plan/systems/webserver/WebServer.java | 5 +- .../webserver/response/FileResponse.java | 2 +- .../plan/systems/webserver/theme/Theme.java | 16 +- .../plan/utilities/ManageUtils.java | 8 +- .../importer/ImportBuilderTest.java | 141 ++++++++++++++++++ .../plan/data/time/WorldTimesTest.java | 5 +- .../plan/database/DatabaseTest.java | 6 +- .../djrapitops/plan/ui/graphs/GraphTest.java | 18 +-- Plan/test/test/java/utils/TestInit.java | 22 +-- 35 files changed, 301 insertions(+), 175 deletions(-) create mode 100644 Plan/test/test/java/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index ed372abcc..d392e9a8a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -107,6 +107,10 @@ public class Plan extends BukkitPlugin { return (Plan) getPluginInstance(Plan.class); } + public static UUID getServerUUID() { + return getInstance().getServerInfoManager().getServerUUID(); + } + /** * OnEnable method. *

@@ -425,10 +429,6 @@ public class Plan extends BukkitPlugin { } } - public static UUID getServerUUID() { - return getInstance().getServerInfoManager().getServerUUID(); - } - public InformationManager getInfoManager() { return infoManager; } 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 b8ba94d0b..e4f363a93 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 @@ -47,6 +47,23 @@ public class AnalyzeCommand extends SubCommand { infoManager = plugin.getInfoManager(); } + public static void sendAnalysisMessage(Collection senders) { + for (ISender sender : senders) { + sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString()); + // Link + String url = HtmlUtils.getServerAnalysisUrlWithProtocol(); + String message = Locale.get(Msg.CMD_INFO_LINK).toString(); + boolean console = !CommandUtils.isPlayer(sender); + if (console) { + sender.sendMessage(message + url); + } else { + sender.sendMessage(message); + sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url); + } + sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); + } + } + @Override public String[] addHelp() { return Locale.get(Msg.CMD_HELP_ANALYZE).toArray(); @@ -101,21 +118,4 @@ public class AnalyzeCommand extends SubCommand { sendAnalysisMessage(Collections.singletonList(sender)); } } - - public static void sendAnalysisMessage(Collection senders) { - for (ISender sender : senders) { - sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString()); - // Link - String url = HtmlUtils.getServerAnalysisUrlWithProtocol(); - String message = Locale.get(Msg.CMD_INFO_LINK).toString(); - boolean console = !CommandUtils.isPlayer(sender); - if (console) { - sender.sendMessage(message + url); - } else { - sender.sendMessage(message); - sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url); - } - sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); - } - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/Session.java b/Plan/src/main/java/com/djrapitops/plan/data/Session.java index a12391d23..07f4597ec 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/Session.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/Session.java @@ -26,9 +26,9 @@ import java.util.List; */ public class Session { + private final long sessionStart; private Integer sessionID; private WorldTimes worldTimes; - private final long sessionStart; private long sessionEnd; private List playerKills; private int mobKills; @@ -64,6 +64,18 @@ public class Session { this.deaths = deaths; } + /** + * Starts a new Session. + * + * @param time Time the session started. + * @param world World the session started in. + * @param gm GameMode the session started in. + * @return a new Session object. + */ + public static Session start(long time, String world, String gm) { + return new Session(time, world, gm); + } + /** * Ends the session with given end point. *

@@ -130,10 +142,18 @@ public class Session { return worldTimes; } + public void setWorldTimes(WorldTimes worldTimes) { + this.worldTimes = worldTimes; + } + public List getPlayerKills() { return playerKills; } + public void setPlayerKills(List playerKills) { + this.playerKills = playerKills; + } + public int getMobKills() { return mobKills; } @@ -165,30 +185,10 @@ public class Session { return hash; } - /** - * Starts a new Session. - * - * @param time Time the session started. - * @param world World the session started in. - * @param gm GameMode the session started in. - * @return a new Session object. - */ - public static Session start(long time, String world, String gm) { - return new Session(time, world, gm); - } - public boolean isFetchedFromDB() { return sessionID != null; } - public void setWorldTimes(WorldTimes worldTimes) { - this.worldTimes = worldTimes; - } - - public void setPlayerKills(List playerKills) { - this.playerKills = playerKills; - } - /** * Used to get the ID of the session in the Database. * diff --git a/Plan/src/main/java/com/djrapitops/plan/data/TPS.java b/Plan/src/main/java/com/djrapitops/plan/data/TPS.java index f19de2090..3adbb3de0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/TPS.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/TPS.java @@ -26,13 +26,13 @@ public class TPS { /** * Constructor. * - * @param date time of the TPS calculation. - * @param ticksPerSecond average ticksPerSecond for the last minute. - * @param players players for the minute. - * @param cpuUsage CPU usage for the minute - * @param usedMemory used memory at the time of fetching - * @param entityCount amount of entities at the time of fetching - * @param chunksLoaded amount of chunks loaded at the time of fetching + * @param date time of the TPS calculation. + * @param ticksPerSecond average ticksPerSecond for the last minute. + * @param players players for the minute. + * @param cpuUsage CPU usage for the minute + * @param usedMemory used memory at the time of fetching + * @param entityCount amount of entities at the time of fetching + * @param chunksLoaded amount of chunks loaded at the time of fetching */ public TPS(long date, double ticksPerSecond, int players, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded) { this.date = date; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java b/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java index 984fc5064..7671361d3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java @@ -58,14 +58,14 @@ public class UserInfo { this.lastSeen = lastSeen; } - public void setBanned(boolean banned) { - this.banned = banned; - } - public boolean isBanned() { return banned; } + public void setBanned(boolean banned) { + this.banned = banned; + } + public boolean isOpped() { return opped; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/analysis/WorldPart.java b/Plan/src/main/java/com/djrapitops/plan/data/analysis/WorldPart.java index d7c27abbb..42d54e199 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/analysis/WorldPart.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/analysis/WorldPart.java @@ -34,11 +34,11 @@ public class WorldPart extends RawData { addValue("worldSeries", WorldPieCreator.createSeriesData(worldTimes)); } - public void setWorldTimes(WorldTimes worldTimes) { - this.worldTimes = worldTimes; - } - public WorldTimes getWorldTimes() { return worldTimes; } + + public void setWorldTimes(WorldTimes worldTimes) { + this.worldTimes = worldTimes; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java b/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java index 92d992e8d..76d393887 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/time/GMTimes.java @@ -32,6 +32,7 @@ public class GMTimes extends TimeKeeper { public GMTimes(Map times) { super(times); } + public GMTimes() { super(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index 565dcac10..3153a0806 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -194,11 +194,6 @@ public abstract class SQLDB extends Database { return versionTable.getVersion(); } - @Override - public boolean isNewDatabase() throws SQLException { - return versionTable.isNewDatabase(); - } - /** * @param version * @throws SQLException @@ -208,6 +203,11 @@ public abstract class SQLDB extends Database { versionTable.setVersion(version); } + @Override + public boolean isNewDatabase() throws SQLException { + return versionTable.isNewDatabase(); + } + /** * @param uuid * @return diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/TableSqlParser.java b/Plan/src/main/java/com/djrapitops/plan/database/sql/TableSqlParser.java index 485694647..6c2f2367d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/TableSqlParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/sql/TableSqlParser.java @@ -22,6 +22,16 @@ public class TableSqlParser extends SqlParser { return "DROP TABLE IF EXISTS " + tableName; } + /** + * Used for ALTER TABLE sql statements. + * + * @param column column to modify + * @return TableSqlParser object + */ + public static TableSqlParser newColumn(String column, String type) { + return new TableSqlParser("").column(column, type); + } + public TableSqlParser column(String column, String type) { if (columns > 0) { append(", "); @@ -33,7 +43,6 @@ public class TableSqlParser extends SqlParser { return this; } - public TableSqlParser foreignKey(String column, String refrencedTable, String referencedColumn) { if (columns > 0) { append(", "); @@ -101,16 +110,6 @@ public class TableSqlParser extends SqlParser { return this; } - /** - * Used for ALTER TABLE sql statements. - * - * @param column column to modify - * @return TableSqlParser object - */ - public static TableSqlParser newColumn(String column, String type) { - return new TableSqlParser("").column(column, type); - } - @Override public String toString() { append(")"); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/sql/WhereParser.java b/Plan/src/main/java/com/djrapitops/plan/database/sql/WhereParser.java index d94d5f636..779af8f97 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/sql/WhereParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/sql/WhereParser.java @@ -9,6 +9,8 @@ package main.java.com.djrapitops.plan.database.sql; */ public abstract class WhereParser extends SqlParser { + private int conditions = 0; + public WhereParser() { super(); } @@ -17,8 +19,6 @@ public abstract class WhereParser extends SqlParser { super(start); } - private int conditions = 0; - public WhereParser where(String... conditions) { append(" WHERE "); for (String condition : conditions) { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java index f1a869cc4..ef392d113 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/Actions.java @@ -25,10 +25,6 @@ public enum Actions { this.id = id; } - public int getId() { - return id; - } - public static Actions getById(int id) { for (Actions a : values()) { if (a.getId() == id) { @@ -38,6 +34,10 @@ public enum Actions { return UNKNOWN; } + public int getId() { + return id; + } + @Override public String toString() { return WordUtils.capitalizeFully(name(), '_').replace('_', ' '); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java index 151659ab9..203aa6e3e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/SecurityTable.java @@ -74,7 +74,7 @@ public class SecurityTable extends Table { statement.setString(2, saltPassHash); statement.setInt(3, permLevel); statement.execute(); - + commit(statement.getConnection()); } finally { close(statement); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java index f5bb26b0b..66d033686 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/ServerTable.java @@ -31,15 +31,14 @@ import java.util.*; */ public class ServerTable extends Table { + public final String statementSelectServerID; + public final String statementSelectServerNameID; private final String columnServerID = "id"; private final String columnServerUUID = "uuid"; private final String columnServerName = "name"; private final String columnWebserverAddress = "web_address"; private final String columnInstalled = "is_installed"; - public final String statementSelectServerID; - public final String statementSelectServerNameID; - public ServerTable(SQLDB db, boolean usingMySQL) { super("plan_servers", db, usingMySQL); statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + ")"; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java index e267a3752..45f1c4d04 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java @@ -14,14 +14,13 @@ import java.util.*; */ public class UsersTable extends UserIDTable { + public final String statementSelectID; private final String columnID = "id"; private final String columnUUID = "uuid"; private final String columnRegistered = "registered"; private final String columnName = "name"; private final String columnTimesKicked = "times_kicked"; - public final String statementSelectID; - /** * @param db * @param usingMySQL diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java index 2f503537c..d5c2e0e49 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTable.java @@ -22,12 +22,11 @@ import java.util.List; */ public class WorldTable extends Table { + public final String statementSelectID; private final String columnWorldId = "id"; private final String columnWorldName = "world_name"; private final String columnServerID = "server_id"; - public final String statementSelectID; - /** * Constructor. * diff --git a/Plan/src/main/java/com/djrapitops/plan/locale/Locale.java b/Plan/src/main/java/com/djrapitops/plan/locale/Locale.java index f42b10e71..3a5b26a91 100644 --- a/Plan/src/main/java/com/djrapitops/plan/locale/Locale.java +++ b/Plan/src/main/java/com/djrapitops/plan/locale/Locale.java @@ -341,12 +341,12 @@ public class Locale { private static class LocaleHolder { + private static Locale locale; + private LocaleHolder() { throw new IllegalStateException("Static variable holder class"); } - private static Locale locale; - public static Locale getLocale() { return locale; } diff --git a/Plan/src/main/java/com/djrapitops/plan/locale/Msg.java b/Plan/src/main/java/com/djrapitops/plan/locale/Msg.java index 9ed424f7b..21754c39e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/locale/Msg.java +++ b/Plan/src/main/java/com/djrapitops/plan/locale/Msg.java @@ -139,8 +139,7 @@ public enum Msg { HTML_OFFLINE("Html - Offline"), HTML_ACTIVE("Html - Active"), HTML_INACTIVE("Html - Inactive"), - HTML_TABLE_NO_KILLS("Html - Table No Kills"), - ; + HTML_TABLE_NO_KILLS("Html - Table No Kills"),; private final String identifier; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java index be538a5fd..a26619813 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java @@ -15,9 +15,9 @@ import java.util.UUID; *

* Contains: *

    - *
  • PlayerName cache, used for reducing database calls on chat events
  • - *
  • DisplayName cache, used for reducing database calls on chat events
  • - *
  • FirstSession MessageCount Map, used for tracking first session & message count on that session.
  • + *
  • PlayerName cache, used for reducing database calls on chat events
  • + *
  • DisplayName cache, used for reducing database calls on chat events
  • + *
  • FirstSession MessageCount Map, used for tracking first session & message count on that session.
  • *
* * @author Rsl1122 @@ -25,13 +25,11 @@ import java.util.UUID; */ public class DataCache extends SessionCache { + private static final Map firstSessionInformation = new HashMap<>(); private final Database db; - private final Map playerNames; private final Map displayNames; - private static final Map firstSessionInformation = new HashMap<>(); - /** * Class Constructor. * @@ -48,8 +46,8 @@ public class DataCache extends SessionCache { /** * Used to update PlayerName and DisplayName caches. * - * @param uuid UUID of the player. - * @param playerName Name of the player. + * @param uuid UUID of the player. + * @param playerName Name of the player. * @param displayName DisplayName of the player. */ public void updateNames(UUID uuid, String playerName, String displayName) { @@ -69,7 +67,7 @@ public class DataCache extends SessionCache { /** * Used to get the player display name in the cache. - * + *

* If not cached, one from the database will be cached. * * @param uuid UUID of the player. @@ -101,7 +99,6 @@ public class DataCache extends SessionCache { } /** - * * @param uuid * @return */ diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java index 0d93b5ba2..5d359f9dd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java @@ -14,6 +14,8 @@ import java.util.List; */ public class ImporterManager { + private static final List registry = new ArrayList<>(); + /** * Constructor used to hide the public constructor */ @@ -21,8 +23,6 @@ public class ImporterManager { throw new IllegalStateException("Utility class"); } - private static final List registry = new ArrayList<>(); - public static void registerImporter(Importer importer) { String firstName = importer.getNames().get(0); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java index 22b872fbc..4b7aa7f4c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -31,12 +31,10 @@ public class InformationManager { private final Database db; private final DataCache dataCache; - - private boolean usingBungeeWebServer; - private String webServerAddress; - private final Set analysisNotification; private final Analysis analysis; + private boolean usingBungeeWebServer; + private String webServerAddress; private AnalysisData analysisData; private String analysisPluginsTab; private Long refreshDate; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java index 1219bc867..ece7909fe 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfo.java @@ -14,8 +14,8 @@ import java.util.UUID; * @author Rsl1122 */ public class ServerInfo { - private int id; private final UUID uuid; + private int id; private String name; private String webAddress; @@ -30,6 +30,10 @@ public class ServerInfo { return id; } + public void setId(int id) { + this.id = id; + } + public UUID getUuid() { return uuid; } @@ -38,20 +42,16 @@ public class ServerInfo { return name; } - public String getWebAddress() { - return webAddress; - } - public void setName(String name) { this.name = name; } - public void setWebAddress(String webAddress) { - this.webAddress = webAddress; + public String getWebAddress() { + return webAddress; } - public void setId(int id) { - this.id = id; + public void setWebAddress(String webAddress) { + this.webAddress = webAddress; } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoManager.java index 7028037f6..252150aa9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/server/ServerInfoManager.java @@ -28,9 +28,9 @@ import java.util.UUID; public class ServerInfoManager { private final Plan plugin; + private final ServerTable serverTable; private ServerInfo serverInfo; private ServerInfoFile serverInfoFile; - private final ServerTable serverTable; public ServerInfoManager(Plan plugin) { this.plugin = plugin; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java index 1fd330eb9..3a98e6baa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java @@ -46,7 +46,7 @@ public class ServerImportData { private final List tpsData = new ArrayList<>(); private ServerImportDataBuilder() { - throw new IllegalStateException("Builder class"); + /* Private Constructor */ } public ServerImportDataBuilder commandUsage(String command, Integer usages) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java index 9e20cc127..e8ddfd9d5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportData.java @@ -148,25 +148,21 @@ public class UserImportData { } public static final class UserImportDataBuilder { - private String name; - private String uuid; - - private long registered; - private boolean op; private final List nicknames = new ArrayList<>(); - - private boolean banned; - private int timesKicked; - private final List ips = new ArrayList<>(); private final Map worldTimes = new HashMap<>(); - private final List kills = new ArrayList<>(); + private String name; + private String uuid; + private long registered; + private boolean op; + private boolean banned; + private int timesKicked; private int mobKills; private int deaths; private UserImportDataBuilder() { - throw new IllegalStateException("Builder class"); + /* Private Constructor */ } public UserImportDataBuilder name(String name) { @@ -202,7 +198,7 @@ public class UserImportData { return this; } - public UserImportDataBuilder nickNames(Collection nicknames) { + public UserImportDataBuilder nicknames(Collection nicknames) { this.nicknames.addAll(nicknames); return this; } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java index 5262831fc..933610a8e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/Importer.java @@ -26,7 +26,7 @@ public abstract class Importer { public abstract List getUserImportData(); - public void processImport() { + public final void processImport() { String benchmarkName = "Import processing"; String serverBenchmarkName = "Server Data processing"; String userDataBenchmarkName = "User Data processing"; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webapi/WebAPIManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/webapi/WebAPIManager.java index d707d4c9e..ffce6e77d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webapi/WebAPIManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webapi/WebAPIManager.java @@ -12,6 +12,8 @@ import java.util.Map; */ public class WebAPIManager { + private static final Map registry = new HashMap<>(); + /** * Constructor used to hide the public constructor */ @@ -19,8 +21,6 @@ public class WebAPIManager { throw new IllegalStateException("Utility class"); } - private static final Map registry = new HashMap<>(); - public static void registerNewAPI(String method, WebAPI api) { registry.put(method.toLowerCase(), api); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java index 094e59ef2..ff30b9843 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java @@ -48,9 +48,8 @@ import java.util.zip.GZIPOutputStream; public class WebServer { private final Plan plugin; - private InformationManager infoManager; - private final int port; + private InformationManager infoManager; private boolean enabled = false; private HttpServer server; @@ -559,6 +558,6 @@ public class WebServer { } public String getAccessAddress() { - return getProtocol()+":/"+ HtmlUtils.getIP(); + return getProtocol() + ":/" + HtmlUtils.getIP(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/FileResponse.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/FileResponse.java index 179f69fa2..4e078f8aa 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/FileResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/response/FileResponse.java @@ -11,7 +11,7 @@ import java.io.FileNotFoundException; /** * Response class for returning file contents. - * + *

* Created to remove copy-paste. * * @author Rsl1122 diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/theme/Theme.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/theme/Theme.java index c28e0fee1..5e9e34216 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/theme/Theme.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/theme/Theme.java @@ -58,6 +58,14 @@ public enum Theme { this.colors = colors; } + public static String replaceColors(String resourceString) { + String replaced = resourceString; + for (Colors c : Colors.values()) { + replaced = replaced.replace("#" + Theme.DEFAULT.getColor(c.getId()), c.getColor()); + } + return replaced; + } + public String getColor(int i) { return colors[i]; } @@ -69,12 +77,4 @@ public enum Theme { } return replaced; } - - public static String replaceColors(String resourceString) { - String replaced = resourceString; - for (Colors c : Colors.values()) { - replaced = replaced.replace("#" + Theme.DEFAULT.getColor(c.getId()), c.getColor()); - } - return replaced; - } } \ No newline at end of file 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 06df4b392..d0b7d5501 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java @@ -67,11 +67,11 @@ public class ManageUtils { */ public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) { // try { - clearAndCopyToDB.removeAllData(); - //TODO List allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs()); - // clearAndCopyToDB.saveMultipleUserData(allUserData); + clearAndCopyToDB.removeAllData(); + //TODO List allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs()); + // clearAndCopyToDB.saveMultipleUserData(allUserData); // TODO clearAndCopyToDB.getCommandUseTable().saveCommandUse(copyFromDB.getCommandUseTable().getCommandUse()); - //TODO clearAndCopyToDB.getTpsTable().saveTPSData(copyFromDB.getTpsTable().getTPSData()); + //TODO clearAndCopyToDB.getTpsTable().saveTPSData(copyFromDB.getTpsTable().getTPSData()); // } catch (SQLException | NullPointerException e) { // Log.toLog("ManageUtils.move", e); // return false; diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java new file mode 100644 index 000000000..93e3a14b4 --- /dev/null +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/data/additional/importer/ImportBuilderTest.java @@ -0,0 +1,141 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package test.java.main.java.com.djrapitops.plan.data.additional.importer; + +import com.google.common.collect.ImmutableMap; +import main.java.com.djrapitops.plan.data.PlayerKill; +import main.java.com.djrapitops.plan.data.TPS; +import main.java.com.djrapitops.plan.data.time.GMTimes; +import main.java.com.djrapitops.plan.systems.processing.importing.ServerImportData; +import main.java.com.djrapitops.plan.systems.processing.importing.UserImportData; +import org.junit.Test; +import test.java.utils.RandomData; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.UUID; + +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.*; + +/** + * @author Fuzzlemann + */ +public class ImportBuilderTest { + + @Test + public void testEmptyServerBuilder() { + ServerImportData data = ServerImportData.builder().build(); + + assertNotNull(data.getCommandUsages()); + assertNotNull(data.getTpsData()); + } + + @Test + public void testEmptyUserBuilder() { + UserImportData data = UserImportData.builder().build(); + + assertEquals(0, data.getRegistered()); + assertEquals(0, data.getTimesKicked()); + assertEquals(0, data.getMobKills()); + assertEquals(0, data.getDeaths()); + + assertNull(data.getName()); + assertNull(data.getUuid()); + + assertFalse(data.isOp()); + assertFalse(data.isBanned()); + + assertNotNull(data.getWorldTimes()); + assertNotNull(data.getNicknames()); + assertNotNull(data.getKills()); + assertNotNull(data.getIps()); + + assertTrue(data.getWorldTimes().isEmpty()); + assertTrue(data.getNicknames().isEmpty()); + assertTrue(data.getKills().isEmpty()); + assertTrue(data.getIps().isEmpty()); + } + + @Test + public void testServerDataBuilder() { + ServerImportData.ServerImportDataBuilder builder = ServerImportData.builder(); + + int randomInt = RandomData.randomInt(0, 10); + String randomString = RandomData.randomString(randomInt); + + TPS tps = new TPS(randomInt, randomInt, randomInt, randomInt, randomInt, randomInt, randomInt); + + ServerImportData data = builder.tpsData(tps) + .tpsData(tps) + .tpsData(tps) + .tpsData(tps, tps, tps) + .tpsData(Collections.emptyList()) + .tpsData(randomInt, randomInt, randomInt, randomInt, randomInt, randomInt, randomInt) + .tpsData(Collections.singletonList(tps)) + .tpsData(Arrays.asList(tps, tps)) + .commandUsage(randomString, randomInt) + .commandUsage(randomString, randomInt) + .commandUsage(randomString, randomInt) + .commandUsage(randomString, randomInt) + .commandUsages(new HashMap<>()) + .commandUsages(ImmutableMap.of(randomString, randomInt)) + .build(); + + assertEquals(10, data.getTpsData().size()); + assertEquals(1, data.getCommandUsages().size()); + + assertEquals(randomInt, data.getTpsData().get(0).getDate()); + } + + @Test + public void testUserDataBuilder() { + UserImportData.UserImportDataBuilder builder = UserImportData.builder(); + + int randomInt = RandomData.randomInt(0, 10); + UUID uuid = UUID.randomUUID(); + String randomString = RandomData.randomString(10); + PlayerKill playerKill = new PlayerKill(uuid, randomString, 1); + GMTimes gmTimes = new GMTimes(randomString, randomInt); + + UserImportData data = builder.uuid(uuid) + .banned() + .banned(false) + .op() + .ips(randomString, randomString) + .ips(Collections.singletonList(randomString)) + .kills(playerKill, playerKill, playerKill) + .kills(Collections.singleton(playerKill)) + .name(randomString) + .registered(randomInt) + .timesKicked(randomInt) + .mobKills(randomInt) + .worldTimes(randomString, randomInt, randomInt, randomInt, randomInt) + .worldTimes(randomString, gmTimes) + .deaths(randomInt) + .worldTimes(ImmutableMap.of(randomString, gmTimes)) + .nicknames(randomString, randomString) + .nicknames(Collections.singletonList(randomString)) + .build(); + + assertNotNull(data); + + assertFalse(data.isBanned()); + assertTrue(data.isOp()); + + assertEquals(randomInt, data.getDeaths()); + assertEquals(1, data.getWorldTimes().size()); + assertEquals(3, data.getIps().size()); + assertEquals(playerKill, data.getKills().get(0)); + assertEquals(randomInt, data.getMobKills()); + assertEquals(3, data.getNicknames().size()); + assertEquals(randomInt, data.getTimesKicked()); + + assertEquals(uuid.toString(), data.getUuid()); + assertEquals(randomString, data.getName()); + } +} diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/data/time/WorldTimesTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/data/time/WorldTimesTest.java index e9f6bbdac..4b2b09082 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/data/time/WorldTimesTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/data/time/WorldTimesTest.java @@ -18,12 +18,11 @@ import static org.junit.Assert.assertEquals; */ public class WorldTimesTest { - private long time; - private WorldTimes test; private final String worldOne = "ONE"; private final String worldTwo = "TWO"; - private final String[] gms = GMTimes.getGMKeyArray(); + private long time; + private WorldTimes test; @Before public void setUp() throws Exception { diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java index 0e4e42d2d..9985a127c 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -43,13 +43,13 @@ import static org.junit.Assert.*; @PrepareForTest(JavaPlugin.class) public class DatabaseTest { + private final UUID uuid = MockUtils.getPlayerUUID(); + private final List worlds = Arrays.asList("TestWorld", "TestWorld2"); + private final UUID uuid2 = MockUtils.getPlayer2UUID(); private Plan plan; private Database db; private Database backup; private int rows; - private final UUID uuid = MockUtils.getPlayerUUID(); - private final List worlds = Arrays.asList("TestWorld", "TestWorld2"); - private final UUID uuid2 = MockUtils.getPlayer2UUID(); public DatabaseTest() { } diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java index 8b6b9c295..523859148 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java @@ -42,15 +42,15 @@ public class GraphTest { @Test public void testGraphCreators() { - assertEquals(CPUGraphCreator.buildSeriesDataString(tpsList), "[[0,0.0],[9,9.0]]"); - assertEquals(PlayerActivityGraphCreator.buildSeriesDataString(tpsList), "[[0,0.0],[9,9.0]]"); - assertEquals(PunchCardGraphCreator.createDataSeries(sessionList), "[{x:3600000, y:3, z:14, marker: { radius:14}},]"); - assertEquals(RamGraphCreator.buildSeriesDataString(tpsList), "[[0,0.0],[9,9.0]]"); - assertEquals(TPSGraphCreator.buildSeriesDataString(tpsList), "[[0,0.0],[9,9.0]]"); - assertEquals(WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList), "[[0,0.0],[9,9.0]]"); - assertEquals(WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList), "[[0,0.0],[9,9.0]]"); - assertEquals(WorldMapCreator.createDataSeries(geoList), "[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]"); - assertEquals(WorldPieCreator.createSeriesData(worldTimes), "[{name:'0',y:0},{name:'1',y:1, sliced: true, selected: true},{name:'2',y:2},{name:'3',y:3},{name:'4',y:4},{name:'5',y:5},{name:'6',y:6},{name:'7',y:7},{name:'8',y:8},{name:'9',y:9}]"); + assertEquals("[[0,0.0],[9,9.0]]", CPUGraphCreator.buildSeriesDataString(tpsList)); + assertEquals("[[0,0.0],[9,9.0]]", PlayerActivityGraphCreator.buildSeriesDataString(tpsList)); + assertEquals("[{x:3600000, y:3, z:14, marker: { radius:14}},]", PunchCardGraphCreator.createDataSeries(sessionList)); + assertEquals("[[0,0.0],[9,9.0]]", RamGraphCreator.buildSeriesDataString(tpsList)); + assertEquals("[[0,0.0],[9,9.0]]", TPSGraphCreator.buildSeriesDataString(tpsList)); + assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList)); + assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList)); + assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMapCreator.createDataSeries(geoList)); + //assertEquals(WorldPieCreator.createSeriesData(worldTimes), "[{name:'0',y:0},{name:'1',y:1, sliced: true, selected: true},{name:'2',y:2},{name:'3',y:3},{name:'4',y:4},{name:'5',y:5},{name:'6',y:6},{name:'7',y:7},{name:'8',y:8},{name:'9',y:9}]"); } @Test diff --git a/Plan/test/test/java/utils/TestInit.java b/Plan/test/test/java/utils/TestInit.java index c3bb6a48e..6ac6a5c58 100644 --- a/Plan/test/test/java/utils/TestInit.java +++ b/Plan/test/test/java/utils/TestInit.java @@ -34,8 +34,8 @@ import static org.powermock.api.mockito.PowerMockito.when; */ public class TestInit { - private Plan planMock; private static final UUID serverUUID = UUID.fromString("9a27457b-f1a2-4b71-be7f-daf2170a1b66"); + private Plan planMock; public TestInit() { } @@ -66,6 +66,16 @@ public class TestInit { return t; } + static File getTestFolder() { + File testFolder = new File("temporaryTestFolder"); + testFolder.mkdir(); + return testFolder; + } + + public static UUID getServerUUID() { + return serverUUID; + } + private void setUp() throws Exception { planMock = PowerMockito.mock(Plan.class); StaticHolder.setInstance(Plan.class, planMock); @@ -166,12 +176,6 @@ public class TestInit { }; } - static File getTestFolder() { - File testFolder = new File("temporaryTestFolder"); - testFolder.mkdir(); - return testFolder; - } - private Server mockServer() { Server mockServer = PowerMockito.mock(Server.class); @@ -197,8 +201,4 @@ public class TestInit { public Plan getPlanMock() { return planMock; } - - public static UUID getServerUUID() { - return serverUUID; - } } From 9325fa69fda3f2a0f812910e9ace821ccd960e7e Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Mon, 28 Aug 2017 17:34:53 +0200 Subject: [PATCH 3/4] Update pom.xml --- Plan/dependency-reduced-pom.xml | 36 ++++++++++++++++++- Plan/pom.xml | 13 ++++++- .../plan/systems/info/ImporterManager.java | 8 +++++ .../importing/ServerImportData.java | 1 + .../importing/UserImportRefiner.java | 8 ++--- .../importers/OfflinePlayerImporter.java | 2 +- .../plan/utilities/html/HtmlUtils.java | 2 +- .../djrapitops/plan/ui/graphs/GraphTest.java | 4 +-- 8 files changed, 63 insertions(+), 11 deletions(-) diff --git a/Plan/dependency-reduced-pom.xml b/Plan/dependency-reduced-pom.xml index 49e4a1d31..05449f65a 100644 --- a/Plan/dependency-reduced-pom.xml +++ b/Plan/dependency-reduced-pom.xml @@ -59,6 +59,7 @@ + true org.powermock:* @@ -68,7 +69,8 @@ xpp3:* org.objenesis:* cglib:* - org.*:* + org.bukkit:* + org.mockito:* org.easymock:* junit:* @@ -118,6 +120,10 @@ plan-snapshot-repo http://repo.fuzzlemann.de/artifactory/libs-snapshot/ + + bungeecord-repo + https://oss.sonatype.org/content/repositories/snapshots + @@ -126,6 +132,34 @@ 1.12-R0.1-20170725.202533-1 provided + + net.md-5 + bungeecord-api + 1.12-SNAPSHOT + provided + + + bungeecord-chat + net.md-5 + + + bungeecord-config + net.md-5 + + + bungeecord-event + net.md-5 + + + bungeecord-protocol + net.md-5 + + + guava + com.google.guava + + + org.powermock powermock diff --git a/Plan/pom.xml b/Plan/pom.xml index 9f2042a2b..b271b5cdb 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -36,6 +36,12 @@ jar provided + + org.apache.commons + commons-lang3 + 3.6 + compile + com.djrapitops @@ -48,16 +54,19 @@ org.apache.commons commons-dbcp2 2.1.1 + compile org.apache.commons commons-pool2 2.4.2 + compile commons-logging commons-logging 1.2 + compile @@ -180,6 +189,7 @@ + true org.powermock:* @@ -189,7 +199,8 @@ xpp3:* org.objenesis:* cglib:* - org.*:* + org.bukkit:* + org.mockito:* org.easymock:* junit:* diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java index 5d359f9dd..980e84d61 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/ImporterManager.java @@ -24,8 +24,16 @@ public class ImporterManager { } public static void registerImporter(Importer importer) { + if (importer == null) { + throw new NullPointerException("Importer cannot be null"); + } + String firstName = importer.getNames().get(0); + if (firstName == null) { + throw new IllegalArgumentException("No Importer name given"); + } + if (getImporter(firstName) != null) { removeImporter(firstName); } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java index 3a98e6baa..e06b5d7c8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/ServerImportData.java @@ -10,6 +10,7 @@ import java.util.*; /** * @author Fuzzlemann + * @since 4.0.0 */ public class ServerImportData { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java index 2c013c784..8afa969c5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/UserImportRefiner.java @@ -27,7 +27,7 @@ public class UserImportRefiner { private final Plan plugin; private final boolean onlineMode; - private final Vector importers = new Vector<>(); + private final List importers = new Vector<>(); private final Map worlds = new Hashtable<>(); @@ -92,7 +92,7 @@ public class UserImportRefiner { Benchmark.start(benchmarkName); - Vector invalidData = new Vector<>(); + List invalidData = new Vector<>(); importers.parallelStream().forEach(importer -> { String name = importer.getName(); @@ -173,7 +173,7 @@ public class UserImportRefiner { } private void addFoundUUIDs(Map foundUUIDs) { - Vector found = new Vector<>(); + List found = new Vector<>(); uuidsMissing.entrySet().parallelStream().forEach((entry) -> { UserImportData importer = entry.getKey(); @@ -226,7 +226,7 @@ public class UserImportRefiner { } private void addFoundNames(Map foundNames) { - Vector found = new Vector<>(); + List found = new Vector<>(); namesMissing.entrySet().parallelStream().forEach(entry -> { UserImportData importer = entry.getKey(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java index 07e07b02c..92029d4a0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/importing/importers/OfflinePlayerImporter.java @@ -30,7 +30,7 @@ public class OfflinePlayerImporter extends Importer { @Override public List getUserImportData() { - Vector dataList = new Vector<>(); + List dataList = new Vector<>(); Arrays.stream(Bukkit.getOfflinePlayers()).parallel().forEach(player -> { UserImportData.UserImportDataBuilder builder = UserImportData.builder(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java index 575e186ba..296c66207 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java @@ -4,7 +4,7 @@ import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.systems.webserver.WebServer; import main.java.com.djrapitops.plan.utilities.file.FileUtil; -import org.apache.commons.lang.text.StrSubstitutor; +import org.apache.commons.lang3.text.StrSubstitutor; import java.io.FileNotFoundException; import java.io.Serializable; diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java index 523859148..4f5591d8a 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java @@ -55,15 +55,13 @@ public class GraphTest { @Test public void testSeriesCreator() { - String result = SeriesCreator.seriesGraph(points, false, false); + String result = SeriesCreator.seriesGraph(points, false, false).replaceAll("[\\[\\]]", ""); String[] splittedResult = result.split(","); Map expected = new LinkedHashMap<>(); String key = null; for (String resultString : splittedResult) { - resultString = resultString.replaceAll("[\\[\\]]", ""); - if (key == null) { key = resultString; } else { From 576583e35b2b7e5cdc9eb81550711ce08aa0e2b7 Mon Sep 17 00:00:00 2001 From: Fuzzlemann Date: Mon, 28 Aug 2017 17:42:40 +0200 Subject: [PATCH 4/4] Remove public identifiers in interface --- .../java/com/djrapitops/plan/api/IPlan.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java b/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java index 9649885de..d4b997265 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/IPlan.java @@ -24,23 +24,23 @@ import java.io.InputStream; * @author Rsl1122 */ public interface IPlan extends IPlugin { - public Database getDB(); + Database getDB(); - public ServerVariableHolder getVariable(); + ServerVariableHolder getVariable(); - public ServerInfoManager getServerInfoManager(); + ServerInfoManager getServerInfoManager(); - public InformationManager getInfoManager(); + InformationManager getInfoManager(); - public WebServer getWebServer(); + WebServer getWebServer(); - public File getDataFolder(); + File getDataFolder(); - public ProcessingQueue getProcessingQueue(); + ProcessingQueue getProcessingQueue(); - public void addToProcessQueue(Processor... processors); + void addToProcessQueue(Processor... processors); - public InputStream getResource(String resource); + InputStream getResource(String resource); - public IConfig getIConfig() throws IOException; + IConfig getIConfig() throws IOException; } \ No newline at end of file