mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-21 15:02:15 +00:00
Add extra listener for server stopped event (#4281)
This commit is contained in:
3 files changed
+34
No files matched your search
@@ -133,6 +133,7 @@ public final class LPFabricBootstrap extends MinecraftLuckPermsBootstrap impleme
|
||||
// Register the Server startup/shutdown events now
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(this::onServerStarting);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(this::onServerStopping);
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(this::onServerStopped);
|
||||
this.plugin.registerFabricListeners();
|
||||
}
|
||||
|
||||
@@ -147,6 +148,15 @@ public final class LPFabricBootstrap extends MinecraftLuckPermsBootstrap impleme
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
private void onServerStopped(MinecraftServer server) {
|
||||
if (this.server == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin.disable();
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountDownLatch getLoadLatch() {
|
||||
return this.loadLatch;
|
||||
|
||||
@@ -38,6 +38,7 @@ import me.lucko.luckperms.common.util.BuildInfo;
|
||||
import net.luckperms.api.platform.Platform;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.event.server.ServerAboutToStartEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppedEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.listener.EventListener;
|
||||
@@ -185,6 +186,17 @@ public final class LPForgeBootstrap extends MinecraftLuckPermsBootstrap implemen
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = Priority.LOWEST)
|
||||
public void onServerStopped(ServerStoppedEvent event) {
|
||||
if (this.server == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin.disable();
|
||||
unregisterListeners();
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountDownLatch getLoadLatch() {
|
||||
return this.loadLatch;
|
||||
|
||||
@@ -45,6 +45,7 @@ import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
import net.neoforged.neoforgespi.language.IModInfo;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -173,6 +174,17 @@ public final class LPNeoForgeBootstrap extends MinecraftLuckPermsBootstrap imple
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onServerStopped(ServerStoppedEvent event) {
|
||||
if (this.server == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin.disable();
|
||||
this.forgeEventBus.unregisterAll();
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountDownLatch getLoadLatch() {
|
||||
return this.loadLatch;
|
||||
|
||||
Reference in new issue
Block a user