From 9b4050d122b0447b322322f26d8817aaec337116 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 20 Dec 2018 18:37:04 +0000 Subject: [PATCH] Run the STOP event before shutdown, rather than after it. --- .../fabric/mixin/events/server/MixinMinecraftServer.java | 7 ++----- .../java/net/fabricmc/fabric/events/ServerEventMod.java | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/fabricmc/fabric/mixin/events/server/MixinMinecraftServer.java b/src/main/java/net/fabricmc/fabric/mixin/events/server/MixinMinecraftServer.java index ce4689aab..3c8c6ea0b 100644 --- a/src/main/java/net/fabricmc/fabric/mixin/events/server/MixinMinecraftServer.java +++ b/src/main/java/net/fabricmc/fabric/mixin/events/server/MixinMinecraftServer.java @@ -35,11 +35,8 @@ public class MixinMinecraftServer { } } - @Inject( - at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;exit()V", shift = At.Shift.BY, by = -2, ordinal = 0), - method = "run" - ) - public void beforeExitServer(CallbackInfo info) { + @Inject(at = @At("HEAD"), method = "shutdown") + public void beforeShutdownServer(CallbackInfo info) { for (Consumer handler : ((HandlerArray>) ServerEvent.STOP).getBackingArray()) { handler.accept((MinecraftServer) (Object) this); } diff --git a/src/test/java/net/fabricmc/fabric/events/ServerEventMod.java b/src/test/java/net/fabricmc/fabric/events/ServerEventMod.java index 910df8f12..df2e61bea 100644 --- a/src/test/java/net/fabricmc/fabric/events/ServerEventMod.java +++ b/src/test/java/net/fabricmc/fabric/events/ServerEventMod.java @@ -10,6 +10,6 @@ public class ServerEventMod implements ModInitializer { @Override public void onInitialize() { ServerEvent.START.register(server -> LOGGER.info("Server starting (" + server + ")")); - ServerEvent.STOP.register(server -> LOGGER.info("Server stopped (" + server + ")")); + ServerEvent.STOP.register(server -> LOGGER.info("Server stopping (" + server + ")")); } }