diff --git a/viafabric-mc1152/src/main/java/com/viaversion/fabric/mc1152/mixin/shutdown/server/MixinMinecraftServer.java b/viafabric-mc1152/src/main/java/com/viaversion/fabric/mc1152/mixin/shutdown/server/MixinMinecraftServer.java new file mode 100644 index 0000000..36f38db --- /dev/null +++ b/viafabric-mc1152/src/main/java/com/viaversion/fabric/mc1152/mixin/shutdown/server/MixinMinecraftServer.java @@ -0,0 +1,34 @@ +/* + * This file is part of ViaFabric - https://github.com/ViaVersion/ViaFabric + * Copyright (C) 2018-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.fabric.mc1152.mixin.shutdown.server; + +import com.viaversion.viaversion.ViaManagerImpl; +import com.viaversion.viaversion.api.Via; +import net.minecraft.server.MinecraftServer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(MinecraftServer.class) +public class MixinMinecraftServer { + @Inject(method = "stop", at = @At("TAIL")) + private void onStop(CallbackInfo ci) { + ((ViaManagerImpl) Via.getManager()).destroy(); + } +} diff --git a/viafabric-mc1152/src/main/resources/fabric.mod.json b/viafabric-mc1152/src/main/resources/fabric.mod.json index 19dd7a7..31d3681 100644 --- a/viafabric-mc1152/src/main/resources/fabric.mod.json +++ b/viafabric-mc1152/src/main/resources/fabric.mod.json @@ -69,7 +69,8 @@ "mixins.viafabric1152.address.json", "mixins.viafabric1152.gui.json", "mixins.viafabric1152.debug.json", - "mixins.viafabric1152.pipeline.json" + "mixins.viafabric1152.pipeline.json", + "mixins.viafabric1152.shutdown.json" ], "custom": { "modmenu": { diff --git a/viafabric-mc1152/src/main/resources/mixins.viafabric1152.shutdown.json b/viafabric-mc1152/src/main/resources/mixins.viafabric1152.shutdown.json new file mode 100644 index 0000000..d022020 --- /dev/null +++ b/viafabric-mc1152/src/main/resources/mixins.viafabric1152.shutdown.json @@ -0,0 +1,13 @@ +{ + "required": true, + "compatibilityLevel": "JAVA_8", + "package": "com.viaversion.fabric.mc1152.mixin.shutdown", + "mixins": [ + ], + "server": [ + "server.MixinMinecraftServer" + ], + "injectors": { + "defaultRequire": 0 + } +}