chore: bump adventure to 4.21.0 (#1564)
feat: support for 1.21.5+ hover and click events
This commit is contained in:
@@ -90,7 +90,7 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
|
|||||||
MINECRAFT_1_21(767, "1.21", "1.21.1"),
|
MINECRAFT_1_21(767, "1.21", "1.21.1"),
|
||||||
MINECRAFT_1_21_2(768, "1.21.2", "1.21.3"),
|
MINECRAFT_1_21_2(768, "1.21.2", "1.21.3"),
|
||||||
MINECRAFT_1_21_4(769, "1.21.4"),
|
MINECRAFT_1_21_4(769, "1.21.4"),
|
||||||
MINECRAFT_1_21_5(770, /*1073742067,*/ "1.21.5");
|
MINECRAFT_1_21_5(770, "1.21.5");
|
||||||
|
|
||||||
private static final int SNAPSHOT_BIT = 30;
|
private static final int SNAPSHOT_BIT = 30;
|
||||||
|
|
||||||
|
@@ -11,8 +11,8 @@ shadow = "io.github.goooler.shadow:8.1.5"
|
|||||||
spotless = "com.diffplug.spotless:6.25.0"
|
spotless = "com.diffplug.spotless:6.25.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
adventure-bom = "net.kyori:adventure-bom:4.20.0"
|
adventure-bom = "net.kyori:adventure-bom:4.21.0"
|
||||||
adventure-text-serializer-json-legacy-impl = "net.kyori:adventure-text-serializer-json-legacy-impl:4.20.0"
|
adventure-text-serializer-json-legacy-impl = "net.kyori:adventure-text-serializer-json-legacy-impl:4.21.0"
|
||||||
adventure-facet = "net.kyori:adventure-platform-facet:4.3.4"
|
adventure-facet = "net.kyori:adventure-platform-facet:4.3.4"
|
||||||
asm = "org.ow2.asm:asm:9.7.1"
|
asm = "org.ow2.asm:asm:9.7.1"
|
||||||
auto-service = "com.google.auto.service:auto-service:1.0.1"
|
auto-service = "com.google.auto.service:auto-service:1.0.1"
|
||||||
|
@@ -47,7 +47,7 @@ import net.kyori.adventure.nbt.CompoundBinaryTag;
|
|||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.json.JSONOptions;
|
import net.kyori.adventure.text.serializer.json.JSONOptions;
|
||||||
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
|
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
|
||||||
import net.kyori.option.OptionState;
|
import net.kyori.option.OptionSchema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for writing and reading data in the Minecraft protocol.
|
* Utilities for writing and reading data in the Minecraft protocol.
|
||||||
@@ -60,10 +60,10 @@ public enum ProtocolUtils {
|
|||||||
.downsampleColors()
|
.downsampleColors()
|
||||||
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
|
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
|
||||||
.options(
|
.options(
|
||||||
OptionState.optionState()
|
OptionSchema.globalSchema().stateBuilder()
|
||||||
// before 1.16
|
// before 1.16
|
||||||
.value(JSONOptions.EMIT_RGB, Boolean.FALSE)
|
.value(JSONOptions.EMIT_RGB, Boolean.FALSE)
|
||||||
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.LEGACY_ONLY)
|
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.VALUE_FIELD)
|
||||||
// before 1.20.3
|
// before 1.20.3
|
||||||
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.FALSE)
|
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.FALSE)
|
||||||
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.FALSE)
|
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.FALSE)
|
||||||
@@ -75,10 +75,11 @@ public enum ProtocolUtils {
|
|||||||
GsonComponentSerializer.builder()
|
GsonComponentSerializer.builder()
|
||||||
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
|
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
|
||||||
.options(
|
.options(
|
||||||
OptionState.optionState()
|
OptionSchema.globalSchema().stateBuilder()
|
||||||
// after 1.16
|
// after 1.16
|
||||||
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
|
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
|
||||||
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.MODERN_ONLY)
|
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.CAMEL_CASE)
|
||||||
|
.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.CAMEL_CASE)
|
||||||
// before 1.20.3
|
// before 1.20.3
|
||||||
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.FALSE)
|
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.FALSE)
|
||||||
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.FALSE)
|
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.FALSE)
|
||||||
@@ -86,17 +87,36 @@ public enum ProtocolUtils {
|
|||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
private static final GsonComponentSerializer PRE_1_21_5_SERIALIZER =
|
||||||
|
GsonComponentSerializer.builder()
|
||||||
|
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
|
||||||
|
.options(
|
||||||
|
OptionSchema.globalSchema().stateBuilder()
|
||||||
|
// after 1.16
|
||||||
|
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
|
||||||
|
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.CAMEL_CASE)
|
||||||
|
.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.CAMEL_CASE)
|
||||||
|
// after 1.20.3
|
||||||
|
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.TRUE)
|
||||||
|
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.TRUE)
|
||||||
|
.value(JSONOptions.VALIDATE_STRICT_EVENTS, Boolean.TRUE)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.build();
|
||||||
private static final GsonComponentSerializer MODERN_SERIALIZER =
|
private static final GsonComponentSerializer MODERN_SERIALIZER =
|
||||||
GsonComponentSerializer.builder()
|
GsonComponentSerializer.builder()
|
||||||
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
|
.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get())
|
||||||
.options(
|
.options(
|
||||||
OptionState.optionState()
|
OptionSchema.globalSchema().stateBuilder()
|
||||||
// after 1.16
|
// after 1.16
|
||||||
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
|
.value(JSONOptions.EMIT_RGB, Boolean.TRUE)
|
||||||
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.MODERN_ONLY)
|
.value(JSONOptions.EMIT_HOVER_EVENT_TYPE, JSONOptions.HoverEventValueMode.SNAKE_CASE)
|
||||||
|
.value(JSONOptions.EMIT_CLICK_EVENT_TYPE, JSONOptions.ClickEventValueMode.SNAKE_CASE)
|
||||||
// after 1.20.3
|
// after 1.20.3
|
||||||
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.TRUE)
|
.value(JSONOptions.EMIT_COMPACT_TEXT_COMPONENT, Boolean.TRUE)
|
||||||
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.TRUE)
|
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_ID_AS_INT_ARRAY, Boolean.TRUE)
|
||||||
|
// after 1.21.5
|
||||||
|
.value(JSONOptions.EMIT_HOVER_SHOW_ENTITY_KEY_AS_TYPE_AND_UUID_AS_ID, Boolean.FALSE)
|
||||||
.value(JSONOptions.VALIDATE_STRICT_EVENTS, Boolean.TRUE)
|
.value(JSONOptions.VALIDATE_STRICT_EVENTS, Boolean.TRUE)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
@@ -713,9 +733,12 @@ public enum ProtocolUtils {
|
|||||||
* @return the appropriate {@link GsonComponentSerializer}
|
* @return the appropriate {@link GsonComponentSerializer}
|
||||||
*/
|
*/
|
||||||
public static GsonComponentSerializer getJsonChatSerializer(ProtocolVersion version) {
|
public static GsonComponentSerializer getJsonChatSerializer(ProtocolVersion version) {
|
||||||
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
|
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_21_5)) {
|
||||||
return MODERN_SERIALIZER;
|
return MODERN_SERIALIZER;
|
||||||
}
|
}
|
||||||
|
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_20_3)) {
|
||||||
|
return PRE_1_21_5_SERIALIZER;
|
||||||
|
}
|
||||||
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_16)) {
|
if (version.noLessThan(ProtocolVersion.MINECRAFT_1_16)) {
|
||||||
return PRE_1_20_3_SERIALIZER;
|
return PRE_1_20_3_SERIALIZER;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user