Class ConsumablePaper

java.lang.Object
valorless.rarespawns.builders.components.ConsumablePaper

public class ConsumablePaper extends Object
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:

  • Consumable
  • ItemUseAnimation
  • ConsumeEffect.ApplyStatusEffects
Links to Bukkit API:
  • ItemStack
  • PotionEffect
  • PotionEffectType
  • Sound
Links to config:
  • Config
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConsumablePaper(valorless.valorlessutils.config.Config config)
    Initializes the Paper consumable component based on the provided configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(org.bukkit.inventory.ItemStack item)
    Applies a Paper Consumable instance to an ItemStack reflectively.
    io.papermc.paper.datacomponent.item.Consumable
    Retrieves the underlying Consumable component.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      • Config
  • Method Details

    • getComponent

      public io.papermc.paper.datacomponent.item.Consumable getComponent()
      Retrieves the underlying Consumable component.
      Returns:
      The Consumable instance.
      See Also:
      • Consumable
    • 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:
      • ItemStack