Skip to content

Commit

Permalink
Re-implement shadow color support
Browse files Browse the repository at this point in the history
Un-reverts the shadow color support, but with adventure release v4.18.0
  • Loading branch information
booky10 committed Dec 10, 2024
1 parent 4b6bfbc commit 7029571
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import net.kyori.adventure.text.event.DataComponentValue;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.ShadowColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
Expand Down Expand Up @@ -330,11 +331,10 @@ public AdventureNBTSerializer(boolean downsampleColor) {
if (color != null) style.color(color);
});
if (BackwardCompatUtil.IS_4_18_0_OR_NEWER) {
// FIXME adventure v4.18.0
// reader.useUTF("shadow_color", value -> {
// ShadowColor color = ShadowColor.fromHexString(value);
// if (color != null) style.shadowColor(color);
// });
reader.useUTF("shadow_color", value -> {
ShadowColor color = ShadowColor.fromHexString(value);
if (color != null) style.shadowColor(color);
});
}

for (String decorationKey : TextDecoration.NAMES.keys()) {
Expand Down Expand Up @@ -412,9 +412,8 @@ public AdventureNBTSerializer(boolean downsampleColor) {
if (color != null) writer.writeUTF("color", this.serializeColor(color));

if (BackwardCompatUtil.IS_4_18_0_OR_NEWER) {
// FIXME adventure v4.18.0
// ShadowColor shadowColor = style.shadowColor();
// if (shadowColor != null) writer.writeUTF("shadow_color", shadowColor.asHexString());
ShadowColor shadowColor = style.shadowColor();
if (shadowColor != null) writer.writeUTF("shadow_color", shadowColor.asHexString());
}

for (TextDecoration decoration : TextDecoration.NAMES.values()) {
Expand Down
2 changes: 1 addition & 1 deletion libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
adventure = "4.17.0" # FIXME adventure v4.18.0
adventure = "4.18.0"
examination = "1.3.0"
netty = "4.1.72.Final"
jetbrains-annotations = "23.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ public final class BackwardCompatUtil {
boolean is4_18_0OrNewer = false;
try {
// shadow color support was added in 4.18.0
// FIXME adventure v4.18.0
// Style.empty().shadowColor();
// is4_18_0OrNewer = true;
Style.empty().shadowColor();
is4_18_0OrNewer = true;
} catch (Throwable ignored) {
}
IS_4_18_0_OR_NEWER = is4_18_0OrNewer;
Expand Down

0 comments on commit 7029571

Please sign in to comment.