Class SUSPENSION
SUSPENSION is a debilitating effect that suspends the target player at eye level by teleporting them to a suspended location. The effect applies two additional permanent effects to maintain the suspension state: FLYING (to prevent falling due to gravity) and IMMOBILIZE (to prevent any movement that could break the suspension). The player's original location is recorded and restored when the effect is removed. This effect replaced the original LEVICORPUS implementation.
Suspension Configuration:
- Suspension height: at player eye level
- Head pitch: 45 degrees (downward tilt)
- Secondary effects: FLYING (permanent, prevents falling) and IMMOBILIZE (permanent, prevents movement)
- Suspension initialization: delayed 5 ticks after effect activation to allow secondary effects to activate
- Suspension state: tracked via boolean flag
- Velocity events: cancelled to maintain suspension stability
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionSUSPENSION(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating a suspension effect. -
Method Summary
Modifier and TypeMethodDescriptionvoidAge the suspension effect and initialize suspension on first tick.voiddoRemove()Clean up the suspension effect and restore the player to normal state.booleanCheck if the player is currently suspended in the air.Methods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, kill, setPermanent
-
Constructor Details
-
SUSPENSION
public SUSPENSION(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid) Constructor for creating a suspension effect.Creates a suspension effect that will hoist the target player into the air on the first checkEffect() call. The player will be teleported to a suspended location and secondary effects (FLYING and IMMOBILIZE) will be applied to maintain the suspension state. The original location is recorded for restoration when the effect is removed.
- Parameters:
plugin- a callback to the MC pluginduration- the duration of the suspension effect in game ticksisPermanent- is this effect permanent (does not age)pid- the unique ID of the player to suspend
-
-
Method Details
-
checkEffect
public void checkEffect()Age the suspension effect and initialize suspension on first tick.Called each game tick. This method ages the effect counter and checks if the player has been suspended yet via the suspended flag. If not, it performs the suspension initialization in two steps:
- Immediately adds the secondary effects (FLYING and IMMOBILIZE) to allow them to activate
- Delays the actual suspension (teleport and setFlying) by 5 ticks to ensure the secondary effects have time to start working before the player is moved
This delay is necessary because the FLYING effect must be initialized before calling setFlying(true), otherwise the player could briefly fall before the effect prevents gravity.
- Specified by:
checkEffectin classO2Effect
-
doRemove
public void doRemove()Clean up the suspension effect and restore the player to normal state.When the suspension effect is removed, this method teleports the player back to their original location and removes the secondary effects (FLYING and IMMOBILIZE) that were applied to maintain suspension. If the player is offline, cleanup is gracefully skipped.
-
isSuspended
public boolean isSuspended()Check if the player is currently suspended in the air.Returns true after the player has been hoisted into the air via the suspend() method. This flag is used to ensure the suspension mechanism runs exactly once per effect.
- Returns:
- true if the player has been suspended, false if the suspension is still pending
-