From 7edc00d45904758345f2a3b03aa6aa6ffbaeed84 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 16 May 2023 14:50:02 +0100 Subject: [PATCH] Added createTasks --- .../java/com/willfp/eco/core/EcoPlugin.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java index 8cfb048a7..88b18f2aa 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java +++ b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java @@ -164,6 +164,11 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist */ private final ListMap afterLoad = new ListMap<>(); + /** + * The tasks to run on task creation. + */ + private final ListMap createTasks = new ListMap<>(); + /** * Create a new plugin. *

@@ -632,6 +637,10 @@ public final void reload(final boolean cancelTasks) { this.handleLifecycle(this.onReload, this::handleReload); + if (cancelTasks) { + this.handleLifecycle(this.createTasks, this::createTasks); + } + for (Extension extension : this.extensionLoader.getLoadedExtensions()) { extension.handleReload(); } @@ -745,6 +754,15 @@ protected void handleReload() { } + /** + * The plugin-specific code to create tasks. + *

+ * Override when needed. + */ + protected void createTasks() { + + } + /** * The plugin-specific code to be executed after the server is up. *