Package org.bukkit.potion
Class Potion
java.lang.Object
org.bukkit.potion.Potion
public class Potion
extends java.lang.Object
Represents a minecraft potion
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPotion.TierDeprecated. -
Constructor Summary
Constructors Constructor Description Potion(int name)Create a potion with a specific name.Potion(PotionType type)Construct a new potion of the given type.Potion(PotionType type, int level)Create a new potion of the given type and level.Potion(PotionType type, int level, boolean splash)Deprecated.In favour of usingPotion(PotionType)withsplash().Potion(PotionType type, int level, boolean splash, boolean extended)Deprecated.Potion(PotionType type, Potion.Tier tier)Deprecated.In favour ofPotion(PotionType, int)Potion(PotionType type, Potion.Tier tier, boolean splash)Deprecated.In favour ofPotion(PotionType, int, boolean)Potion(PotionType type, Potion.Tier tier, boolean splash, boolean extended)Deprecated.In favour ofPotion(PotionType, int, boolean, boolean) -
Method Summary
Modifier and Type Method Description voidapply(LivingEntity to)Applies the effects that would be applied by this potion to the givenLivingEntity.voidapply(ItemStack to)Applies the effects of this potion to the givenItemStack.booleanequals(java.lang.Object obj)Potionextend()Chain this to the constructor to extend the potion's duration.static PotionfromDamage(int damage)Deprecated.Magic valuestatic PotionfromItemStack(ItemStack item)static PotionBrewergetBrewer()Returns an instance ofPotionBrewer.java.util.Collection<PotionEffect>getEffects()intgetLevel()Returns the level of this potion.intgetNameId()Deprecated.Magic valuePotion.TiergetTier()Deprecated.PotionTypegetType()Returns thePotionTypeof this potion.booleanhasExtendedDuration()Returns whether this potion has an extended duration.inthashCode()booleanisSplash()Returns whether this potion is a splash potion.voidsetHasExtendedDuration(boolean isExtended)Set whether this potion has extended duration.voidsetLevel(int level)Sets the level of this potion.static voidsetPotionBrewer(PotionBrewer other)Sets the current instance ofPotionBrewer.voidsetSplash(boolean isSplash)Sets whether this potion is a splash potion.voidsetTier(Potion.Tier tier)Deprecated.In favour ofsetLevel(int)voidsetType(PotionType type)Sets thePotionTypeof this potion.Potionsplash()Chain this to the constructor to make the potion a splash potion.shorttoDamageValue()Deprecated.Magic valueItemStacktoItemStack(int amount)Converts this potion to anItemStackwith the specified amount and a correct damage value.
-
Constructor Details
-
Potion
Construct a new potion of the given type. Unless the type isPotionType.WATER, it will be level one, without extended duration. Don't use this constructor to create a no-effect potion other than water bottle.- Parameters:
type- The potion type- See Also:
Potion(int)
-
Potion
Deprecated.In favour ofPotion(PotionType, int)- Parameters:
type- the type of the potiontier- the tier of the potion
-
Potion
Deprecated.In favour ofPotion(PotionType, int, boolean)- Parameters:
type- the type of the potiontier- the tier of the potionsplash- whether the potion is a splash potion
-
Potion
Deprecated.In favour ofPotion(PotionType, int, boolean, boolean)- Parameters:
type- the type of the potiontier- the tier of the potionsplash- whether the potion is a splash potionextended- whether the potion has an extended duration
-
Potion
Create a new potion of the given type and level.- Parameters:
type- The type of potion.level- The potion's level.
-
Potion
Deprecated.In favour of usingPotion(PotionType)withsplash().Create a new potion of the given type and level.- Parameters:
type- The type of potion.level- The potion's level.splash- Whether it is a splash potion.
-
Potion
Deprecated.Create a new potion of the given type and level.- Parameters:
type- The type of potion.level- The potion's level.splash- Whether it is a splash potion.extended- Whether it has an extended duration.
-
Potion
public Potion(int name)Create a potion with a specific name.- Parameters:
name- The name index (0-63)
-
-
Method Details
-
splash
Chain this to the constructor to make the potion a splash potion.- Returns:
- The potion.
-
extend
Chain this to the constructor to extend the potion's duration.- Returns:
- The potion.
-
apply
Applies the effects of this potion to the givenItemStack. The ItemStack must be a potion.- Parameters:
to- The itemstack to apply to
-
apply
Applies the effects that would be applied by this potion to the givenLivingEntity.- Parameters:
to- The entity to apply the effects to- See Also:
LivingEntity.addPotionEffects(Collection)
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
getEffects
- Returns:
- The effects that this potion applies
- See Also:
PotionBrewer.getEffectsFromDamage(int),toDamageValue()
-
getLevel
public int getLevel()Returns the level of this potion.- Returns:
- The level of this potion
-
getTier
Deprecated.Returns thePotion.Tierof this potion.- Returns:
- The tier of this potion
-
getType
Returns thePotionTypeof this potion.- Returns:
- The type of this potion
-
hasExtendedDuration
public boolean hasExtendedDuration()Returns whether this potion has an extended duration.- Returns:
- Whether this potion has extended duration
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
isSplash
public boolean isSplash()Returns whether this potion is a splash potion.- Returns:
- Whether this is a splash potion
-
setHasExtendedDuration
public void setHasExtendedDuration(boolean isExtended)Set whether this potion has extended duration. This will cause the potion to have roughly 8/3 more duration than a regular potion.- Parameters:
isExtended- Whether the potion should have extended duration
-
setSplash
public void setSplash(boolean isSplash)Sets whether this potion is a splash potion. Splash potions can be thrown for a radius effect.- Parameters:
isSplash- Whether this is a splash potion
-
setTier
Deprecated.In favour ofsetLevel(int)Sets thePotion.Tierof this potion.- Parameters:
tier- The new tier of this potion
-
setType
Sets thePotionTypeof this potion.- Parameters:
type- The new type of this potion
-
setLevel
public void setLevel(int level)Sets the level of this potion.- Parameters:
level- The new level of this potion
-
toDamageValue
@Deprecated public short toDamageValue()Deprecated.Magic valueConverts this potion to a valid potion damage short, usable for potion item stacks.- Returns:
- The damage value of this potion
-
toItemStack
Converts this potion to anItemStackwith the specified amount and a correct damage value.- Parameters:
amount- The amount of the ItemStack- Returns:
- The created ItemStack
-
fromDamage
Deprecated.Magic value- Parameters:
damage- the damage value- Returns:
- the produced potion
-
fromItemStack
-
getBrewer
Returns an instance ofPotionBrewer.- Returns:
- An instance of PotionBrewer
-
setPotionBrewer
Sets the current instance ofPotionBrewer. Generally not to be used from within a plugin.- Parameters:
other- The new PotionBrewer
-
getNameId
@Deprecated public int getNameId()Deprecated.Magic value- Returns:
- the name id
-