Class ShapeShiftSuper
- Direct Known Subclasses:
ANIMAGUS_EFFECT,LYCANTHROPY
ShapeShiftSuper provides a transformation mechanism using the libDisguises plugin to disguise players as various Minecraft entities (animals, monsters, etc.). Transformations are visual-only and do not change the player's actual capabilities (they still fly, use commands, etc.).
Transformation Lifecycle:
- A subclass creates an instance and sets the target form (entity type)
- checkEffect() calls transform() to apply the disguise using libDisguises
- transform() creates a MobDisguise, customizes the watcher (appearance), and disguises the player
- checkEffect() calls upkeep() each tick to maintain the transformation (subclasses can override)
- When the effect expires or is killed, restore() undisguises the player back to human form
Mutual Exclusion: Only one shape-shift effect can be active on a player at a time. When a new transformation is applied, any existing shape-shift effect is removed by the effects system.
Dependencies: This effect requires the LibDisguises plugin to be enabled on the server. If LibDisguises is disabled, the effect is automatically killed with no transformation applied.
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionShapeShiftSuper(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating a shape shift effect. -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck the effect each game tick and perform transformations.protected abstract voidPerform specific checkEffect actions on the active transformation each game tick.booleanCheck if the player is currently transformed into another entity form.voidkill()Kill this effect and restore the player to human form.voidrestore()Restore the player to their original human form.Methods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, doRemove, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, setPermanent
-
Constructor Details
-
ShapeShiftSuper
public ShapeShiftSuper(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid) Constructor for creating a shape shift effect.Creates an effect that will transform the player into another entity form using the LibDisguises plugin. Requires LibDisguises to be enabled on the server. Subclasses must set the form field to specify the target entity type before this effect is added to the player's effect list.
- 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 transform
-
-
Method Details
-
checkEffect
public void checkEffect()Check the effect each game tick and perform transformations.This method executes once per tick and performs the following:
- Verifies that LibDisguises is still enabled; kills the effect if disabled
- Ages the effect by 1 tick (for non-permanent effects)
- Calls upkeep() to allow subclasses to maintain or modify the transformation
- Specified by:
checkEffectin classO2Effect
-
doCheckEffect
protected abstract void doCheckEffect()Perform specific checkEffect actions on the active transformation each game tick.This is a template method that subclasses can override to maintain or modify the transformation on each tick. Subclasses can override to refresh the disguise, apply potion effects, play animations, or other tick-based behavior.
-
kill
public void kill()Kill this effect and restore the player to human form.Called when the effect expires or is being removed. This method calls restore() to undisguise the player, then marks the effect as killed to prevent further processing.
-
restore
public void restore()Restore the player to their original human form.Undisguises the player using LibDisguises, removing the transformation. Only performs undisguise if the player is currently transformed. Safely handles cases where the disguised entity no longer exists by catching exceptions.
-
isTransformed
public boolean isTransformed()Check if the player is currently transformed into another entity form.Returns whether the player is actively disguised as another entity. This is useful for subclasses to determine if the transformation is currently active (e.g., to prevent applying additional effects during transformation or to perform tick-based behavior only while transformed).
- Returns:
- true if the player is currently transformed, false if in human form
-