diff --git a/libs.versions.toml b/libs.versions.toml index 021df08..efa956d 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -12,6 +12,7 @@ jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version snakeyaml = { group = "org.yaml", name = "snakeyaml", version.ref = "snakeyaml" } adventure = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" } adventure-bukkit = { group = "net.kyori", name = "adventure-platform-bukkit", version.ref = "adventure-bukkit" } +adventure-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" } spigot = { module = "org.spigotmc:spigot-api", version.ref = "spigot" } velocity = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } diff --git a/platforms/spigot/build.gradle.kts b/platforms/spigot/build.gradle.kts index 1c80571..36865dc 100644 --- a/platforms/spigot/build.gradle.kts +++ b/platforms/spigot/build.gradle.kts @@ -11,6 +11,7 @@ repositories { dependencies { api(project(":shared")) api(libs.adventure.bukkit) + api(libs.adventure.legacy) compileOnly(libs.spigot) } diff --git a/platforms/universal/build.gradle.kts b/platforms/universal/build.gradle.kts index 6f3b844..5f15a9a 100644 --- a/platforms/universal/build.gradle.kts +++ b/platforms/universal/build.gradle.kts @@ -10,5 +10,6 @@ repositories { dependencies { api(project(":shared")) api(libs.adventure) + api(libs.adventure.legacy) api(libs.snakeyaml) } diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 115b4e0..e5a8189 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -6,5 +6,6 @@ plugins { dependencies { api(libs.jetbrains.annotations) compileOnly(libs.adventure) + compileOnly(libs.adventure.legacy) compileOnly(libs.snakeyaml) } \ No newline at end of file diff --git a/shared/src/main/java/net/codersky/mcutils/java/strings/MCStrings.java b/shared/src/main/java/net/codersky/mcutils/java/strings/MCStrings.java index 400814a..d3bbb84 100644 --- a/shared/src/main/java/net/codersky/mcutils/java/strings/MCStrings.java +++ b/shared/src/main/java/net/codersky/mcutils/java/strings/MCStrings.java @@ -15,6 +15,7 @@ import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -254,9 +255,11 @@ public static String stripEventPatterns(@NotNull String string) { */ @NotNull public static Component applyEventPatterns(@NotNull String string) { + final LegacyComponentSerializer serializer = LegacyComponentSerializer.builder(). + useUnusualXRepeatedCharacterHexFormat().build(); final TextComponent.Builder builder = Component.text(); searchEventPatterns(string, - txt -> builder.append(Component.text(txt)), + txt -> builder.append(serializer.deserialize(txt)), (event, txt) -> applyEvents(builder, event, txt)); return builder.build(); }