Skip to content

Commit

Permalink
Added createTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed May 16, 2023
1 parent a51bad0 commit 7edc00d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike, Regist
*/
private final ListMap<LifecyclePosition, Runnable> afterLoad = new ListMap<>();

/**
* The tasks to run on task creation.
*/
private final ListMap<LifecyclePosition, Runnable> createTasks = new ListMap<>();

/**
* Create a new plugin.
* <p>
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -745,6 +754,15 @@ protected void handleReload() {

}

/**
* The plugin-specific code to create tasks.
* <p>
* Override when needed.
*/
protected void createTasks() {

}

/**
* The plugin-specific code to be executed after the server is up.
* <p>
Expand Down

0 comments on commit 7edc00d

Please sign in to comment.