Class CustomEquippableComponent

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.component.CustomEquippableComponent
All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable, org.bukkit.inventory.meta.components.EquippableComponent

public class CustomEquippableComponent extends Object implements org.bukkit.inventory.meta.components.EquippableComponent
Represents a custom implementation of the EquippableComponent interface. This class allows customizing equipment behavior, such as defining equip slots, sounds, allowed entities, and other properties.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomEquippableComponent(org.bukkit.inventory.EquipmentSlot equipmentSlot)
    Constructs a new CustomEquippableComponent with the given equipment slot and default values.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Collection<org.bukkit.entity.EntityType>
    Gets the entities which can equip this item.
    @Nullable org.bukkit.NamespacedKey
    Gets the key of the camera overlay to use when equipped.
    @Nullable org.bukkit.Sound
    Gets the sound to play when the item is equipped.
    @Nullable org.bukkit.NamespacedKey
    Gets the key of the model to use when equipped.
    @NotNull org.bukkit.inventory.EquipmentSlot
    Gets the slot the item can be equipped to.
    boolean
    Checks if the equipment takes damage when the wearer is hurt.
    boolean
    Gets whether the item can be equipped by a dispenser.
    boolean
    Gets if the item is swappable by right-clicking.
    @NotNull Map<String,Object>
    Serializes this component into a map of key-value pairs.
    void
    setAllowedEntities(@Nullable Collection<org.bukkit.entity.EntityType> entities)
    Sets the entities which can equip this item.
    void
    setAllowedEntities(@Nullable org.bukkit.Tag<org.bukkit.entity.EntityType> tag)
    Set the entity types (represented as an entity Tag) which can equip this item.
    void
    setAllowedEntities(@Nullable org.bukkit.entity.EntityType entity)
    Sets the entity which can equip this item.
    void
    setCameraOverlay(@Nullable org.bukkit.NamespacedKey key)
    Sets the key of the camera overlay to use when equipped.
    void
    setDamageOnHurt(boolean damage)
    Sets whether the equipment takes damage when the wearer is hurt.
    void
    setDispensable(boolean dispensable)
    Sets whether the item can be equipped by a dispenser.
    void
    setEquipSound(@Nullable org.bukkit.Sound sound)
    Sets the sound to play when the item is equipped.
    void
    setModel(@Nullable org.bukkit.NamespacedKey key)
    Sets the key of the model to use when equipped.
    void
    setSlot(@NotNull org.bukkit.inventory.EquipmentSlot slot)
    Sets the slot the item can be equipped to.
    void
    setSwappable(boolean swappable)
    Sets if the item is swappable by right-clicking.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomEquippableComponent

      public CustomEquippableComponent(org.bukkit.inventory.EquipmentSlot equipmentSlot)
      Constructs a new CustomEquippableComponent with the given equipment slot and default values.
      Parameters:
      equipmentSlot - the slot where the equipment can be placed
  • Method Details

    • getSlot

      @NotNull public @NotNull org.bukkit.inventory.EquipmentSlot getSlot()
      Gets the slot the item can be equipped to.
      Specified by:
      getSlot in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      the equipment slot
    • setSlot

      public void setSlot(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot slot)
      Sets the slot the item can be equipped to.
      Specified by:
      setSlot in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      slot - the new equipment slot
    • getEquipSound

      @Nullable public @Nullable org.bukkit.Sound getEquipSound()
      Gets the sound to play when the item is equipped.
      Specified by:
      getEquipSound in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      the equip sound, or null if none is set
    • setEquipSound

      public void setEquipSound(@Nullable @Nullable org.bukkit.Sound sound)
      Sets the sound to play when the item is equipped.
      Specified by:
      setEquipSound in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      sound - the new equipped sound, or null to remove the sound
    • getModel

      @Nullable public @Nullable org.bukkit.NamespacedKey getModel()
      Gets the key of the model to use when equipped.
      Specified by:
      getModel in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      the model key, or null if none is set
    • setModel

      public void setModel(@Nullable @Nullable org.bukkit.NamespacedKey key)
      Sets the key of the model to use when equipped.
      Specified by:
      setModel in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      key - the new model key, or null to remove the model
    • getCameraOverlay

      @Nullable public @Nullable org.bukkit.NamespacedKey getCameraOverlay()
      Gets the key of the camera overlay to use when equipped.
      Specified by:
      getCameraOverlay in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      the camera overlay key, or null if none is set
    • setCameraOverlay

      public void setCameraOverlay(@Nullable @Nullable org.bukkit.NamespacedKey key)
      Sets the key of the camera overlay to use when equipped.
      Specified by:
      setCameraOverlay in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      key - the new camera overlay key, or null to remove the overlay
    • getAllowedEntities

      @Nullable public @Nullable Collection<org.bukkit.entity.EntityType> getAllowedEntities()
      Gets the entities which can equip this item.
      Specified by:
      getAllowedEntities in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      a collection of allowed entity types
    • setAllowedEntities

      public void setAllowedEntities(@Nullable @Nullable org.bukkit.entity.EntityType entity)
      Sets the entity which can equip this item.
      Specified by:
      setAllowedEntities in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      entity - the allowed entity, or null to clear the list
    • setAllowedEntities

      public void setAllowedEntities(@Nullable @Nullable Collection<org.bukkit.entity.EntityType> entities)
      Sets the entities which can equip this item.
      Specified by:
      setAllowedEntities in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      entities - a collection of allowed entities, or null to clear the list
    • setAllowedEntities

      public void setAllowedEntities(@Nullable @Nullable org.bukkit.Tag<org.bukkit.entity.EntityType> tag)
      Set the entity types (represented as an entity Tag) which can equip this item.
      Specified by:
      setAllowedEntities in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      tag - the tag containing allowed entities, or null to clear the list
    • isDispensable

      public boolean isDispensable()
      Gets whether the item can be equipped by a dispenser.
      Specified by:
      isDispensable in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      true if dispensable, false otherwise
    • setDispensable

      public void setDispensable(boolean dispensable)
      Sets whether the item can be equipped by a dispenser.
      Specified by:
      setDispensable in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      dispensable - true to make it dispensable, false otherwise
    • isSwappable

      public boolean isSwappable()
      Gets if the item is swappable by right-clicking.
      Specified by:
      isSwappable in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      true if swappable, false otherwise
    • setSwappable

      public void setSwappable(boolean swappable)
      Sets if the item is swappable by right-clicking.
      Specified by:
      setSwappable in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      swappable - true to make it swappable, false otherwise
    • isDamageOnHurt

      public boolean isDamageOnHurt()
      Checks if the equipment takes damage when the wearer is hurt.
      Specified by:
      isDamageOnHurt in interface org.bukkit.inventory.meta.components.EquippableComponent
      Returns:
      true if it takes damage, false otherwise
    • setDamageOnHurt

      public void setDamageOnHurt(boolean damage)
      Sets whether the equipment takes damage when the wearer is hurt.
      Specified by:
      setDamageOnHurt in interface org.bukkit.inventory.meta.components.EquippableComponent
      Parameters:
      damage - true to enable damage on hurt, false otherwise
    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      Serializes this component into a map of key-value pairs.
      Specified by:
      serialize in interface org.bukkit.configuration.serialization.ConfigurationSerializable
      Returns:
      a map containing the serialized data