Interface Enchantment
-
- All Superinterfaces:
DataSerializable
public interface Enchantment extends DataSerializable
Represents anEnchantmentType
on anItemStack
that is paired with a level.The contract of enchantments is that their level will always be between
Short.MIN_VALUE
andShort.MAX_VALUE
, but it is not guaranteed they will work properly outside ofEnchantmentType.minimumLevel()
andEnchantmentType.maximumLevel()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Enchantment.Builder
Represents a builder interface which can be used to create aEnchantment
.static interface
Enchantment.RandomListBuilder
Represents a builder interface which can be used to create aEnchantment
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static 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.static Enchantment.RandomListBuilder
randomListBuilder()
Creates a newEnchantment.RandomListBuilder
to create a random list ofEnchantment
s.EnchantmentType
type()
Gets theEnchantmentType
for this enchantment.-
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
-
-
-
Method Detail
-
builder
static Enchantment.Builder builder()
Creates a newEnchantment.Builder
to create anEnchantment
.- Returns:
- The new builder
-
randomListBuilder
static Enchantment.RandomListBuilder 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
static Enchantment of(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
-
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
-
-