Class FLYING
- Direct Known Subclasses:
BROOM_FLYING
The FLYING effect enables the target player to fly for the specified duration. Each game tick, the effect checks the remaining duration and maintains flight state: while duration > 1 tick remains, the player can fly; on the final tick (duration ≤ 1), flight is disabled. Optional smoke particle effects can be displayed during flight by setting doSmokeEffect to true (default is false).
Mechanism:
- Flight enabled each tick while duration > 1
- Flight disabled on final tick (duration ≤ 1) before effect expires
- Optional smoke particle effects each tick (disabled by default)
- On removal: flight revoked unless player has Ollivanders2.admin permission
- Admin players retain flight ability through spell/effect removal
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionFLYING(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating a flight effect. -
Method Summary
Modifier and TypeMethodDescriptionvoidEnable flight while the effect is active and disable on final tick.voiddoRemove()Revoke flight ability when the effect is removed (unless player is an admin).Methods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, kill, setPermanent
-
Constructor Details
-
FLYING
public FLYING(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid) Constructor for creating a flight effect.Creates an effect that grants temporary flight ability to the target player. The effect will enable flight each tick while the duration remains above 1 tick, then disable flight on the final tick before expiring. Smoke effects are disabled by default (doSmokeEffect = false) but can be enabled by subclasses for visually distinctive flight mechanics.
- Parameters:
plugin- a callback to the MC pluginduration- the duration of the effect in game ticksisPermanent- is this effect permanent (does not age)pid- the unique ID of the player to grant flight
-
-
Method Details
-
checkEffect
public void checkEffect()Enable flight while the effect is active and disable on final tick.Called each game tick. This method:
- Ages the effect (decrements duration)
- If target player not found: kills the effect
- If duration > 1 (effect still active):
- Enables flight (setAllowFlight(true))
- Plays smoke effect each tick if doSmokeEffect is true
- If duration ≤ 1 (final tick):
- Disables flight (setAllowFlight(false))
- Effect expires naturally on next tick
- Specified by:
checkEffectin classO2Effect
-
doRemove
public void doRemove()Revoke flight ability when the effect is removed (unless player is an admin).Called when the flight effect expires or is manually killed. This method checks if the player has the "Ollivanders2.admin" permission:
- Non-admin players: flight ability is revoked (setAllowFlight(false) and setFlying(false))
- Admin players: flight ability is preserved - admins can retain flight through spell/effect removal
This allows server admins to maintain flight privileges when flight-granting spells expire.
-