Class ShapeShiftSuper

java.lang.Object
net.pottercraft.ollivanders2.effect.O2Effect
net.pottercraft.ollivanders2.effect.ShapeShiftSuper
Direct Known Subclasses:
ANIMAGUS_EFFECT, LYCANTHROPY

public abstract class ShapeShiftSuper extends O2Effect
Parent class for effects that transform a player into another entity form.

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:

  1. A subclass creates an instance and sets the target form (entity type)
  2. checkEffect() calls transform() to apply the disguise using libDisguises
  3. transform() creates a MobDisguise, customizes the watcher (appearance), and disguises the player
  4. checkEffect() calls upkeep() each tick to maintain the transformation (subclasses can override)
  5. 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.

  • 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 plugin
      duration - the duration of the effect in game ticks
      isPermanent - 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:

      1. Verifies that LibDisguises is still enabled; kills the effect if disabled
      2. Ages the effect by 1 tick (for non-permanent effects)
      3. Calls upkeep() to allow subclasses to maintain or modify the transformation
      Specified by:
      checkEffect in class O2Effect
    • 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.

      Overrides:
      kill in class O2Effect
    • 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