From 8f6b196b604f24340aa0697bbcfe86bb9116eb23 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 13 Jan 2018 13:51:52 +0200 Subject: [PATCH] Moved task system --- Plan/src/main/java/com/djrapitops/plan/Plan.java | 3 ++- Plan/src/main/java/com/djrapitops/plan/PlanBungee.java | 2 +- .../java/com/djrapitops/plan/system/PlanSystem.java | 8 ++++++++ .../plan/system/listeners/ListenerSystem.java | 8 ++++++++ .../system/listeners/bukkit/PlayerOnlineListener.java | 2 +- .../tasks/BukkitTaskSystem.java} | 4 ++-- .../tasks/BungeeTaskSystem.java} | 4 ++-- .../plan/{systems => system}/tasks/TPSCountTimer.java | 2 +- .../plan/{systems => system}/tasks/TaskSystem.java | 7 ++++--- .../main/java/com/djrapitops/plan/systems/Systems.java | 10 +++++----- .../plan/systems/info/InformationManager.java | 1 + .../djrapitops/plan/utilities/analysis/Analysis.java | 6 +++--- .../plan/utilities/html/graphs/line/RamGraph.java | 2 +- .../utilities/html/graphs/line/WorldLoadGraph.java | 2 +- 14 files changed, 40 insertions(+), 21 deletions(-) rename Plan/src/main/java/com/djrapitops/plan/{systems/tasks/PlanTaskSystem.java => system/tasks/BukkitTaskSystem.java} (97%) rename Plan/src/main/java/com/djrapitops/plan/{systems/tasks/PlanBungeeTaskSystem.java => system/tasks/BungeeTaskSystem.java} (93%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/tasks/TPSCountTimer.java (99%) rename Plan/src/main/java/com/djrapitops/plan/{systems => system}/tasks/TaskSystem.java (86%) diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 09b621232..3e5855bb1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -47,7 +47,7 @@ import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.ImporterManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plan.utilities.metrics.BStats; import com.djrapitops.plugin.BukkitPlugin; @@ -357,6 +357,7 @@ public class Plan extends BukkitPlugin implements PlanPlugin { return ConfigSystem.getInstance().getConfig(); } + @Deprecated public InformationManager getInfoManager() { return infoManager; } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java index 28545d4e8..130b30457 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanBungee.java @@ -24,7 +24,7 @@ import com.djrapitops.plan.systems.Systems; import com.djrapitops.plan.systems.info.BungeeInformationManager; import com.djrapitops.plan.systems.info.InformationManager; import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.file.export.HtmlExport; import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.StaticHolder; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 774e19194..b6ea59b9d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -10,6 +10,7 @@ import com.djrapitops.plan.system.file.FileSystem; import com.djrapitops.plan.system.listeners.ListenerSystem; import com.djrapitops.plan.system.processing.ProcessingQueue; import com.djrapitops.plan.system.settings.config.ConfigSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Check; @@ -33,6 +34,7 @@ public abstract class PlanSystem implements SubSystem { protected DBSystem databaseSystem; protected ListenerSystem listenerSystem; + protected TaskSystem taskSystem; public PlanSystem() { processingQueue = new ProcessingQueue(); @@ -48,12 +50,14 @@ public abstract class PlanSystem implements SubSystem { databaseSystem.enable(); processingQueue.enable(); listenerSystem.enable(); + taskSystem.enable(); } @Override public void disable() { processingQueue.disable(); databaseSystem.disable(); + taskSystem.disable(); configSystem.disable(); fileSystem.disable(); versionCheckSystem.disable(); @@ -114,4 +118,8 @@ public abstract class PlanSystem implements SubSystem { public ListenerSystem getListenerSystem() { return listenerSystem; } + + public TaskSystem getTaskSystem() { + return taskSystem; + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java index 4b4e717d1..486dfe459 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/ListenerSystem.java @@ -1,10 +1,18 @@ package com.djrapitops.plan.system.listeners; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; +import com.djrapitops.plan.utilities.NullCheck; import com.djrapitops.plugin.api.Benchmark; public abstract class ListenerSystem implements SubSystem { + public static ListenerSystem getInstance() { + ListenerSystem listenerSystem = PlanSystem.getInstance().getListenerSystem(); + NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized.")); + return listenerSystem; + } + @Override public void enable() { Benchmark.start("Register Listeners"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java index 2a5aa8582..eaa6b9f34 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/bukkit/PlayerOnlineListener.java @@ -5,7 +5,7 @@ import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor; import com.djrapitops.plan.system.processing.processors.player.*; import com.djrapitops.plan.systems.cache.DataCache; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plugin.api.systems.NotificationCenter; import com.djrapitops.plugin.api.utility.log.Log; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java similarity index 97% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java index 1b843a8eb..46d2b2d3f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BukkitTaskSystem.java @@ -2,7 +2,7 @@ * Licence is provided in the jar as license.yml also here: * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml */ -package com.djrapitops.plan.systems.tasks; +package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.Plan; import com.djrapitops.plan.settings.locale.Locale; @@ -21,7 +21,7 @@ import com.djrapitops.plugin.task.RunnableFactory; * * @author Rsl1122 */ -public class PlanTaskSystem extends TaskSystem { +public class BukkitTaskSystem extends TaskSystem { // TODO Remove Plan.getInstance requirement. diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java similarity index 93% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java index 74bbb617d..dcdc15a1b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/PlanBungeeTaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/BungeeTaskSystem.java @@ -2,7 +2,7 @@ * Licence is provided in the jar as license.yml also here: * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml */ -package com.djrapitops.plan.systems.tasks; +package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.PlanBungee; import com.djrapitops.plan.systems.info.BungeeInformationManager; @@ -14,7 +14,7 @@ import com.djrapitops.plugin.task.AbsRunnable; * * @author Rsl1122 */ -public class PlanBungeeTaskSystem extends TaskSystem { +public class BungeeTaskSystem extends TaskSystem { @Override public void enable() { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java similarity index 99% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java index c41d2fc0b..fd1a324da 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TPSCountTimer.java @@ -1,4 +1,4 @@ -package com.djrapitops.plan.systems.tasks; +package com.djrapitops.plan.system.tasks; import com.djrapitops.plan.Plan; import com.djrapitops.plan.PlanBungee; diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java similarity index 86% rename from Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java rename to Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java index ff64d92ca..8cc02c086 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/tasks/TaskSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/TaskSystem.java @@ -2,10 +2,11 @@ * Licence is provided in the jar as license.yml also here: * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml */ -package com.djrapitops.plan.systems.tasks; +package com.djrapitops.plan.system.tasks; +import com.djrapitops.plan.PlanPlugin; +import com.djrapitops.plan.system.PlanSystem; import com.djrapitops.plan.system.SubSystem; -import com.djrapitops.plan.systems.Systems; import com.djrapitops.plugin.api.systems.TaskCenter; import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.IRunnable; @@ -21,7 +22,7 @@ public abstract class TaskSystem implements SubSystem { protected TPSCountTimer tpsCountTimer; public static TaskSystem getInstance() { - return Systems.getInstance().getTaskSystem(); + return PlanSystem.getInstance().getTaskSystem(); } protected IRunnable registerTask(AbsRunnable runnable) { diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java index 8f843b8eb..b0d9dd2ca 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/Systems.java @@ -17,9 +17,9 @@ import com.djrapitops.plan.system.settings.config.BungeeConfigSystem; import com.djrapitops.plan.system.settings.config.ConfigSystem; import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.webserver.WebServerSystem; -import com.djrapitops.plan.systems.tasks.PlanBungeeTaskSystem; -import com.djrapitops.plan.systems.tasks.PlanTaskSystem; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.BungeeTaskSystem; +import com.djrapitops.plan.system.tasks.BukkitTaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plugin.api.utility.log.Log; import org.apache.commons.lang3.ArrayUtils; @@ -52,7 +52,7 @@ public class Systems { databaseSystem = new BukkitDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); - taskSystem = new PlanTaskSystem(); + taskSystem = new BukkitTaskSystem(); webServerSystem = new WebServerSystem(); themeSystem = new Theme(); @@ -69,7 +69,7 @@ public class Systems { databaseSystem = new BungeeDBSystem(); versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); - taskSystem = new PlanBungeeTaskSystem(); + taskSystem = new BungeeTaskSystem(); webServerSystem = new WebServerSystem(); themeSystem = new Theme(); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java index e30474271..11e39f7f3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/InformationManager.java @@ -21,6 +21,7 @@ import java.util.*; * * @author Rsl1122 */ +@Deprecated public abstract class InformationManager { boolean usingAnotherWebServer; String webServerAddress; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index d7ae999e7..ee191dd8b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -16,8 +16,8 @@ import com.djrapitops.plan.systems.cache.DataCache; import com.djrapitops.plan.systems.cache.SessionCache; import com.djrapitops.plan.systems.info.BukkitInformationManager; import com.djrapitops.plan.systems.info.InformationManager; -import com.djrapitops.plan.systems.tasks.PlanTaskSystem; -import com.djrapitops.plan.systems.tasks.TaskSystem; +import com.djrapitops.plan.system.tasks.BukkitTaskSystem; +import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plugin.api.utility.log.Log; @@ -55,7 +55,7 @@ public class Analysis { return; } - ((PlanTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis(); + ((BukkitTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis(); Benchmark.start("Analysis"); log(Locale.get(Msg.ANALYSIS_START).toString()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java index 71340d85e..61ef570a6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/RamGraph.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.utilities.html.graphs.line; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.systems.tasks.TPSCountTimer; +import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plan.utilities.analysis.Point; import java.util.List; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java index 096474380..40cee358c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/line/WorldLoadGraph.java @@ -1,7 +1,7 @@ package com.djrapitops.plan.utilities.html.graphs.line; import com.djrapitops.plan.data.container.TPS; -import com.djrapitops.plan.systems.tasks.TPSCountTimer; +import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plan.utilities.analysis.Point; import java.util.List;