mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-30 11:42:02 -07:00
[ci skip] improvement example in javadoc for DatapackRegistrar (#12122)
This commit is contained in:
@@ -19,11 +19,13 @@ import org.jspecify.annotations.Nullable;
|
||||
* 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,
|
||||
* 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
|
||||
* public class YourPluginBootstrap implements PluginBootstrap {
|
||||
* @Override
|
||||
* public void bootstrap(BoostrapContext context) {
|
||||
* public void bootstrap(BootstrapContext context) {
|
||||
* final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
|
||||
* manager.registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, event -> {
|
||||
* DatapackRegistrar registrar = event.registrar();
|
||||
@@ -39,6 +41,7 @@ import org.jspecify.annotations.Nullable;
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* @see io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents#DATAPACK_DISCOVERY
|
||||
*/
|
||||
@ApiStatus.NonExtendable
|
||||
|
@@ -19,7 +19,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
* tags only point to individual entries and not other nested tags.
|
||||
* <p>
|
||||
* 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
|
||||
* class YourBootstrapClass implements PluginBootstrap {
|
||||
*
|
||||
@@ -27,7 +27,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
*
|
||||
* @Override
|
||||
* public void bootstrap(BootstrapContext context) {
|
||||
* LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
|
||||
* final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
|
||||
* manager.registerEventHandler(LifecycleEvents.TAGS.postFlatten(RegistryKey.ENCHANTMENT), event -> {
|
||||
* final PostFlattenTagRegistrar<Enchantment> registrar = event.registrar();
|
||||
* registrar.addToTag(
|
||||
|
@@ -22,11 +22,11 @@ import org.jspecify.annotations.NullMarked;
|
||||
* <pre>{@code
|
||||
* 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
|
||||
* public void bootstrap(BootstrapContext context) {
|
||||
* LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
|
||||
* final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
|
||||
* manager.registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ITEM), event -> {
|
||||
* final PreFlattenTagRegistrar<ItemType> registrar = event.registrar();
|
||||
* registrar.setTag(AXE_PICKAXE, Set.of(
|
||||
|
Reference in New Issue
Block a user