ItemEnchantmentHandlingTrait
This trait encapsulates all enchantment handling needed for itemstacks.
The primary purpose of this trait is providing scope isolation for the methods it contains.
Table of Contents
- $enchantments : array<string|int, EnchantmentInstance>
- addEnchantment() : $this
- getEnchantment() : EnchantmentInstance|null
- getEnchantmentLevel() : int
- Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the enchantment.
- getEnchantments() : array<string|int, EnchantmentInstance>
- hasEnchantment() : bool
- hasEnchantments() : bool
- removeEnchantment() : $this
- removeEnchantments() : $this
Properties
$enchantments
protected
array<string|int, EnchantmentInstance>
$enchantments
= []
Methods
addEnchantment()
public
addEnchantment(EnchantmentInstance $enchantment) : $this
Parameters
- $enchantment : EnchantmentInstance
Return values
$this —getEnchantment()
public
getEnchantment(Enchantment $enchantment) : EnchantmentInstance|null
Parameters
- $enchantment : Enchantment
Return values
EnchantmentInstance|null —getEnchantmentLevel()
Returns the level of the enchantment on this item with the specified ID, or 0 if the item does not have the enchantment.
public
getEnchantmentLevel(Enchantment $enchantment) : int
Parameters
- $enchantment : Enchantment
Return values
int —getEnchantments()
public
getEnchantments() : array<string|int, EnchantmentInstance>
Return values
array<string|int, EnchantmentInstance> —hasEnchantment()
public
hasEnchantment(Enchantment $enchantment[, int $level = -1 ]) : bool
Parameters
- $enchantment : Enchantment
- $level : int = -1
Return values
bool —hasEnchantments()
public
hasEnchantments() : bool
Return values
bool —removeEnchantment()
public
removeEnchantment(Enchantment $enchantment[, int $level = -1 ]) : $this
Parameters
- $enchantment : Enchantment
- $level : int = -1
Return values
$this —removeEnchantments()
public
removeEnchantments() : $this