Interface Enchantment
-
- All Superinterfaces:
DataSerializable
public interface Enchantment extends DataSerializable
Represents anEnchantmentTypeon anItemStackthat is paired with a level.The contract of enchantments is that their level will always be between
Short.MIN_VALUEandShort.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 interfaceEnchantment.BuilderRepresents a builder interface which can be used to create aEnchantment.static interfaceEnchantment.RandomListBuilderRepresents 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.Builderbuilder()Creates a newEnchantment.Builderto create anEnchantment.intlevel()Gets the level of this enchantment.static Enchantmentof(java.util.function.Supplier<? extends EnchantmentType> enchantmentType, int level)Creates a newEnchantmentwith the providedEnchantmentTypeand level.static Enchantmentof(EnchantmentType enchantmentType, int level)Creates a newEnchantmentwith the providedEnchantmentTypeand level.static Enchantment.RandomListBuilderrandomListBuilder()Creates a newEnchantment.RandomListBuilderto create a random list ofEnchantments.EnchantmentTypetype()Gets theEnchantmentTypefor this enchantment.-
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
-
-
-
Method Detail
-
builder
static Enchantment.Builder builder()
Creates a newEnchantment.Builderto create anEnchantment.- Returns:
- The new builder
-
randomListBuilder
static Enchantment.RandomListBuilder randomListBuilder()
Creates a newEnchantment.RandomListBuilderto create a random list ofEnchantments.- Returns:
- The new random list builder
-
of
static Enchantment of(java.util.function.Supplier<? extends EnchantmentType> enchantmentType, int level) throws java.lang.IllegalArgumentException
Creates a newEnchantmentwith the providedEnchantmentTypeand level.- Parameters:
enchantmentType- The enchantment typelevel- The enchantment level- Returns:
- The created enchantment
- Throws:
java.lang.IllegalArgumentException- If the level is smaller thanShort.MIN_VALUEor larger thanShort.MAX_VALUE
-
of
static Enchantment of(EnchantmentType enchantmentType, int level) throws java.lang.IllegalArgumentException
Creates a newEnchantmentwith the providedEnchantmentTypeand level.- Parameters:
enchantmentType- The enchantment typelevel- The enchantment level- Returns:
- The created enchantment
- Throws:
java.lang.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
-
-