diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 3d1cdcace..3512ef11d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -22,29 +22,24 @@ import org.bukkit.scheduler.BukkitRunnable; /* TODO 2.1.0 Placeholder API - Html getter without webserver - Webserver off setting Immutable InspectCache ? - Join-leavers to activity pie. Recent players - Customizability - Colors, chat, analysis - Demographics triggers Optimize db with batch processing (commanduse, ips, nicks) Manage command Database cleaning - Server & user data saved seperately with different times - Alternative ip & webserver off check warning, check for PlanLite too. - Fix PlanLite balance. PlanLite Top 20 richest PlanLite Top 20 most votes Top 20 most active Clear setting multiper (InspectCache) Clear check for existing clear task. (InspectCache) -ErrorManager - (Alternative ui) ? Push data to PlanLite (setting) - DataBase init message + Update Version checker so it doesn't fail */ + +/** + * + * @author Rsl1122 + */ + public class Plan extends JavaPlugin { private API api; @@ -56,6 +51,11 @@ public class Plan extends JavaPlugin { private HashSet databases; private WebSocketServer uiServer; + /** + * OnEnable method. + * + * Initiates the plugin with database, webserver, commands & listeners. + */ @Override public void onEnable() { getDataFolder().mkdirs(); @@ -126,6 +126,9 @@ public class Plan extends JavaPlugin { log("Player Analytics Enabled."); } + /** + * Hooks PlanLite for UI and/or additional data. + */ public void hookPlanLite() { try { planLiteHook = new PlanLiteHook(this); @@ -134,9 +137,16 @@ public class Plan extends JavaPlugin { } } + /** + * Disables the plugin. + * + * Stops the webserver, cancels all tasks and saves cache to the database. * + */ @Override public void onDisable() { - uiServer.stop(); + if (uiServer != null) { + uiServer.stop(); + } Bukkit.getScheduler().cancelTasks(this); if (handler != null) { log("Saving cached data.."); @@ -150,14 +160,25 @@ public class Plan extends JavaPlugin { log("Player Analytics Disabled."); } + /** + * Logs the message to the console. + * @param message + */ public void log(String message) { getLogger().info(message); } + /** + * Logs an error message to the console. + * @param message + */ public void logError(String message) { getLogger().severe(message); } + /** + * @return Plan API + */ public API getAPI() { return api; } @@ -200,26 +221,44 @@ public class Plan extends JavaPlugin { return true; } + /** + * @return Currnet instance of the AnalysisCacheHandler + */ public AnalysisCacheHandler getAnalysisCache() { return analysisCache; } + /** + * @return Currnet instance of the InspectCacheHandler + */ public InspectCacheHandler getInspectCache() { return inspectCache; } + /** + * @return Currnet instance of the DataCacheHandler + */ public DataCacheHandler getHandler() { return handler; } + /** + * @return PlanLiteHook + */ public PlanLiteHook getPlanLiteHook() { return planLiteHook; } + /** + * @return the Database + */ public Database getDB() { return db; } + /** + * @return the Webserver + */ public WebSocketServer getUiServer() { return uiServer; } 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 a74ef3435..05e2eaf9c 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 @@ -21,6 +21,7 @@ import static org.bukkit.Bukkit.getOfflinePlayer; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; +import static org.bukkit.Bukkit.getOfflinePlayer; /** * 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 88475f14f..2da6fc1ac 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -78,13 +78,16 @@ public class FormatUtils { * @return parsed double - for example 1,11 * @throws NumberFormatException When wrong format */ - public static double parseVersionDouble(String versionString) throws NumberFormatException { + public static int parseVersionNumber(String versionString) throws NumberFormatException { String[] versionArray = versionString.split("\\."); if (versionArray.length != 3) { throw new NumberFormatException("Wrong format used"); } - double versionDouble = Double.parseDouble(versionArray[0] + "." + versionArray[1] + versionArray[2]); - return versionDouble; + int main = Integer.parseInt(versionArray[0]) * 100; + int major = Integer.parseInt(versionArray[1]) * 10; + int minor = Integer.parseInt(versionArray[2]); + int versionNumber = main + major + minor; + return versionNumber; } /** 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 ad8c37638..cba77d343 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -42,9 +42,9 @@ public class MiscUtils { } } String versionString = lineWithVersion.split(": ")[1]; - double newestVersionNumber = FormatUtils.parseVersionDouble(versionString); + int newestVersionNumber = FormatUtils.parseVersionNumber(versionString); cVersion = plugin.getDescription().getVersion(); - double currentVersionNumber = FormatUtils.parseVersionDouble(cVersion); + int currentVersionNumber = FormatUtils.parseVersionNumber(cVersion); if (newestVersionNumber > currentVersionNumber) { return "New Version (" + versionString + ") is availible at https://www.spigotmc.org/resources/plan-player-analytics.32536/"; } else { diff --git a/Plan/src/main/resources/plugin.yml b/Plan/src/main/resources/plugin.yml index 31a64b5c8..02fe49b5a 100644 --- a/Plan/src/main/resources/plugin.yml +++ b/Plan/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.Plan -version: 2.1.0 +version: 2.1.1 commands: plan: