Added Extension#onAfterLoad and Extension#onReload

This commit is contained in:
Auxilor
2021-11-08 14:04:24 +00:00
parent 830f92bbdb
commit 40020b0503
3 changed files with 37 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import com.willfp.eco.core.config.updating.ConfigHandler;
import com.willfp.eco.core.display.Display;
import com.willfp.eco.core.display.DisplayModule;
import com.willfp.eco.core.events.EventManager;
import com.willfp.eco.core.extensions.Extension;
import com.willfp.eco.core.extensions.ExtensionLoader;
import com.willfp.eco.core.factory.MetadataValueFactory;
import com.willfp.eco.core.factory.NamespacedKeyFactory;
@@ -469,6 +470,10 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
this.reload();
for (Extension extension : this.getExtensionLoader().getLoadedExtensions()) {
extension.handleAfterLoad();
}
this.getLogger().info("Loaded " + this.color + this.getName());
}
@@ -483,6 +488,10 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
this.getScheduler().cancelAll();
this.handleReload();
for (Extension extension : this.extensionLoader.getLoadedExtensions()) {
extension.handleReload();
}
}
/**

View File

@@ -57,6 +57,20 @@ public abstract class Extension implements PluginLike {
this.onDisable();
}
/**
* Method to handle after load.
*/
public final void handleAfterLoad() {
this.onAfterLoad();
}
/**
* Method to handle plugin reloads.
*/
public final void handleReload() {
this.onReload();
}
/**
* Called on enabling Extension.
*/
@@ -67,6 +81,16 @@ public abstract class Extension implements PluginLike {
*/
protected abstract void onDisable();
/**
* Called the once the base plugin is done loading.
*/
protected abstract void onAfterLoad();
/**
* Called on plugin reload.
*/
protected abstract void onReload();
/**
* Set the metadata of the extension.
* <p>