Class PotionEffectSuper
- Direct Known Subclasses:
BLINDNESS,CONFUSION,FIRE_RESISTANCE,HARM,HEAL,HEALTH_BOOST,HUNGER,LUCK,NIGHT_VISION,POISON,REGENERATION,SATIATION,SLOWNESS,SPEED,SPEED_SPEEDIER,SPEED_SPEEDIEST,STRENGTH,UNLUCK,WATER_BREATHING,WEAKNESS
PotionEffectSuper provides a potion effect application mechanism that applies effects immediately and then expires. Potion effects are applied in checkEffect() and the effect kills itself in the same tick.
Duration Mechanism:
Potion effects are applied with a duration clamped to a valid range:- Minimum duration: 2400 ticks (2 minutes)
- Maximum duration: 6000 ticks (5 minutes)
- The duration specified in the constructor is clamped to this range
Effect Configuration: Subclasses set potionEffectType to specify which Minecraft potion effect (POISON, WEAKNESS, etc.) to apply, and strength to set the amplifier level of the effect (1 is normal strength).
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionPotionEffectSuper(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating a potion effect. -
Method Summary
Modifier and TypeMethodDescriptionvoidApply the potion effect immediately and expire.org.bukkit.potion.PotionEffectTypeGet the PotionEffectType this PotionEffect effect addsintGet the strength for this potion effectvoidsetPermanent(boolean perm) Potion effects cannot ever be permanentvoidsetStrength(int s) Set the amplifier strength of this potion effect.Methods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, doRemove, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, kill
-
Constructor Details
-
PotionEffectSuper
public PotionEffectSuper(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid) Constructor for creating a potion effect.Creates an effect that will apply a Minecraft potion effect immediately and expire in a single game tick. Subclasses should initialize potionEffectType and strength fields before the effect is added to a player's effect list.
- Parameters:
plugin- a reference to the pluginduration- the duration in ticks, snapped to min of 2 minutes, max of 5 minutesisPermanent- ignored - potion effects cannot be permanentpid- the unique ID of the target player
-
-
Method Details
-
checkEffect
public void checkEffect()Apply the potion effect immediately and expire.This method executes in a single game tick and performs the following:
- Creates a new potion effect with the specified type, duration, and strength (amplifier)
- Applies the potion effect to the target player (initialized in O2Effect constructor)
- Kills the effect so it doesn't persist beyond the single tick
Example: A POISON effect with strength 2 will create a poison effect with amplifier 2 and the duration specified when the effect was created (clamped to 2400-6000 ticks).
- Specified by:
checkEffectin classO2Effect
-
setStrength
public void setStrength(int s) Set the amplifier strength of this potion effect.Sets the strength (amplifier level) of the potion effect that will be applied to the player. A value of 1 represents normal strength. Higher values increase the effect's potency.
- Parameters:
s- a positive integer representing the amplifier level (1 = normal, 2 = enhanced, etc.)
-
getStrength
public int getStrength()Get the strength for this potion effect- Returns:
- the potion strength
-
getPotionEffectType
public org.bukkit.potion.PotionEffectType getPotionEffectType()Get the PotionEffectType this PotionEffect effect adds- Returns:
- the PotionEffectType
-
setPermanent
public void setPermanent(boolean perm) Potion effects cannot ever be permanent- Overrides:
setPermanentin classO2Effect- Parameters:
perm- ignored - potion effects are always temporary
-