From 4a82aa82eca1d449ee727b338d37dd8dd91aa612 Mon Sep 17 00:00:00 2001 From: Seren_Modz 21 Date: Wed, 6 Jul 2022 19:07:24 +0100 Subject: [PATCH] :bug: fix server stop bug --- .github/changelog.md | 5 +++++ gradle.properties | 2 +- src/main/java/me/seren/Events.java | 16 +++++++++------- src/main/java/me/seren/KingsWorld.java | 1 - 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/changelog.md b/.github/changelog.md index c953483..2023b6f 100644 --- a/.github/changelog.md +++ b/.github/changelog.md @@ -1,3 +1,8 @@ +# 1.0.0-beta1.2 + +- Fixed issue of server getting stuck on "Thread Query Listener stopped" +- Close all connections that the mod makes + # 1.0.0-beta1.1 - Send player death messages diff --git a/gradle.properties b/gradle.properties index 9ce379d..3ca0872 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ loader_version = 0.14.8 # Mod Properties mod_name = Kings World -mod_version = 1.0.0-beta1.1 +mod_version = 1.0.0-beta1.2 maven_group = me.seren archives_base_name = kings-world diff --git a/src/main/java/me/seren/Events.java b/src/main/java/me/seren/Events.java index bfecd93..d7fe0a4 100644 --- a/src/main/java/me/seren/Events.java +++ b/src/main/java/me/seren/Events.java @@ -2,8 +2,6 @@ import club.minnced.discord.webhook.WebhookClient; import me.seren.discord.Client; -import net.minecraft.advancement.Advancement; -import net.minecraft.advancement.AdvancementDisplay; import net.minecraft.entity.Entity; import net.minecraft.network.message.MessageType; import net.minecraft.network.message.SignedMessage; @@ -15,8 +13,6 @@ import javax.security.auth.login.LoginException; -import java.util.Objects; - import static me.seren.KingsWorld.*; public final class Events { @@ -38,12 +34,18 @@ public static void serverStarted(MinecraftServer server) { Utils.sendDiscordMessage(":white_check_mark: The server has started!"); } - public static void serverStopped(MinecraftServer server) { + public static void serverStopping(MinecraftServer server) { + logger.info("Sending server stopped message to discord"); Utils.sendDiscordMessage(":octagonal_sign: The server has stopped!"); - } - public static void serverStopping(MinecraftServer server) { + logger.info("Deleting all slash commands"); client.jda.updateCommands().queue(); + + logger.info("Closing the webhook connection"); + webhook.close(); + + logger.info("Closing the JDA connection"); + client.jda.shutdown(); } public static void chatMessage(FilteredMessage message, ServerPlayerEntity sender, RegistryKey typeKey) { diff --git a/src/main/java/me/seren/KingsWorld.java b/src/main/java/me/seren/KingsWorld.java index db89be7..0289d24 100644 --- a/src/main/java/me/seren/KingsWorld.java +++ b/src/main/java/me/seren/KingsWorld.java @@ -35,7 +35,6 @@ private void registerEvents() { // fabric-lifecycle-events-v1 ServerLifecycleEvents.SERVER_STARTING.register(Events::serverStarting); ServerLifecycleEvents.SERVER_STARTED.register(Events::serverStarted); - ServerLifecycleEvents.SERVER_STOPPED.register(Events::serverStopped); ServerLifecycleEvents.SERVER_STOPPING.register(Events::serverStopping); // fabric-message-api-v1