diff options
-rw-r--r-- | patches/api/0486-Tag-Lifecycle-Events.patch | 50 | ||||
-rw-r--r-- | patches/server/1052-Tag-Lifecycle-Events.patch | 33 | ||||
-rw-r--r-- | test-plugin/src/main/java/io/papermc/testplugin/TestPluginBootstrap.java | 7 |
3 files changed, 47 insertions, 43 deletions
diff --git a/patches/api/0486-Tag-Lifecycle-Events.patch b/patches/api/0486-Tag-Lifecycle-Events.patch index bcc45042cd..1788b7c106 100644 --- a/patches/api/0486-Tag-Lifecycle-Events.patch +++ b/patches/api/0486-Tag-Lifecycle-Events.patch @@ -152,7 +152,7 @@ index 11d19e339c7c62f2eb4467277552c27e4e83069c..5fde17e97eddcd1d01ee39694c9159d0 } diff --git a/src/main/java/io/papermc/paper/tag/PostFlattenTagRegistrar.java b/src/main/java/io/papermc/paper/tag/PostFlattenTagRegistrar.java new file mode 100644 -index 0000000000000000000000000000000000000000..081e9b48d07684d6fb69fde1d22a8a8809e45138 +index 0000000000000000000000000000000000000000..2cecd9b9056299cfa6bb3ac4c26d246c20b9da1b --- /dev/null +++ b/src/main/java/io/papermc/paper/tag/PostFlattenTagRegistrar.java @@ -0,0 +1,114 @@ @@ -184,11 +184,11 @@ index 0000000000000000000000000000000000000000..081e9b48d07684d6fb69fde1d22a8a88 + * @Override + * public void bootstrap(@NotNull BootstrapContext context) { + * LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager(); -+ * manager.registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ENCHANTMENT), event -> { -+ * final PreFlattenTagRegistrar<Enchantment> registrar = event.registrar(); ++ * manager.registerEventHandler(LifecycleEvents.TAGS.postFlatten(RegistryKey.ENCHANTMENT), event -> { ++ * final PostFlattenTagRegistrar<Enchantment> registrar = event.registrar(); + * registrar.addToTag( + * EnchantmentTagKeys.IN_ENCHANTING_TABLE, -+ * Set.of(TagEntry.valueEntry(CUSTOM_ENCHANT, true)) ++ * Set.of(CUSTOM_ENCHANT) + * ); + * }); + * } @@ -238,16 +238,16 @@ index 0000000000000000000000000000000000000000..081e9b48d07684d6fb69fde1d22a8a88 + @Contract(value = "_ -> new", pure = true) + @Unmodifiable @NonNull Collection<TypedKey<T>> getTag(@NonNull TagKey<T> tagKey); + -+ /** -+ * Adds values to the given tag. If the tag does not exist, it will be created. -+ * -+ * @param tagKey the key of the tag to add to -+ * @param first the first value to add -+ * @param rest the rest of the values to add -+ * @see #setTag(TagKey, Collection) -+ */ -+ @Contract(mutates = "this") -+ void addToTag(@NonNull TagKey<T> tagKey, @NonNull TypedKey<T> first, @NonNull TypedKey<T> @NonNull ... rest); ++ // /** ++ // * Adds values to the given tag. If the tag does not exist, it will be created. ++ // * ++ // * @param tagKey the key of the tag to add to ++ // * @param first the first value to add ++ // * @param rest the rest of the values to add ++ // * @see #setTag(TagKey, Collection) ++ // */ ++ // @Contract(mutates = "this") ++ // void addToTag(@NonNull TagKey<T> tagKey, @NonNull TypedKey<T> first, @NonNull TypedKey<T> @NonNull ... rest); + + /** + * Adds values to the given tag. If the tag does not exist, it will be created. @@ -272,7 +272,7 @@ index 0000000000000000000000000000000000000000..081e9b48d07684d6fb69fde1d22a8a88 +} diff --git a/src/main/java/io/papermc/paper/tag/PreFlattenTagRegistrar.java b/src/main/java/io/papermc/paper/tag/PreFlattenTagRegistrar.java new file mode 100644 -index 0000000000000000000000000000000000000000..b6083888ecebfdc611c6938a1150c84277c68b58 +index 0000000000000000000000000000000000000000..2f6e57af8fcc0ff2d9f256bd91a9da75ef5b9a34 --- /dev/null +++ b/src/main/java/io/papermc/paper/tag/PreFlattenTagRegistrar.java @@ -0,0 +1,114 @@ @@ -358,16 +358,16 @@ index 0000000000000000000000000000000000000000..b6083888ecebfdc611c6938a1150c842 + @Contract(value = "_ -> new", pure = true) + @Unmodifiable @NonNull List<TagEntry<T>> getTag(@NonNull TagKey<T> tagKey); + -+ /** -+ * Adds entries to the given tag. If the tag does not exist, it will be created. -+ * -+ * @param tagKey the key of the tag to add to -+ * @param first the first entry to add -+ * @param rest the rest of the entries to add -+ * @see #setTag(TagKey, Collection) -+ */ -+ @Contract(mutates = "this") -+ void addToTag(@NonNull TagKey<T> tagKey, @NonNull TagEntry<T> first, @NonNull TagEntry<T> @NonNull ... rest); ++ // /** ++ // * Adds entries to the given tag. If the tag does not exist, it will be created. ++ // * ++ // * @param tagKey the key of the tag to add to ++ // * @param first the first entry to add ++ // * @param rest the rest of the entries to add ++ // * @see #setTag(TagKey, Collection) ++ // */ ++ // @Contract(mutates = "this") ++ // void addToTag(@NonNull TagKey<T> tagKey, @NonNull TagEntry<T> first, @NonNull TagEntry<T> @NonNull ... rest); + + /** + * Adds entries to the given tag. If the tag does not exist, it will be created. diff --git a/patches/server/1052-Tag-Lifecycle-Events.patch b/patches/server/1052-Tag-Lifecycle-Events.patch index e1ed5b4266..7bed81b8e5 100644 --- a/patches/server/1052-Tag-Lifecycle-Events.patch +++ b/patches/server/1052-Tag-Lifecycle-Events.patch @@ -271,7 +271,7 @@ index dcc0f6b337840a78d38abdf2eb3f4bbd1676f58f..0c7cb29aa001923e36b9f4dae3b15fe4 } diff --git a/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java b/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java new file mode 100644 -index 0000000000000000000000000000000000000000..b1bf2165e8f063d74a9f95e8943fcd576ed1f3f5 +index 0000000000000000000000000000000000000000..013fef5b95eee817ed1d9b28c6f1ecde5a331e56 --- /dev/null +++ b/src/main/java/io/papermc/paper/tag/PaperPostFlattenTagRegistrar.java @@ -0,0 +1,130 @@ @@ -381,14 +381,14 @@ index 0000000000000000000000000000000000000000..b1bf2165e8f063d74a9f95e8943fcd57 + return this.convert(this.getNmsTag(tagKey, false)); + } + -+ @SafeVarargs -+ @Override -+ public final void addToTag(final TagKey<T> tagKey, final TypedKey<T> first, final TypedKey<T> ... rest) { -+ final ArrayList<TypedKey<T>> list = Lists.newArrayListWithCapacity(rest.length + 1); -+ list.add(first); -+ list.addAll(Arrays.asList(rest)); -+ this.addToTag(tagKey, list); -+ } ++ // @SafeVarargs ++ // @Override ++ // public final void addToTag(final TagKey<T> tagKey, final TypedKey<T> first, final TypedKey<T> ... rest) { ++ // final ArrayList<TypedKey<T>> list = Lists.newArrayListWithCapacity(rest.length + 1); ++ // list.add(first); ++ // Collections.addAll(list, rest); ++ // this.addToTag(tagKey, list); ++ // } + + @Override + public void addToTag(final TagKey<T> tagKey, final Collection<TypedKey<T>> values) { @@ -407,10 +407,10 @@ index 0000000000000000000000000000000000000000..b1bf2165e8f063d74a9f95e8943fcd57 +} diff --git a/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java b/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java new file mode 100644 -index 0000000000000000000000000000000000000000..dce65072d3c1ea3378f9daf4d21e317c01b6431e +index 0000000000000000000000000000000000000000..46b6839c462951b135fd9cd5bcbed478a32a7485 --- /dev/null +++ b/src/main/java/io/papermc/paper/tag/PaperPreFlattenTagRegistrar.java -@@ -0,0 +1,134 @@ +@@ -0,0 +1,137 @@ +package io.papermc.paper.tag; + +import com.google.common.base.Preconditions; @@ -525,10 +525,13 @@ index 0000000000000000000000000000000000000000..dce65072d3c1ea3378f9daf4d21e317c + return convert(this.getNmsTag(tagKey, false)); + } + -+ @Contract(mutates = "this") -+ public final void addToTag(@NonNull TagKey<T> tagKey, @NonNull TagEntry<T> first, @NonNull TagEntry<T> @NonNull ... rest) { -+ -+ } ++ // @Contract(mutates = "this") ++ // public final void addToTag(@NonNull TagKey<T> tagKey, @NonNull TagEntry<T> first, @NonNull TagEntry<T> @NonNull ... rest) { ++ // final List<TagEntry<T>> entries = new ArrayList<>(rest.length + 1); ++ // entries.add(first); ++ // Collections.addAll(entries, rest); ++ // this.addToTag(tagKey, entries); ++ // } + + @Override + public void addToTag(final TagKey<T> tagKey, final Collection<TagEntry<T>> entries) { diff --git a/test-plugin/src/main/java/io/papermc/testplugin/TestPluginBootstrap.java b/test-plugin/src/main/java/io/papermc/testplugin/TestPluginBootstrap.java index 27985fd232..1fc72979f2 100644 --- a/test-plugin/src/main/java/io/papermc/testplugin/TestPluginBootstrap.java +++ b/test-plugin/src/main/java/io/papermc/testplugin/TestPluginBootstrap.java @@ -11,6 +11,7 @@ import io.papermc.paper.registry.event.RegistryEvents; import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys; import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys; import io.papermc.paper.registry.tag.TagKey; +import io.papermc.paper.tag.PostFlattenTagRegistrar; import io.papermc.paper.tag.PreFlattenTagRegistrar; import io.papermc.paper.tag.TagEntry; import java.util.Set; @@ -54,11 +55,11 @@ public class TestPluginBootstrap implements PluginBootstrap { )); }); - manager.registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ENCHANTMENT), event -> { - final PreFlattenTagRegistrar<Enchantment> registrar = event.registrar(); + manager.registerEventHandler(LifecycleEvents.TAGS.postFlatten(RegistryKey.ENCHANTMENT), event -> { + final PostFlattenTagRegistrar<Enchantment> registrar = event.registrar(); registrar.addToTag( EnchantmentTagKeys.IN_ENCHANTING_TABLE, - Set.of(TagEntry.valueEntry(CUSTOM_ENCHANT, true)) + Set.of(CUSTOM_ENCHANT) ); }); } |