Class TeamEnchantment
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionTeamEnchantment
(TeamEnchantment.Target target, Enchantment ench, int lvl) TeamEnchantment
(Predicate<ItemStack> targetPredicate, String targetId, Enchantment ench, int lvl) You generally should useTeamEnchantment(Target, Enchantment, int)
instead. -
Method Summary
Modifier and TypeMethodDescriptionGet the enchantment that shall be applied on the items.int
getLevel()
Get the level of the enchantment that gets appliedGet the broad item target this enchantment should target.Get the id of the target.boolean
Get whether this enchantment is applicable to the given material.
-
Constructor Details
-
TeamEnchantment
- Parameters:
target
- The item type it should targetench
- The enchantmentlvl
- The level of the enchantment
-
TeamEnchantment
public TeamEnchantment(Predicate<ItemStack> targetPredicate, String targetId, Enchantment ench, int lvl) You generally should use
TeamEnchantment(Target, Enchantment, int)
instead. This constructor, however, allows you to be more precise with the items that should be enchanted.The targetPredicate should always return the same result for the same material. If it does not, then unexpected behavior might occur.
- Parameters:
targetPredicate
- The predicate that determines if an item should be enchantedtargetId
- The id of the target. Multiple enchantments with the same targetId will be combined into oneench
- The enchantmentlvl
- The level of the enchantment
-
-
Method Details
-
getTarget
Get the broad item target this enchantment should target.- Returns:
- The items for which the enchantment gets applied on
-
isApplicable
Get whether this enchantment is applicable to the given material.E.g. if the target is
TeamEnchantment.Target.PICKAXE
and the material isMaterial.DIAMOND_PICKAXE
, this method would returntrue
. If the material would however beMaterial.DIRT
, this method would returnfalse
.- Parameters:
is
- The item to test- Returns:
true
if the enchantment is applicable,false
otherwise
-
getTargetId
Get the id of the target.If a player buys an enchantment with the same targetId multiple times, then the older one with the equal targetId will be replaced by the newer one.
Built-in targets (those that are not
TeamEnchantment.Target.CUSTOM
) will returnEnum.name()
.- Returns:
- The id of the target
-
getEnchantment
Get the enchantment that shall be applied on the items.- Returns:
- The enchantment that gets applied
-
getLevel
public int getLevel()Get the level of the enchantment that gets applied- Returns:
- The level of the enchantment that gets applied
-