Class ConsumablePaper
java.lang.Object
valorless.rarespawns.builders.components.ConsumablePaper
Represents a Paper-specific consumable component that can be applied to an item.
This component defines the behavior when the item is consumed, utilizing Paper's API.
Links to Paper API:
ConsumableItemUseAnimationConsumeEffect.ApplyStatusEffects
ItemStackPotionEffectPotionEffectTypeSound
Config
-
Constructor Summary
ConstructorsConstructorDescriptionConsumablePaper(valorless.valorlessutils.config.Config config) Initializes the Paper consumable component based on the provided configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(org.bukkit.inventory.ItemStack item) Applies a Paper Consumable instance to an ItemStack reflectively.io.papermc.paper.datacomponent.item.ConsumableRetrieves the underlying Consumable component.
-
Constructor Details
-
ConsumablePaper
public ConsumablePaper(valorless.valorlessutils.config.Config config) Initializes the Paper consumable component based on the provided configuration. Reads config keys and sets up the consumable's properties and effects.Supported config keys:
- food.eat-speed
- food.effects
- food.animation
- food.sound
- food.particles
- Parameters:
config- The configuration object containing consumable settings.- See Also:
-
-
Method Details
-
getComponent
public io.papermc.paper.datacomponent.item.Consumable getComponent()Retrieves the underlying Consumable component.- Returns:
- The Consumable instance.
- See Also:
-
apply
public void apply(org.bukkit.inventory.ItemStack item) Applies a Paper Consumable instance to an ItemStack reflectively. Skips if the server is Spigot or the consumable is null.Uses reflection to access Paper's DataComponentTypes and set the consumable data.
- Parameters:
item- The ItemStack to modify- See Also:
-