Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.potion.PotionEffect Class Reference
Inheritance diagram for org.bukkit.potion.PotionEffect:
org.bukkit.configuration.serialization.ConfigurationSerializable

Public Member Functions

 PotionEffect (PotionEffectType type, int duration, int amplifier, boolean ambient)
 
 PotionEffect (PotionEffectType type, int duration, int amplifier)
 
 PotionEffect (Map< String, Object > map)
 
Map< String, Object > serialize ()
 
boolean apply (LivingEntity entity)
 
boolean equals (Object obj)
 
int getAmplifier ()
 
int getDuration ()
 
PotionEffectType getType ()
 
boolean isAmbient ()
 
int hashCode ()
 
String toString ()
 

Detailed Description

Represents a potion effect, that can be added to a LivingEntity. A potion effect has a duration that it will last for, an amplifier that will enhance its effects, and a PotionEffectType, that represents its effect on an entity.

Definition at line 20 of file PotionEffect.java.

Constructor & Destructor Documentation

org.bukkit.potion.PotionEffect.PotionEffect ( PotionEffectType  type,
int  duration,
int  amplifier,
boolean  ambient 
)

Creates a potion effect.

Parameters
typeeffect type
durationmeasured in ticks, see PotionEffect#getDuration()
amplifierthe amplifier, see PotionEffect#getAmplifier()
ambientthe ambient status, see PotionEffect#isAmbient()

Definition at line 39 of file PotionEffect.java.

39  {
40  Validate.notNull(type, "effect type cannot be null");
41  this.type = type;
42  this.duration = duration;
43  this.amplifier = amplifier;
44  this.ambient = ambient;
45  }
org.bukkit.potion.PotionEffect.PotionEffect ( PotionEffectType  type,
int  duration,
int  amplifier 
)

Creates a potion effect. Assumes ambient is true.

Parameters
typeEffect type
durationmeasured in ticks
amplifierthe amplifier for the effect
See also
PotionEffect::PotionEffect(PotionEffectType, int, int, boolean)

Definition at line 55 of file PotionEffect.java.

55  {
56  this(type, duration, amplifier, true);
57  }
org.bukkit.potion.PotionEffect.PotionEffect ( Map< String, Object >  map)

Constructor for deserialization.

Parameters
mapthe map to deserialize from

Definition at line 64 of file PotionEffect.java.

64  {
65  this(getEffectType(map), getInt(map, DURATION), getInt(map, AMPLIFIER), getBool(map, AMBIENT));
66  }

Member Function Documentation

boolean org.bukkit.potion.PotionEffect.apply ( LivingEntity  entity)

Attempts to add the effect represented by this object to the given LivingEntity.

See also
LivingEntity::addPotionEffect(PotionEffect)
Parameters
entityThe entity to add this effect to
Returns
Whether the effect could be added

Definition at line 110 of file PotionEffect.java.

References org.bukkit.entity.LivingEntity.addPotionEffect().

110  {
111  return entity.addPotionEffect(this);
112  }
int org.bukkit.potion.PotionEffect.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

Definition at line 133 of file PotionEffect.java.

133  {
134  return amplifier;
135  }
int org.bukkit.potion.PotionEffect.getDuration ( )

Returns the duration (in ticks) that this effect will run for when applied to a LivingEntity.

Returns
The duration of the effect

Definition at line 143 of file PotionEffect.java.

143  {
144  return duration;
145  }
PotionEffectType org.bukkit.potion.PotionEffect.getType ( )

Returns the PotionEffectType of this effect.

Returns
The potion type of this effect

Definition at line 152 of file PotionEffect.java.

152  {
153  return type;
154  }
boolean org.bukkit.potion.PotionEffect.isAmbient ( )

Makes potion effect produce more, translucent, particles.

Returns
if this effect is ambient

Definition at line 161 of file PotionEffect.java.

161  {
162  return ambient;
163  }
Map<String, Object> org.bukkit.potion.PotionEffect.serialize ( )

Creates a Map representation of this class.

This class must provide a method to restore this class, as defined in the ConfigurationSerializable interface javadocs.

Returns
Map containing the current state of this class

Implements org.bukkit.configuration.serialization.ConfigurationSerializable.

Definition at line 93 of file PotionEffect.java.

93  {
94  return ImmutableMap.<String, Object>of(
95  TYPE, type.getId(),
96  DURATION, duration,
97  AMPLIFIER, amplifier,
98  AMBIENT, ambient
99  );
100  }

The documentation for this class was generated from the following file: