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
Modifier and TypeInterfaceDescriptionstatic interface
Represents a builder interface which can be used to create aEnchantment
.static interface
Represents a builder interface which can be used to create aEnchantment
. -
Method Summary
Modifier and TypeMethodDescriptionstatic Enchantment.Builder
builder()
Creates a newEnchantment.Builder
to create anEnchantment
.int
level()
Gets the level of this enchantment.static Enchantment
of
(Supplier<? extends EnchantmentType> enchantmentType, int level) Creates a newEnchantment
with the providedEnchantmentType
and level.static Enchantment
of
(EnchantmentType enchantmentType, int level) Creates a newEnchantment
with the providedEnchantmentType
and level.Creates a newEnchantment.RandomListBuilder
to create a random list ofEnchantment
s.type()
Gets theEnchantmentType
for this enchantment.Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
Method Details
-
builder
Creates a newEnchantment.Builder
to create anEnchantment
.- Returns:
- The new builder
-
randomListBuilder
Creates a newEnchantment.RandomListBuilder
to create a random list ofEnchantment
s.- Returns:
- The new random list builder
-
of
static Enchantment of(Supplier<? extends EnchantmentType> enchantmentType, int level) throws IllegalArgumentException Creates a newEnchantment
with the providedEnchantmentType
and level.- Parameters:
enchantmentType
- The enchantment typelevel
- The enchantment level- Returns:
- The created enchantment
- Throws:
IllegalArgumentException
- If the level is smaller thanShort.MIN_VALUE
or larger thanShort.MAX_VALUE
-
of
Creates a newEnchantment
with the providedEnchantmentType
and level.- Parameters:
enchantmentType
- The enchantment typelevel
- The enchantment level- Returns:
- The created enchantment
- Throws:
IllegalArgumentException
- If the level is smaller thanShort.MIN_VALUE
or larger thanShort.MAX_VALUE
-
type
EnchantmentType type()Gets theEnchantmentType
for this enchantment.- Returns:
- The enchantment type of this enchantment
-
level
int level()Gets the level of this enchantment.- Returns:
- The level of this enchantment
-