Package org.bukkit.potion
Class PotionEffect
- java.lang.Object
-
- org.bukkit.potion.PotionEffect
-
- All Implemented Interfaces:
ConfigurationSerializable
public class PotionEffect extends Object implements ConfigurationSerializable
Represents a potion effect, that can be added to aLivingEntity. A potion effect has a duration that it will last for, an amplifier that will enhance its effects, and aPotionEffectType, that represents its effect on an entity.
-
-
Constructor Summary
Constructors Constructor Description PotionEffect(@NotNull Map<String,Object> map)Constructor for deserialization.PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier)Creates a potion effect.PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient)Creates a potion effect.PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles)Creates a potion effect with no defined color.PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon)Creates a potion effect.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanapply(@NotNull LivingEntity entity)Attempts to add the effect represented by this object to the givenLivingEntity.booleanequals(Object obj)intgetAmplifier()Returns the amplifier of this effect.@Nullable ColorgetColor()Deprecated.color is not part of potion effectsintgetDuration()Returns the duration (in ticks) that this effect will run for when applied to aLivingEntity.@NotNull PotionEffectTypegetType()Returns thePotionEffectTypeof this effect.inthashCode()booleanhasIcon()booleanhasParticles()booleanisAmbient()Makes potion effect produce more, translucent, particles.@NotNull Map<String,Object>serialize()Creates a Map representation of this class.StringtoString()
-
-
-
Constructor Detail
-
PotionEffect
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon)Creates a potion effect.- Parameters:
type- effect typeduration- measured in ticks, seegetDuration()amplifier- the amplifier, seegetAmplifier()ambient- the ambient status, seeisAmbient()particles- the particle status, seehasParticles()icon- the icon status, seehasIcon()
-
PotionEffect
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles)Creates a potion effect with no defined color.- Parameters:
type- effect typeduration- measured in ticks, seegetDuration()amplifier- the amplifier, seegetAmplifier()ambient- the ambient status, seeisAmbient()particles- the particle status, seehasParticles()
-
PotionEffect
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient)Creates a potion effect. Assumes that particles are visible- Parameters:
type- effect typeduration- measured in ticks, seegetDuration()amplifier- the amplifier, seegetAmplifier()ambient- the ambient status, seeisAmbient()
-
PotionEffect
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier)Creates a potion effect. Assumes ambient is true.- Parameters:
type- Effect typeduration- measured in ticksamplifier- the amplifier for the effect- See Also:
PotionEffect(PotionEffectType, int, int, boolean)
-
-
Method Detail
-
serialize
@NotNull public @NotNull Map<String,Object> serialize()
Description copied from interface:ConfigurationSerializableCreates a Map representation of this class.This class must provide a method to restore this class, as defined in the
ConfigurationSerializableinterface javadocs.- Specified by:
serializein interfaceConfigurationSerializable- Returns:
- Map containing the current state of this class
-
apply
public boolean apply(@NotNull @NotNull LivingEntity entity)Attempts to add the effect represented by this object to the givenLivingEntity.- Parameters:
entity- The entity to add this effect to- Returns:
- Whether the effect could be added
- See Also:
LivingEntity.addPotionEffect(PotionEffect)
-
getAmplifier
public int getAmplifier()
Returns the amplifier of this effect. A higher amplifier means the potion effect happens more often over its duration and in some cases has more effect on its target.- Returns:
- The effect amplifier
-
getDuration
public int getDuration()
Returns the duration (in ticks) that this effect will run for when applied to aLivingEntity.- Returns:
- The duration of the effect
-
getType
@NotNull public @NotNull PotionEffectType getType()
Returns thePotionEffectTypeof this effect.- Returns:
- The potion type of this effect
-
isAmbient
public boolean isAmbient()
Makes potion effect produce more, translucent, particles.- Returns:
- if this effect is ambient
-
hasParticles
public boolean hasParticles()
- Returns:
- whether this effect has particles or not
-
getColor
@Deprecated @Nullable @Contract("-> null") public @Nullable Color getColor()
Deprecated.color is not part of potion effects- Returns:
- color of this potion's particles. May be null if the potion has no particles or defined color.
-
hasIcon
public boolean hasIcon()
- Returns:
- whether this effect has an icon or not
-
-