Class O2StationarySpell

java.lang.Object
net.pottercraft.ollivanders2.stationaryspell.O2StationarySpell
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ALIQUAM_FLOO, COLLOPORTUS, HARMONIA_NECTERE_PASSUS, HORCRUX, LUMOS_FERVENS, MOLLIARE, NULLUM_APPAREBIT, NULLUM_EVANESCUNT, ShieldSpell, ThrownPotionStationarySpell

public abstract class O2StationarySpell extends Object implements Serializable
Abstract base class for stationary spells (area-of-effect persistent spells).

Stationary spells create protective barriers or effects that persist at a fixed location and affect all players and entities within their radius. They age over time (unless permanent), emit visual effects (flair), and provide a hook system for handling game events. Each spell has configurable minimum and maximum radius and duration constraints that subclasses must define.

Key features:

  • Fixed location with configurable radius
  • Time-based duration (ages each tick unless permanent)
  • Active/inactive state (duration continues to age when inactive)
  • Event handler overrides for spell-specific behavior
  • Serialization/deserialization for persistence across server restarts
  • Visual effects (flair) at spell location
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a stationary spell from deserialized data at server startup.
    O2StationarySpell(@NotNull Ollivanders2 plugin, @NotNull UUID pid, @NotNull org.bukkit.Location location)
    Constructs a new stationary spell cast by a player.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    age()
    Ages the StationarySpellObj
    void
    age(int i)
    Ages the StationarySpellObj
    void
    ageByPercent(double percent)
    Ages the stationary spell by the specified percent.
    boolean
    Checks if this spell has been properly deserialized with required data.
    void
    decreaseRadius(int decrease)
    Decrease the radius of this stationary spell.
    void
    flair(int intensity)
    Makes a particle effect at all points along the radius of spell and at spell loc
    @NotNull org.bukkit.block.Block
    Gets the block at the center of this spell radius
    @NotNull UUID
    Get the ID of the player that cast the spell
    int
    Get the duration remaining for this spell
    @NotNull List<org.bukkit.entity.LivingEntity>
    Get living entities whose eye location is within the radius.
    @NotNull org.bukkit.Location
    Get a copy of the location for this stationary spell.
    int
    Get the max duration for this spell
    int
    Get the max radius for this spell
    int
    Get the min duration for this spell
    int
    Get the min radius for this spell
    List<org.bukkit.entity.Player>
    Get the players inside this spell radius.
    int
    Get the spell's current radius
    Get the type of this stationary spell
    void
    increaseDuration(int increase)
    Increase the duration of this stationary spell.
    void
    increaseRadius(int increase)
    Increase the radius of this stationary spell.
    boolean
    Is this stationary spell currently active?
    boolean
    Is this spell killed (marked for removal)?
    boolean
    isLocationInside(@NotNull org.bukkit.Location loc)
    Is the location specified inside the stationary spell's radius?
    boolean
    Checks if this spell is permanent (never ages or expires).
    void
    This kills the spell
    void
    setActive(boolean active)
    Set whether this spell should be active or not.
    abstract void
    Performs per-tick upkeep for this spell.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • O2StationarySpell

      public O2StationarySpell(@NotNull @NotNull Ollivanders2 plugin)
      Constructs a stationary spell from deserialized data at server startup.

      Used only for loading saved spells from disk. Subclasses should not call this directly when casting a new spell - use the full constructor instead. Calls initRadiusAndDurationMinMax() to set spell-specific radius and duration constraints.

      Parameters:
      plugin - a callback to the MC plugin
    • O2StationarySpell

      public O2StationarySpell(@NotNull @NotNull Ollivanders2 plugin, @NotNull @NotNull UUID pid, @NotNull @NotNull org.bukkit.Location location)
      Constructs a new stationary spell cast by a player.

      Creates a new spell at the specified location with the given caster. Initializes spell-specific constraints via initRadiusAndDurationMinMax(). This constructor should be used when casting a new spell.

      Parameters:
      plugin - a callback to the MC plugin
      pid - the UUID of the player who cast the spell
      location - the center location of the spell
  • Method Details

    • getDuration

      public int getDuration()
      Get the duration remaining for this spell
      Returns:
      the duration remaining
    • getRadius

      public int getRadius()
      Get the spell's current radius
      Returns:
      the radius of this spell
    • increaseRadius

      public void increaseRadius(int increase)
      Increase the radius of this stationary spell.
      Parameters:
      increase - the amount to increase the radius by
    • decreaseRadius

      public void decreaseRadius(int decrease)
      Decrease the radius of this stationary spell.
      Parameters:
      decrease - the amount to decrease the radius
    • increaseDuration

      public void increaseDuration(int increase)
      Increase the duration of this stationary spell.
      Parameters:
      increase - the amount to increase the duration by
    • getSpellType

      @NotNull public @NotNull O2StationarySpellType getSpellType()
      Get the type of this stationary spell
      Returns:
      the spell type
    • setActive

      public void setActive(boolean active)
      Set whether this spell should be active or not. Duration counts down regardless of this state.
      Parameters:
      active - true if active, false is not active
    • isPermanent

      public boolean isPermanent()
      Checks if this spell is permanent (never ages or expires).
      Returns:
      true if the spell is permanent, false if it ages over time
    • age

      public void age()
      Ages the StationarySpellObj
    • age

      public void age(int i)
      Ages the StationarySpellObj
      Parameters:
      i - number of ticks to age the spell by
    • ageByPercent

      public void ageByPercent(double percent)
      Ages the stationary spell by the specified percent.
      Parameters:
      percent - the percent (as a decimal) to age the spell by, 0.1-1 where 0.1 = 10%
    • kill

      public void kill()
      This kills the spell
    • isLocationInside

      public boolean isLocationInside(@NotNull @NotNull org.bukkit.Location loc)
      Is the location specified inside the stationary spell's radius?
      Parameters:
      loc - the location specified.
      Returns:
      true if the location is inside of this spell radius, false otherwise
    • getBlock

      @NotNull public @NotNull org.bukkit.block.Block getBlock()
      Gets the block at the center of this spell radius
      Returns:
      the center block for this spell
    • getLivingEntitiesInsideSpellRadius

      @NotNull public @NotNull List<org.bukkit.entity.LivingEntity> getLivingEntitiesInsideSpellRadius()
      Get living entities whose eye location is within the radius. We use eye radius to handle entities bigger than 1 block.
      Returns:
      a list of living entities with an eye location within radius
    • getPlayersInsideSpellRadius

      public List<org.bukkit.entity.Player> getPlayersInsideSpellRadius()
      Get the players inside this spell radius. We use eye radius to handle entities bigger than 1 block.
      Returns:
      a list of the players with an eye location within the radius
    • flair

      public void flair(int intensity)
      Makes a particle effect at all points along the radius of spell and at spell loc

      Ollivanders2Common

      Parameters:
      intensity - intensity of the flair
    • getCasterID

      @NotNull public @NotNull UUID getCasterID()
      Get the ID of the player that cast the spell
      Returns:
      the MC UUID of the player that cast the spell
    • getMaxRadius

      public int getMaxRadius()
      Get the max radius for this spell
      Returns:
      the max radius possible for this spell
    • getMinRadius

      public int getMinRadius()
      Get the min radius for this spell
      Returns:
      the min default radius for this spell
    • getMaxDuration

      public int getMaxDuration()
      Get the max duration for this spell
      Returns:
      the max duration possible for this spell
    • getMinDuration

      public int getMinDuration()
      Get the min duration for this spell
      Returns:
      the min default duration for this spell
    • isActive

      public boolean isActive()
      Is this stationary spell currently active?
      Returns:
      true if active, false if not active
    • isKilled

      public boolean isKilled()
      Is this spell killed (marked for removal)?
      Returns:
      true if killed, false otherwise
    • getLocation

      @NotNull public @NotNull org.bukkit.Location getLocation()
      Get a copy of the location for this stationary spell. A copy is returned because a stationary spell location cannot be changed.
      Returns:
      a clone of the spell location
    • upkeep

      public abstract void upkeep()
      Performs per-tick upkeep for this spell.

      Subclasses must implement to handle spell lifecycle management. Should call age() or age(int) to decrement the spell duration each tick, which will automatically kill the spell when duration reaches zero. Permanent spells will never age.

    • checkSpellDeserialization

      public boolean checkSpellDeserialization()
      Checks if this spell has been properly deserialized with required data.

      Verifies that the spell has both a caster UUID and a location set, which are required for a spell to function correctly.

      Returns:
      true if both playerUUID and location are set, false otherwise