mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Remove onEnable, onDisable and onLoad and replace it with lifecycle events
This commit is contained in:
parent
34d1dfde5e
commit
ac134b84f2
6 changed files with 59 additions and 34 deletions
|
@ -51,6 +51,7 @@ import org.geysermc.floodgate.news.NewsItemAction;
|
|||
import org.geysermc.geyser.api.GeyserApi;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserPostInitializeEvent;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserPreInitializeEvent;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserShutdownEvent;
|
||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
|
@ -167,6 +168,8 @@ public class GeyserImpl implements GeyserApi {
|
|||
this.extensionManager = new GeyserExtensionManager();
|
||||
this.extensionManager.init();
|
||||
|
||||
this.eventBus.fire(new GeyserPreInitializeEvent(this.extensionManager, this.eventBus));
|
||||
|
||||
start();
|
||||
|
||||
GeyserConfiguration config = bootstrap.getGeyserConfig();
|
||||
|
@ -418,7 +421,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
newsHandler.handleNews(null, NewsItemAction.ON_SERVER_STARTED);
|
||||
|
||||
this.eventBus.fire(new GeyserPostInitializeEvent());
|
||||
this.eventBus.fire(new GeyserPostInitializeEvent(this.extensionManager, this.eventBus));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -474,7 +477,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
ResourcePack.PACKS.clear();
|
||||
|
||||
this.eventBus.fire(new GeyserShutdownEvent());
|
||||
this.eventBus.fire(new GeyserShutdownEvent(this.extensionManager, this.commandManager(), this.eventBus));
|
||||
this.extensionManager.disableExtensions();
|
||||
|
||||
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
|
||||
|
|
|
@ -90,9 +90,7 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||
|
||||
private GeyserExtensionContainer setup(Extension extension, GeyserExtensionDescription description, Path dataFolder, ExtensionEventBus eventBus) {
|
||||
GeyserExtensionLogger logger = new GeyserExtensionLogger(GeyserImpl.getInstance().getLogger(), description.name());
|
||||
GeyserExtensionContainer container = new GeyserExtensionContainer(extension, dataFolder, description, this, logger, eventBus);
|
||||
extension.onLoad();
|
||||
return container;
|
||||
return new GeyserExtensionContainer(extension, dataFolder, description, this, logger, eventBus);
|
||||
}
|
||||
|
||||
public GeyserExtensionDescription extensionDescription(Path path) throws InvalidDescriptionException {
|
||||
|
@ -225,15 +223,7 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||
|
||||
@Override
|
||||
protected void setEnabled(@NonNull Extension extension, boolean enabled) {
|
||||
boolean isEnabled = this.extensionContainers.get(extension).enabled;
|
||||
if (isEnabled != enabled) {
|
||||
this.extensionContainers.get(extension).enabled = enabled;
|
||||
if (enabled) {
|
||||
extension.onEnable();
|
||||
} else {
|
||||
extension.onDisable();
|
||||
}
|
||||
}
|
||||
this.extensionContainers.get(extension).enabled = enabled;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue