Package org.bukkit.enchantments
Class Enchantment
java.lang.Object
org.bukkit.enchantments.Enchantment
- Direct Known Subclasses:
EnchantmentWrapper
public abstract class Enchantment
extends java.lang.Object
The various type of enchantments that may be added to armour or weapons
-
Field Summary
Fields Modifier and Type Field Description static EnchantmentARROW_DAMAGEProvides extra damage when shooting arrows from bowsstatic EnchantmentARROW_FIRESets entities on fire when hit by arrows shot from a bowstatic EnchantmentARROW_INFINITEProvides infinite arrows when shooting a bowstatic EnchantmentARROW_KNOCKBACKProvides a knockback when an entity is hit by an arrow from a bowstatic EnchantmentDAMAGE_ALLIncreases damage against all targetsstatic EnchantmentDAMAGE_ARTHROPODSIncreases damage against arthropod targetsstatic EnchantmentDAMAGE_UNDEADIncreases damage against undead targetsstatic EnchantmentDEPTH_STRIDERIncreases walking speed while in waterstatic EnchantmentDIG_SPEEDIncreases the rate at which you mine/digstatic EnchantmentDURABILITYDecreases the rate at which a tool looses durabilitystatic EnchantmentFIRE_ASPECTWhen attacking a target, has a chance to set them on firestatic EnchantmentKNOCKBACKAll damage to other targets will knock them back when hitstatic EnchantmentLOOT_BONUS_BLOCKSProvides a chance of gaining extra loot when destroying blocksstatic EnchantmentLOOT_BONUS_MOBSProvides a chance of gaining extra loot when killing monstersstatic EnchantmentLUCKDecreases odds of catching worthless junkstatic EnchantmentLUREIncreases rate of fish biting your hookstatic EnchantmentOXYGENDecreases the rate of air loss whilst underwaterstatic EnchantmentPROTECTION_ENVIRONMENTALProvides protection against environmental damagestatic EnchantmentPROTECTION_EXPLOSIONSProvides protection against explosive damagestatic EnchantmentPROTECTION_FALLProvides protection against fall damagestatic EnchantmentPROTECTION_FIREProvides protection against fire damagestatic EnchantmentPROTECTION_PROJECTILEProvides protection against projectile damagestatic EnchantmentSILK_TOUCHAllows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone)static EnchantmentTHORNSDamages the attackerstatic EnchantmentWATER_WORKERIncreases the speed at which a player may mine underwater -
Constructor Summary
Constructors Constructor Description Enchantment(int id) -
Method Summary
Modifier and Type Method Description abstract booleancanEnchantItem(ItemStack item)Checks if this Enchantment may be applied to the givenItemStack.abstract booleanconflictsWith(Enchantment other)Check if this enchantment conflicts with another enchantment.booleanequals(java.lang.Object obj)static EnchantmentgetById(int id)Deprecated.Magic valuestatic EnchantmentgetByName(java.lang.String name)Gets the Enchantment at the specified nameintgetId()Deprecated.Magic valueabstract EnchantmentTargetgetItemTarget()Gets the type ofItemStackthat may fit this Enchantment.abstract intgetMaxLevel()Gets the maximum level that this Enchantment may become.abstract java.lang.StringgetName()Gets the unique name of this enchantmentabstract intgetStartLevel()Gets the level that this Enchantment should start atinthashCode()static booleanisAcceptingRegistrations()Checks if this is accepting Enchantment registrations.static voidregisterEnchantment(Enchantment enchantment)Registers an enchantment with the given ID and object.static voidstopAcceptingRegistrations()Stops accepting any enchantment registrationsjava.lang.StringtoString()static Enchantment[]values()Gets an array of all the registeredEnchantments
-
Field Details
-
PROTECTION_ENVIRONMENTAL
Provides protection against environmental damage -
PROTECTION_FIRE
Provides protection against fire damage -
PROTECTION_FALL
Provides protection against fall damage -
PROTECTION_EXPLOSIONS
Provides protection against explosive damage -
PROTECTION_PROJECTILE
Provides protection against projectile damage -
OXYGEN
Decreases the rate of air loss whilst underwater -
WATER_WORKER
Increases the speed at which a player may mine underwater -
THORNS
Damages the attacker -
DEPTH_STRIDER
Increases walking speed while in water -
DAMAGE_ALL
Increases damage against all targets -
DAMAGE_UNDEAD
Increases damage against undead targets -
DAMAGE_ARTHROPODS
Increases damage against arthropod targets -
KNOCKBACK
All damage to other targets will knock them back when hit -
FIRE_ASPECT
When attacking a target, has a chance to set them on fire -
LOOT_BONUS_MOBS
Provides a chance of gaining extra loot when killing monsters -
DIG_SPEED
Increases the rate at which you mine/dig -
SILK_TOUCH
Allows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone) -
DURABILITY
Decreases the rate at which a tool looses durability -
LOOT_BONUS_BLOCKS
Provides a chance of gaining extra loot when destroying blocks -
ARROW_DAMAGE
Provides extra damage when shooting arrows from bows -
ARROW_KNOCKBACK
Provides a knockback when an entity is hit by an arrow from a bow -
ARROW_FIRE
Sets entities on fire when hit by arrows shot from a bow -
ARROW_INFINITE
Provides infinite arrows when shooting a bow -
LUCK
Decreases odds of catching worthless junk -
LURE
Increases rate of fish biting your hook
-
-
Constructor Details
-
Enchantment
public Enchantment(int id)
-
-
Method Details
-
getId
@Deprecated public int getId()Deprecated.Magic valueGets the unique ID of this enchantment- Returns:
- Unique ID
-
getName
public abstract java.lang.String getName()Gets the unique name of this enchantment- Returns:
- Unique name
-
getMaxLevel
public abstract int getMaxLevel()Gets the maximum level that this Enchantment may become.- Returns:
- Maximum level of the Enchantment
-
getStartLevel
public abstract int getStartLevel()Gets the level that this Enchantment should start at- Returns:
- Starting level of the Enchantment
-
getItemTarget
Gets the type ofItemStackthat may fit this Enchantment.- Returns:
- Target type of the Enchantment
-
conflictsWith
Check if this enchantment conflicts with another enchantment.- Parameters:
other- The enchantment to check against- Returns:
- True if there is a conflict.
-
canEnchantItem
Checks if this Enchantment may be applied to the givenItemStack.This does not check if it conflicts with any enchantments already applied to the item.
- Parameters:
item- Item to test- Returns:
- True if the enchantment may be applied, otherwise False
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
registerEnchantment
Registers an enchantment with the given ID and object.Generally not to be used from within a plugin.
- Parameters:
enchantment- Enchantment to register
-
isAcceptingRegistrations
public static boolean isAcceptingRegistrations()Checks if this is accepting Enchantment registrations.- Returns:
- True if the server Implementation may add enchantments
-
stopAcceptingRegistrations
public static void stopAcceptingRegistrations()Stops accepting any enchantment registrations -
getById
Deprecated.Magic valueGets the Enchantment at the specified ID- Parameters:
id- ID to fetch- Returns:
- Resulting Enchantment, or null if not found
-
getByName
Gets the Enchantment at the specified name- Parameters:
name- Name to fetch- Returns:
- Resulting Enchantment, or null if not found
-
values
Gets an array of all the registeredEnchantments- Returns:
- Array of enchantments
-