mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Updated Kyori-Adventure (4.17.0 -> 4.18.0)
This commit is contained in:
parent
17d76ae42b
commit
4221937aea
4 changed files with 14 additions and 5 deletions
|
@ -11,7 +11,7 @@ java {
|
||||||
|
|
||||||
val annotationsVersion = "24.1.0"
|
val annotationsVersion = "24.1.0"
|
||||||
val bungeeCordChatVersion = "1.20-R0.2"
|
val bungeeCordChatVersion = "1.20-R0.2"
|
||||||
val adventureVersion = "4.17.0"
|
val adventureVersion = "4.18.0"
|
||||||
val slf4jVersion = "2.0.9"
|
val slf4jVersion = "2.0.9"
|
||||||
val log4jVersion = "2.17.1"
|
val log4jVersion = "2.17.1"
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ dependencies {
|
||||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||||
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
|
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
|
||||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||||
implementation("net.kyori:adventure-text-serializer-ansi:4.17.0") // Keep in sync with adventureVersion from Paper-API build file
|
implementation("net.kyori:adventure-text-serializer-ansi:4.18.0") // Keep in sync with adventureVersion from Paper-API build file
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Required to add the missing Log4j2Plugins.dat file from log4j-core
|
Required to add the missing Log4j2Plugins.dat file from log4j-core
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.mojang.serialization.DynamicOps;
|
||||||
import com.mojang.serialization.JsonOps;
|
import com.mojang.serialization.JsonOps;
|
||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -37,6 +36,7 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.DataComponentValue;
|
import net.kyori.adventure.text.event.DataComponentValue;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
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.Style;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
@ -79,6 +79,11 @@ public final class AdventureCodecs {
|
||||||
public static final Codec<Component> COMPONENT_CODEC = recursive("adventure Component", AdventureCodecs::createCodec);
|
public static final Codec<Component> COMPONENT_CODEC = recursive("adventure Component", AdventureCodecs::createCodec);
|
||||||
public static final StreamCodec<RegistryFriendlyByteBuf, Component> STREAM_COMPONENT_CODEC = ByteBufCodecs.fromCodecWithRegistriesTrusted(COMPONENT_CODEC);
|
public static final StreamCodec<RegistryFriendlyByteBuf, Component> STREAM_COMPONENT_CODEC = ByteBufCodecs.fromCodecWithRegistriesTrusted(COMPONENT_CODEC);
|
||||||
|
|
||||||
|
static final Codec<ShadowColor> SHADOW_COLOR_CODEC = Codec.INT.comapFlatMap(s -> {
|
||||||
|
@Nullable ShadowColor value = ShadowColor.shadowColor(s);
|
||||||
|
return value != null ? DataResult.success(value) : DataResult.error(() -> "Cannot convert " + s + " to adventure ShadowColor");
|
||||||
|
}, ShadowColor::value);
|
||||||
|
|
||||||
static final Codec<TextColor> TEXT_COLOR_CODEC = Codec.STRING.comapFlatMap(s -> {
|
static final Codec<TextColor> TEXT_COLOR_CODEC = Codec.STRING.comapFlatMap(s -> {
|
||||||
if (s.startsWith("#")) {
|
if (s.startsWith("#")) {
|
||||||
@Nullable TextColor value = TextColor.fromHexString(s);
|
@Nullable TextColor value = TextColor.fromHexString(s);
|
||||||
|
@ -228,8 +233,9 @@ public final class AdventureCodecs {
|
||||||
CLICK_EVENT_CODEC.optionalFieldOf("clickEvent").forGetter(nullableGetter(Style::clickEvent)),
|
CLICK_EVENT_CODEC.optionalFieldOf("clickEvent").forGetter(nullableGetter(Style::clickEvent)),
|
||||||
HOVER_EVENT_CODEC.optionalFieldOf("hoverEvent").forGetter(nullableGetter(Style::hoverEvent)),
|
HOVER_EVENT_CODEC.optionalFieldOf("hoverEvent").forGetter(nullableGetter(Style::hoverEvent)),
|
||||||
Codec.STRING.optionalFieldOf("insertion").forGetter(nullableGetter(Style::insertion)),
|
Codec.STRING.optionalFieldOf("insertion").forGetter(nullableGetter(Style::insertion)),
|
||||||
KEY_CODEC.optionalFieldOf("font").forGetter(nullableGetter(Style::font))
|
KEY_CODEC.optionalFieldOf("font").forGetter(nullableGetter(Style::font)),
|
||||||
).apply(instance, (textColor, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, font) -> {
|
SHADOW_COLOR_CODEC.optionalFieldOf("shadow_color").forGetter(nullableGetter(Style::shadowColor))
|
||||||
|
).apply(instance, (textColor, bold, italic, underlined, strikethrough, obfuscated, clickEvent, hoverEvent, insertion, font, shadowColor) -> {
|
||||||
return Style.style(builder -> {
|
return Style.style(builder -> {
|
||||||
textColor.ifPresent(builder::color);
|
textColor.ifPresent(builder::color);
|
||||||
bold.ifPresent(styleBooleanConsumer(builder, TextDecoration.BOLD));
|
bold.ifPresent(styleBooleanConsumer(builder, TextDecoration.BOLD));
|
||||||
|
@ -241,6 +247,7 @@ public final class AdventureCodecs {
|
||||||
hoverEvent.ifPresent(builder::hoverEvent);
|
hoverEvent.ifPresent(builder::hoverEvent);
|
||||||
insertion.ifPresent(builder::insertion);
|
insertion.ifPresent(builder::insertion);
|
||||||
font.ifPresent(builder::font);
|
font.ifPresent(builder::font);
|
||||||
|
shadowColor.ifPresent(builder::shadowColor);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,6 +22,7 @@ import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
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.Style;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
@ -278,6 +279,7 @@ class AdventureCodecsTest {
|
||||||
style(TextDecoration.BOLD.withState(TextDecoration.State.NOT_SET)),
|
style(TextDecoration.BOLD.withState(TextDecoration.State.NOT_SET)),
|
||||||
style()
|
style()
|
||||||
.font(key("kyori", "kittens"))
|
.font(key("kyori", "kittens"))
|
||||||
|
.shadowColor(ShadowColor.fromHexString("#FF00AAFF"))
|
||||||
.color(NamedTextColor.RED)
|
.color(NamedTextColor.RED)
|
||||||
.decoration(TextDecoration.BOLD, true)
|
.decoration(TextDecoration.BOLD, true)
|
||||||
.clickEvent(openUrl("https://github.com"))
|
.clickEvent(openUrl("https://github.com"))
|
||||||
|
|
Loading…
Reference in a new issue