mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -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
|
* 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
|
||||||
|
@@ -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(
|
||||||
|
@@ -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(
|
||||||
|
Reference in New Issue
Block a user