Compiler issue v5

This commit is contained in:
Bjarne Koll 2024-10-25 18:08:28 +02:00
parent bb124f4021
commit 0a8fd78e37
No known key found for this signature in database
GPG key ID: 27F6CCCF55D2EE62
42 changed files with 97 additions and 87 deletions

View file

@ -14,10 +14,10 @@ Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java
new file mode 100644
index 0000000000000000000000000000000000000000..8dcedc5f4d4453fd942787dbcb9c757274ec7715
index 0000000000000000000000000000000000000000..2c5702a42c4a3d8b37deeb26e1bd7fbdcca3554e
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java
@@ -0,0 +1,446 @@
@@ -0,0 +1,450 @@
+package io.papermc.paper.adventure;
+
+import com.google.gson.JsonElement;
@ -61,6 +61,7 @@ index 0000000000000000000000000000000000000000..8dcedc5f4d4453fd942787dbcb9c7572
+import net.kyori.adventure.text.format.TextColor;
+import net.kyori.adventure.text.format.TextDecoration;
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
+import net.minecraft.commands.arguments.selector.SelectorPattern;
+import net.minecraft.core.UUIDUtil;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.nbt.CompoundTag;
@ -146,7 +147,7 @@ index 0000000000000000000000000000000000000000..8dcedc5f4d4453fd942787dbcb9c7572
+ @Subst("key") final String typeKey = isi.item.unwrapKey().orElseThrow().location().toString();
+ return HoverEvent.ShowItem.showItem(Key.key(typeKey), isi.count, PaperAdventure.asAdventure(isi.getItemStack().getComponentsPatch()));
+ }, si -> {
+ final Item itemType = BuiltInRegistries.ITEM.get(PaperAdventure.asVanilla(si.item()));
+ final Item itemType = BuiltInRegistries.ITEM.getValue(PaperAdventure.asVanilla(si.item()));
+ final Map<Key, DataComponentValue> dataComponentsMap = si.dataComponents();
+ final ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(itemType), si.count(), PaperAdventure.asVanilla(dataComponentsMap));
+ return new net.minecraft.network.chat.HoverEvent.ItemStackInfo(stack);
@ -315,7 +316,10 @@ index 0000000000000000000000000000000000000000..8dcedc5f4d4453fd942787dbcb9c7572
+ });
+
+ static final MapCodec<KeybindComponent> KEYBIND_COMPONENT_MAP_CODEC = KeybindContents.CODEC.xmap(k -> Component.keybind(k.getName()), k -> new KeybindContents(k.keybind()));
+ static final MapCodec<ScoreComponent> SCORE_COMPONENT_INNER_MAP_CODEC = ScoreContents.INNER_CODEC.xmap(s -> Component.score(s.getName(), s.getObjective()), s -> new ScoreContents(s.name(), s.objective()));
+ static final MapCodec<ScoreComponent> SCORE_COMPONENT_INNER_MAP_CODEC = ScoreContents.INNER_CODEC.xmap(
+ s -> Component.score(s.name().map(SelectorPattern::pattern, Function.identity()), s.objective()),
+ s -> new ScoreContents(SelectorPattern.parse(s.name()).<Either<SelectorPattern, String>>map(Either::left).result().orElse(Either.right(s.name())), s.objective())
+ ); // TODO we might want to ask adventure for a nice way we can avoid parsing and flattening the SelectorPattern on every conversion.
+ static final MapCodec<ScoreComponent> SCORE_COMPONENT_MAP_CODEC = SCORE_COMPONENT_INNER_MAP_CODEC.fieldOf("score");
+ static final MapCodec<SelectorComponent> SELECTOR_COMPONENT_MAP_CODEC = mapCodec((instance) -> {
+ return instance.group(
@ -1157,7 +1161,7 @@ index 0000000000000000000000000000000000000000..2fd6c3e65354071af71c7d8ebb97b559
+}
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
new file mode 100644
index 0000000000000000000000000000000000000000..dc4837c577676115f0653acc35f55962a432e425
index 0000000000000000000000000000000000000000..161bc8c577643094d824ea96fb6974c76e5e77f0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
@@ -0,0 +1,479 @@
@ -1580,7 +1584,7 @@ index 0000000000000000000000000000000000000000..dc4837c577676115f0653acc35f55962
+ }
+ final DataComponentPatch.Builder builder = DataComponentPatch.builder();
+ map.forEach((key, dataComponentValue) -> {
+ final DataComponentType<?> type = requireNonNull(BuiltInRegistries.DATA_COMPONENT_TYPE.get(asVanilla(key)));
+ final DataComponentType<?> type = requireNonNull(BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(asVanilla(key)));
+ if (dataComponentValue instanceof DataComponentValue.Removed) {
+ builder.remove(type);
+ return;
@ -1839,7 +1843,7 @@ index 0000000000000000000000000000000000000000..8323f135d6bf2e1f12525e05094ffa3f
+}
diff --git a/src/main/java/io/papermc/paper/adventure/providers/DataComponentValueConverterProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/DataComponentValueConverterProviderImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..6b37c0ebda4a0cfcf9c3b2c3483ffababe622555
index 0000000000000000000000000000000000000000..ee2076fd098ae2164596f39b88f56b3700ed3687
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/providers/DataComponentValueConverterProviderImpl.java
@@ -0,0 +1,82 @@
@ -1895,7 +1899,7 @@ index 0000000000000000000000000000000000000000..6b37c0ebda4a0cfcf9c3b2c3483ffaba
+ GsonDataComponentValue.class,
+ PaperAdventure.DataComponentValueImpl.class,
+ (key, dataComponentValue) -> {
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(PaperAdventure.asVanilla(key));
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(PaperAdventure.asVanilla(key));
+ if (type == null) {
+ throw new IllegalArgumentException("Unknown data component type: " + key);
+ }
@ -1911,7 +1915,7 @@ index 0000000000000000000000000000000000000000..6b37c0ebda4a0cfcf9c3b2c3483ffaba
+ DataComponentValue.TagSerializable.class,
+ PaperAdventure.DataComponentValueImpl.class,
+ (key, tagSerializable) -> {
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(PaperAdventure.asVanilla(key));
+ final @Nullable DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(PaperAdventure.asVanilla(key));
+ if (type == null) {
+ throw new IllegalArgumentException("Unknown data component type: " + key);
+ }