Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public MinecraftHasher<Component> get() {
case TRUE -> true;
});

MinecraftHasher<ClickEvent.Action> CLICK_EVENT_ACTION = MinecraftHasher.STRING.cast(ClickEvent.Action::toString);
MinecraftHasher<ClickEvent.Action<?>> CLICK_EVENT_ACTION = MinecraftHasher.STRING.cast(ClickEvent.Action::name);

MinecraftHasher<ClickEvent.Payload.Text> CLICK_EVENT_TEXT_PAYLOAD = MinecraftHasher.STRING.cast(ClickEvent.Payload.Text::value);

Expand All @@ -101,13 +101,15 @@ public MinecraftHasher<Component> get() {
// - Dialog has no proper implementation within Adventure yet. Once it does, we'd probably only hash dialog holders with a resource location, because setting up
// hashers for the full dialog structure can be a lot of work.
// - Custom uses BinaryTagHolder to store NBT data, which essentially only stores a string representation. This won't work with hashing, we need a NBT tag to hash.
MinecraftHasher<ClickEvent> CLICK_EVENT = CLICK_EVENT_ACTION.dispatch("action", ClickEvent::action, action -> switch (action) {
case OPEN_URL -> builder -> builder.accept("url", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case OPEN_FILE -> builder -> builder.accept("path", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case RUN_COMMAND, SUGGEST_COMMAND -> builder -> builder.accept("command", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case CHANGE_PAGE -> builder -> builder.accept("page", CLICK_EVENT_INT_PAYLOAD, event -> (ClickEvent.Payload.Int) event.payload());
case COPY_TO_CLIPBOARD -> builder -> builder.accept("value", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case SHOW_DIALOG, CUSTOM -> MapBuilder.unit();
MinecraftHasher<ClickEvent<?>> CLICK_EVENT = CLICK_EVENT_ACTION.dispatch("action", ClickEvent::action, action -> switch (action) {
case ClickEvent.Action.OpenUrl ignored -> builder -> builder.accept("url", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case ClickEvent.Action.OpenFile ignored -> builder -> builder.accept("path", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case ClickEvent.Action.RunCommand ignored -> builder -> builder.accept("command", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case ClickEvent.Action.SuggestCommand ignored -> builder -> builder.accept("command", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case ClickEvent.Action.ChangePage ignored -> builder -> builder.accept("page", CLICK_EVENT_INT_PAYLOAD, event -> (ClickEvent.Payload.Int) event.payload());
case ClickEvent.Action.CopyToClipboard ignored -> builder -> builder.accept("value", CLICK_EVENT_TEXT_PAYLOAD, event -> (ClickEvent.Payload.Text) event.payload());
case ClickEvent.Action.ShowDialog ignored -> MapBuilder.unit();
case ClickEvent.Action.Custom ignored -> MapBuilder.unit();
});

MinecraftHasher<HoverEvent.Action<?>> HOVER_EVENT_ACTION = MinecraftHasher.STRING.cast(HoverEvent.Action::toString);
Expand Down Expand Up @@ -169,7 +171,7 @@ public MinecraftHasher<Component> get() {
.accept("selector", MinecraftHasher.STRING, SelectorComponent::pattern)
.optionalNullable("separator", COMPONENT, SelectorComponent::separator));

MinecraftHasher<NBTComponent<?, ?>> NBT_COMPONENT = component(builder -> builder
MinecraftHasher<NBTComponent<?>> NBT_COMPONENT = component(builder -> builder
.accept("nbt", MinecraftHasher.STRING, NBTComponent::nbtPath)
.optional("interpret", MinecraftHasher.BOOL, NBTComponent::interpret, false)
.optionalNullable("separator", COMPONENT, NBTComponent::separator)
Expand All @@ -189,7 +191,7 @@ public MinecraftHasher<Component> get() {
return SCORE_COMPONENT.hash(score, encoder);
} else if (component instanceof SelectorComponent selector) {
return SELECTOR_COMPONENT.hash(selector, encoder);
} else if (component instanceof NBTComponent<?, ?> nbt) {
} else if (component instanceof NBTComponent<?> nbt) {
return NBT_COMPONENT.hash(nbt, encoder);
} else if (component instanceof ObjectComponent object) {
return OBJECT_COMPONENT.hash(object, encoder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@
import org.geysermc.geyser.item.hashing.MapBuilder;
import org.geysermc.geyser.item.hashing.MinecraftHasher;

public enum NbtComponentType implements EnumMapDispatchHasher<NbtComponentType, NBTComponent<?, ?>> {
public enum NbtComponentType implements EnumMapDispatchHasher<NbtComponentType, NBTComponent<?>> {
BLOCK(BlockNBTComponent.class, builder -> builder
.accept("block", ComponentPosHasher.POS_HASHER, BlockNBTComponent::pos)),
ENTITY(EntityNBTComponent.class, builder -> builder
.accept("entity", MinecraftHasher.STRING, component -> component.selector())),
STORAGE(StorageNBTComponent.class, builder -> builder
.accept("storage", MinecraftHasher.KEY, StorageNBTComponent::storage));

public static final MapBuilder<NBTComponent<?, ?>> NBT_COMPONENT_SOURCE_MAP_BUILDER = EnumMapDispatchHasher.dispatchFuzzy(NbtComponentType::values);
public static final MapBuilder<NBTComponent<?>> NBT_COMPONENT_SOURCE_MAP_BUILDER = EnumMapDispatchHasher.dispatchFuzzy(NbtComponentType::values);

private final Class<? extends NBTComponent<?, ?>> clazz;
private final MapBuilder<? extends NBTComponent<?, ?>> mapBuilder;
private final Class<? extends NBTComponent<?>> clazz;
private final MapBuilder<? extends NBTComponent<?>> mapBuilder;

<T extends NBTComponent<?, ?>> NbtComponentType(Class<T> clazz, MapBuilder<T> mapBuilder) {
<T extends NBTComponent<?>> NbtComponentType(Class<T> clazz, MapBuilder<T> mapBuilder) {
this.clazz = clazz;
this.mapBuilder = mapBuilder;
}
Expand All @@ -57,12 +57,12 @@ public NbtComponentType distinction() {
}

@Override
public Class<? extends NBTComponent<?, ?>> valueTypeClass() {
public Class<? extends NBTComponent<?>> valueTypeClass() {
return clazz;
}

@Override
public MapBuilder<? extends NBTComponent<?, ?>> mapBuilder() {
public MapBuilder<? extends NBTComponent<?>> mapBuilder() {
return mapBuilder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.TrimMaterial;
import org.cloudburstmc.protocol.bedrock.data.TrimPattern;
import org.geysermc.geyser.api.util.Unit;
import org.geysermc.geyser.entity.type.living.animal.FrogEntity;
import org.geysermc.geyser.entity.type.living.animal.TemperatureVariantAnimal;
import org.geysermc.geyser.entity.type.living.animal.nautilus.ZombieNautilusEntity;
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protocol-codec = "3.0.0.Beta12-20260505.144358-18"
raknet = "1.0.0.CR3-20260421.190401-34"
minecraftauth = "5.0.0"
mcprotocollib = "26.1-20260404.063343-16"
adventure = "4.25.0"
adventure = "5.0.0"
adventure-platform = "4.4.1"
junit = "6.0.0"
checkerframework = "3.19.0"
Expand Down
Loading