Skip to content

Commit 4221937

Browse files
committed
Updated Kyori-Adventure (4.17.0 -> 4.18.0)
1 parent 17d76ae commit 4221937

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

paper-api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ java {
1111

1212
val annotationsVersion = "24.1.0"
1313
val bungeeCordChatVersion = "1.20-R0.2"
14-
val adventureVersion = "4.17.0"
14+
val adventureVersion = "4.18.0"
1515
val slf4jVersion = "2.0.9"
1616
val log4jVersion = "2.17.1"
1717

paper-server/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ dependencies {
128128
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
129129
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
130130
implementation("net.minecrell:terminalconsoleappender:1.3.0")
131-
implementation("net.kyori:adventure-text-serializer-ansi:4.17.0") // Keep in sync with adventureVersion from Paper-API build file
131+
implementation("net.kyori:adventure-text-serializer-ansi:4.18.0") // Keep in sync with adventureVersion from Paper-API build file
132132

133133
/*
134134
Required to add the missing Log4j2Plugins.dat file from log4j-core

paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.mojang.serialization.JsonOps;
1212
import com.mojang.serialization.MapCodec;
1313
import com.mojang.serialization.codecs.RecordCodecBuilder;
14-
import java.io.IOException;
1514
import java.util.Collections;
1615
import java.util.List;
1716
import java.util.Map;
@@ -37,6 +36,7 @@
3736
import net.kyori.adventure.text.event.DataComponentValue;
3837
import net.kyori.adventure.text.event.HoverEvent;
3938
import net.kyori.adventure.text.format.NamedTextColor;
39+
import net.kyori.adventure.text.format.ShadowColor;
4040
import net.kyori.adventure.text.format.Style;
4141
import net.kyori.adventure.text.format.TextColor;
4242
import net.kyori.adventure.text.format.TextDecoration;
@@ -79,6 +79,11 @@ public final class AdventureCodecs {
7979
public static final Codec<Component> COMPONENT_CODEC = recursive("adventure Component", AdventureCodecs::createCodec);
8080
public static final StreamCodec<RegistryFriendlyByteBuf, Component> STREAM_COMPONENT_CODEC = ByteBufCodecs.fromCodecWithRegistriesTrusted(COMPONENT_CODEC);
8181

82+
static final Codec<ShadowColor> SHADOW_COLOR_CODEC = Codec.INT.comapFlatMap(s -> {
83+
@Nullable ShadowColor value = ShadowColor.shadowColor(s);
84+
return value != null ? DataResult.success(value) : DataResult.error(() -> "Cannot convert " + s + " to adventure ShadowColor");
85+
}, ShadowColor::value);
86+
8287
static final Codec<TextColor> TEXT_COLOR_CODEC = Codec.STRING.comapFlatMap(s -> {
8388
if (s.startsWith("#")) {
8489
@Nullable TextColor value = TextColor.fromHexString(s);
@@ -228,8 +233,9 @@ public String getSerializedName() {
228233
CLICK_EVENT_CODEC.optionalFieldOf("clickEvent").forGetter(nullableGetter(Style::clickEvent)),
229234
HOVER_EVENT_CODEC.optionalFieldOf("hoverEvent").forGetter(nullableGetter(Style::hoverEvent)),
230235
Codec.STRING.optionalFieldOf("insertion").forGetter(nullableGetter(Style::insertion)),
231-
KEY_CODEC.optionalFieldOf("font").forGetter(nullableGetter(Style::font))
232-
).apply(instance, (textColor, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, font) -> {
236+
KEY_CODEC.optionalFieldOf("font").forGetter(nullableGetter(Style::font)),
237+
SHADOW_COLOR_CODEC.optionalFieldOf("shadow_color").forGetter(nullableGetter(Style::shadowColor))
238+
).apply(instance, (textColor, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, font, shadowColor) -> {
233239
return Style.style(builder -> {
234240
textColor.ifPresent(builder::color);
235241
bold.ifPresent(styleBooleanConsumer(builder, TextDecoration.BOLD));
@@ -241,6 +247,7 @@ public String getSerializedName() {
241247
hoverEvent.ifPresent(builder::hoverEvent);
242248
insertion.ifPresent(builder::insertion);
243249
font.ifPresent(builder::font);
250+
shadowColor.ifPresent(builder::shadowColor);
244251
});
245252
});
246253
});

paper-server/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import net.kyori.adventure.text.event.ClickEvent;
2323
import net.kyori.adventure.text.event.HoverEvent;
2424
import net.kyori.adventure.text.format.NamedTextColor;
25+
import net.kyori.adventure.text.format.ShadowColor;
2526
import net.kyori.adventure.text.format.Style;
2627
import net.kyori.adventure.text.format.TextColor;
2728
import net.kyori.adventure.text.format.TextDecoration;
@@ -278,6 +279,7 @@ static List<Style> testStyles() {
278279
style(TextDecoration.BOLD.withState(TextDecoration.State.NOT_SET)),
279280
style()
280281
.font(key("kyori", "kittens"))
282+
.shadowColor(ShadowColor.fromHexString("#FF00AAFF"))
281283
.color(NamedTextColor.RED)
282284
.decoration(TextDecoration.BOLD, true)
283285
.clickEvent(openUrl("https://github.com"))

0 commit comments

Comments
 (0)