[ci skip] improvement example in javadoc for DatapackRegistrar (#12122)

This commit is contained in:
Pedro
2025-02-16 15:19:42 -03:00
committed by GitHub
parent cb25c0cf31
commit 00701267c8
3 changed files with 9 additions and 6 deletions

View File

@@ -19,11 +19,13 @@ import org.jspecify.annotations.Nullable;
* is called anytime the game tries to discover datapacks at any of the * is called anytime the game tries to discover datapacks at any of the
* configured locations. This means that if a datapack should stay available to the server, * configured locations. This means that if a datapack should stay available to the server,
* it must always be discovered whenever this event fires. * it must always be discovered whenever this event fires.
* <p>An example of a plugin loading a datapack from within it's own jar is below</p> * <p>
* An example of a plugin loading a datapack from within its own jar is below,
* assuming the datapack is included under {@code resources/pack} folder:
* <pre>{@code * <pre>{@code
* public class YourPluginBootstrap implements PluginBootstrap { * public class YourPluginBootstrap implements PluginBootstrap {
* @Override * @Override
* public void bootstrap(BoostrapContext context) { * public void bootstrap(BootstrapContext context) {
* final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager(); * final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
* manager.registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, event -> { * manager.registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, event -> {
* DatapackRegistrar registrar = event.registrar(); * DatapackRegistrar registrar = event.registrar();
@@ -39,6 +41,7 @@ import org.jspecify.annotations.Nullable;
* } * }
* } * }
* }</pre> * }</pre>
*
* @see io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents#DATAPACK_DISCOVERY * @see io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents#DATAPACK_DISCOVERY
*/ */
@ApiStatus.NonExtendable @ApiStatus.NonExtendable

View File

@@ -19,7 +19,7 @@ import org.jspecify.annotations.NullMarked;
* tags only point to individual entries and not other nested tags. * tags only point to individual entries and not other nested tags.
* <p> * <p>
* An example of a custom enchant being registered to the vanilla * An example of a custom enchant being registered to the vanilla
* {@code #minecraft:in_enchanting_table} tag. * {@code #minecraft:in_enchanting_table} tag:
* <pre>{@code * <pre>{@code
* class YourBootstrapClass implements PluginBootstrap { * class YourBootstrapClass implements PluginBootstrap {
* *
@@ -27,7 +27,7 @@ import org.jspecify.annotations.NullMarked;
* *
* @Override * @Override
* public void bootstrap(BootstrapContext context) { * public void bootstrap(BootstrapContext context) {
* LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager(); * final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
* manager.registerEventHandler(LifecycleEvents.TAGS.postFlatten(RegistryKey.ENCHANTMENT), event -> { * manager.registerEventHandler(LifecycleEvents.TAGS.postFlatten(RegistryKey.ENCHANTMENT), event -> {
* final PostFlattenTagRegistrar<Enchantment> registrar = event.registrar(); * final PostFlattenTagRegistrar<Enchantment> registrar = event.registrar();
* registrar.addToTag( * registrar.addToTag(

View File

@@ -22,11 +22,11 @@ import org.jspecify.annotations.NullMarked;
* <pre>{@code * <pre>{@code
* class YourBootstrapClass implements PluginBootstrap { * class YourBootstrapClass implements PluginBootstrap {
* *
* public static final TagKey<ItemType> AXE_PICKAXE = TagKey.create(RegistryKey.ITEM, Key.key("papermc:axe_pickaxe")); * public static final TagKey<ItemType> AXE_PICKAXE = ItemTypeTagKeys.create(Key.key("papermc:axe_pickaxe"));
* *
* @Override * @Override
* public void bootstrap(BootstrapContext context) { * public void bootstrap(BootstrapContext context) {
* LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager(); * final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
* manager.registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ITEM), event -> { * manager.registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ITEM), event -> {
* final PreFlattenTagRegistrar<ItemType> registrar = event.registrar(); * final PreFlattenTagRegistrar<ItemType> registrar = event.registrar();
* registrar.setTag(AXE_PICKAXE, Set.of( * registrar.setTag(AXE_PICKAXE, Set.of(