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
ConstructorsConstructorDescriptionCustomEquippableComponent(org.bukkit.inventory.EquipmentSlot equipmentSlot) Constructs a new CustomEquippableComponent with the given equipment slot and default values. -
Method Summary
Modifier and TypeMethodDescription@Nullable Collection<org.bukkit.entity.EntityType> Gets the entities which can equip this item.@Nullable org.bukkit.NamespacedKeyGets the key of the camera overlay to use when equipped.@Nullable org.bukkit.SoundGets the sound to play when the item is equipped.@Nullable org.bukkit.NamespacedKeygetModel()Gets the key of the model to use when equipped.@NotNull org.bukkit.inventory.EquipmentSlotgetSlot()Gets the slot the item can be equipped to.booleanChecks if the equipment takes damage when the wearer is hurt.booleanGets whether the item can be equipped by a dispenser.booleanGets if the item is swappable by right-clicking.Serializes this component into a map of key-value pairs.voidsetAllowedEntities(@Nullable Collection<org.bukkit.entity.EntityType> entities) Sets the entities which can equip this item.voidsetAllowedEntities(@Nullable org.bukkit.Tag<org.bukkit.entity.EntityType> tag) Set the entity types (represented as an entityTag) which can equip this item.voidsetAllowedEntities(@Nullable org.bukkit.entity.EntityType entity) Sets the entity which can equip this item.voidsetCameraOverlay(@Nullable org.bukkit.NamespacedKey key) Sets the key of the camera overlay to use when equipped.voidsetDamageOnHurt(boolean damage) Sets whether the equipment takes damage when the wearer is hurt.voidsetDispensable(boolean dispensable) Sets whether the item can be equipped by a dispenser.voidsetEquipSound(@Nullable org.bukkit.Sound sound) Sets the sound to play when the item is equipped.voidsetModel(@Nullable org.bukkit.NamespacedKey key) Sets the key of the model to use when equipped.voidsetSlot(@NotNull org.bukkit.inventory.EquipmentSlot slot) Sets the slot the item can be equipped to.voidsetSwappable(boolean swappable) Sets if the item is swappable by right-clicking.
-
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:
getSlotin interfaceorg.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:
setSlotin interfaceorg.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:
getEquipSoundin interfaceorg.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:
setEquipSoundin interfaceorg.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:
getModelin interfaceorg.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:
setModelin interfaceorg.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:
getCameraOverlayin interfaceorg.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:
setCameraOverlayin interfaceorg.bukkit.inventory.meta.components.EquippableComponent- Parameters:
key- the new camera overlay key, or null to remove the overlay
-
getAllowedEntities
Gets the entities which can equip this item.- Specified by:
getAllowedEntitiesin interfaceorg.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:
setAllowedEntitiesin interfaceorg.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:
setAllowedEntitiesin interfaceorg.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 entityTag) which can equip this item.- Specified by:
setAllowedEntitiesin interfaceorg.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:
isDispensablein interfaceorg.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:
setDispensablein interfaceorg.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:
isSwappablein interfaceorg.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:
setSwappablein interfaceorg.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:
isDamageOnHurtin interfaceorg.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:
setDamageOnHurtin interfaceorg.bukkit.inventory.meta.components.EquippableComponent- Parameters:
damage- true to enable damage on hurt, false otherwise
-
serialize
Serializes this component into a map of key-value pairs.- Specified by:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable- Returns:
- a map containing the serialized data
-