From c6e5549fa92dc72de70fe40fce3f7955958e6eb0 Mon Sep 17 00:00:00 2001 From: hypherionmc Date: Mon, 28 Apr 2025 13:57:21 +0200 Subject: [PATCH] [BUG] Handle Adventure serializer errors with a fallback value --- .../com/hypherionmc/craterlib/utils/ChatUtils.java | 8 ++++++-- changelog.md | 13 ++----------- gradle.properties | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Common/src/main/java/com/hypherionmc/craterlib/utils/ChatUtils.java b/Common/src/main/java/com/hypherionmc/craterlib/utils/ChatUtils.java index 9e89c94..48ba60c 100644 --- a/Common/src/main/java/com/hypherionmc/craterlib/utils/ChatUtils.java +++ b/Common/src/main/java/com/hypherionmc/craterlib/utils/ChatUtils.java @@ -36,8 +36,12 @@ public class ChatUtils { } public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) { - final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup()); - return adventureSerializer.deserialize(serialised); + try { + final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup()); + return adventureSerializer.deserialize(serialised); + } catch (Exception e) { + return net.kyori.adventure.text.Component.text(inComponent.getString()); + } } private static HolderLookup.Provider getRegistryLookup() { diff --git a/changelog.md b/changelog.md index ef30c2a..43dd535 100644 --- a/changelog.md +++ b/changelog.md @@ -1,13 +1,4 @@ **Bug Fixes**: -- Fixed LuckPerms breaking commands on Paper -- Fix Config watcher using too many threads and not detecting changes on Linux systems - -**New Features**: - -- Added Nojang API to allow mods to access GameRules (SDLink) -- Exposed Adventure JSON serializer to mods - -**Dev Changes**: - -- Bumped MoonConfig - `1.0.10` -> `1.0.12` \ No newline at end of file +- Fix Adventure Serializer failing completely when serialization fails, causing game glitches +- \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 006d3aa..9e34599 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ #Project version_major=2 version_minor=1 -version_patch=4 -version_build=2 +version_patch=5 +version_build=0 #Mod mod_author=HypherionSA