fix: ondisable not called properly

This commit is contained in:
iceBear67 committed 2024-09-02 01:46:03 +08:00
1 parent 7c3abc0ffd
commit eec84d7dba
4 files changed
+62 -1

No files matched your search

@@ -1,6 +1,9 @@
package io.ib67.sfcraft;
public interface Lifecycle {
/**
* Invoke at ModInit (registries are open, etc.)
*/
void onInitialize();
void onStateChange(State state);
@@ -70,6 +70,11 @@ public class SFCraftInitializer extends GuiceModInitializer {
log.info("Load completed! " + getModuleManager().getModules().size() + " modules were loaded.");
}
@Override
protected void onStopping(MinecraftServer minecraftServer) {
getModuleManager().switchGlobalState(Lifecycle.State.DISABLED);
}
@Override
protected Injector onInit() {
SFEntityType.registerEntities();
@@ -23,10 +23,17 @@ public abstract class ServerModule extends AbstractModule implements Lifecycle {
}
}
/**
* Often called when server is shutting down. Can also be triggered by manual operation
*/
public void onDisable() {
}
/**
* Often called when server is starting. Can also be triggered by manual operation
* In this phase you can access MinecraftServer via {@link io.ib67.sfcraft.inject.MinecraftServerSupplier}, which is injectable.
*/
public void onEnable() {
}