Interface Enchantment.Builder
-
- All Superinterfaces:
AbstractBuilder<Enchantment>
,Buildable.Builder<Enchantment>
,Builder<Enchantment,Enchantment.Builder>
,CopyableBuilder<Enchantment,Enchantment.Builder>
,DataBuilder<Enchantment>
,ResettableBuilder<Enchantment,Enchantment.Builder>
- Enclosing interface:
- Enchantment
public static interface Enchantment.Builder extends Builder<Enchantment,Enchantment.Builder>, CopyableBuilder<Enchantment,Enchantment.Builder>, DataBuilder<Enchantment>
Represents a builder interface which can be used to create aEnchantment
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Enchantment
build()
Builds an instance of aEnchantment
based on the entered information.Enchantment.Builder
level(int level)
Sets the level for this enchantment.default Enchantment.Builder
type(java.util.function.Supplier<? extends EnchantmentType> enchantmentType)
Sets theEnchantmentType
for this enchantment.Enchantment.Builder
type(EnchantmentType enchantmentType)
Sets theEnchantmentType
for this enchantment.-
Methods inherited from interface org.spongepowered.api.util.CopyableBuilder
from
-
Methods inherited from interface org.spongepowered.api.data.persistence.DataBuilder
build
-
-
-
-
Method Detail
-
type
Enchantment.Builder type(EnchantmentType enchantmentType)
Sets theEnchantmentType
for this enchantment.- Parameters:
enchantmentType
- The desired enchantment type- Returns:
- The modified builder, for chaining
-
type
default Enchantment.Builder type(java.util.function.Supplier<? extends EnchantmentType> enchantmentType)
Sets theEnchantmentType
for this enchantment.- Parameters:
enchantmentType
- The desired enchantment type- Returns:
- The modified builder, for chaining
-
level
Enchantment.Builder level(int level) throws java.lang.IllegalArgumentException
Sets the level for this enchantment.This level must be between
Short.MIN_VALUE
andShort.MAX_VALUE
, but there is no guarantee all levels will work properly without error. It is recommended for reliable results you stay betweenEnchantmentType.minimumLevel()
andEnchantmentType.maximumLevel()
, or at least larger than0
and less thanShort.MAX_VALUE
.- Parameters:
level
- The desired level- Returns:
- The modified builder for chaining
- Throws:
java.lang.IllegalArgumentException
- If the level is smaller thanShort.MIN_VALUE
or larger thanShort.MAX_VALUE
-
build
Enchantment build() throws java.lang.IllegalStateException
Builds an instance of aEnchantment
based on the entered information.- Specified by:
build
in interfaceAbstractBuilder<Enchantment>
- Specified by:
build
in interfaceBuildable.Builder<Enchantment>
- Returns:
- The created enchantment
- Throws:
java.lang.IllegalStateException
- If a required value was not specified
-
-