Run the STOP event before shutdown, rather than after it.

This commit is contained in:
SquidDev 2018-12-20 18:37:04 +00:00
parent ac954f6e08
commit 9b4050d122
2 changed files with 3 additions and 6 deletions

View file

@ -35,11 +35,8 @@ public class MixinMinecraftServer {
} }
} }
@Inject( @Inject(at = @At("HEAD"), method = "shutdown")
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;exit()V", shift = At.Shift.BY, by = -2, ordinal = 0), public void beforeShutdownServer(CallbackInfo info) {
method = "run"
)
public void beforeExitServer(CallbackInfo info) {
for (Consumer<MinecraftServer> handler : ((HandlerArray<Consumer<MinecraftServer>>) ServerEvent.STOP).getBackingArray()) { for (Consumer<MinecraftServer> handler : ((HandlerArray<Consumer<MinecraftServer>>) ServerEvent.STOP).getBackingArray()) {
handler.accept((MinecraftServer) (Object) this); handler.accept((MinecraftServer) (Object) this);
} }

View file

@ -10,6 +10,6 @@ public class ServerEventMod implements ModInitializer {
@Override @Override
public void onInitialize() { public void onInitialize() {
ServerEvent.START.register(server -> LOGGER.info("Server starting (" + server + ")")); 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 + ")"));
} }
} }