Interface Enchantment
- All Superinterfaces:
DataSerializable
Represents an
EnchantmentType on an ItemStack that is paired
with a level.
The contract of enchantments is that their level will always be between
Short.MIN_VALUE and Short.MAX_VALUE, but it is not guaranteed
they will work properly outside of EnchantmentType.minimumLevel()
and EnchantmentType.maximumLevel().
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a builder interface which can be used to create aEnchantment.static interfaceRepresents a builder interface which can be used to create aEnchantment. -
Method Summary
Modifier and TypeMethodDescriptionstatic Enchantment.Builderbuilder()Creates a newEnchantment.Builderto create anEnchantment.intlevel()Gets the level of this enchantment.static Enchantmentof(Supplier<? extends EnchantmentType> enchantmentType, int level) Creates a newEnchantmentwith the providedEnchantmentTypeand level.static Enchantmentof(EnchantmentType enchantmentType, int level) Creates a newEnchantmentwith the providedEnchantmentTypeand level.Creates a newEnchantment.RandomListBuilderto create a random list ofEnchantments.type()Gets theEnchantmentTypefor this enchantment.Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
Method Details
-
builder
Creates a newEnchantment.Builderto create anEnchantment.- Returns:
- The new builder
-
randomListBuilder
Creates a newEnchantment.RandomListBuilderto create a random list ofEnchantments.- Returns:
- The new random list builder
-
of
static Enchantment of(Supplier<? extends EnchantmentType> enchantmentType, int level) throws IllegalArgumentException Creates a newEnchantmentwith the providedEnchantmentTypeand level.- Parameters:
enchantmentType- The enchantment typelevel- The enchantment level- Returns:
- The created enchantment
- Throws:
IllegalArgumentException- If the level is smaller thanShort.MIN_VALUEor larger thanShort.MAX_VALUE
-
of
Creates a newEnchantmentwith the providedEnchantmentTypeand level.- Parameters:
enchantmentType- The enchantment typelevel- The enchantment level- Returns:
- The created enchantment
- Throws:
IllegalArgumentException- If the level is smaller thanShort.MIN_VALUEor larger thanShort.MAX_VALUE
-
type
EnchantmentType type()Gets theEnchantmentTypefor this enchantment.- Returns:
- The enchantment type of this enchantment
-
level
int level()Gets the level of this enchantment.- Returns:
- The level of this enchantment
-