Class O2StationarySpell
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ALIQUAM_FLOO,COLLOPORTUS,HARMONIA_NECTERE_PASSUS,HORCRUX,LUMOS_FERVENS,MOLLIARE,NULLUM_APPAREBIT,NULLUM_EVANESCUNT,ShieldSpell,ThrownPotionStationarySpell
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
ConstructorsConstructorDescriptionO2StationarySpell(@NotNull Ollivanders2 plugin) 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 TypeMethodDescriptionvoidage()Ages the StationarySpellObjvoidage(int i) Ages the StationarySpellObjvoidageByPercent(double percent) Ages the stationary spell by the specified percent.booleanChecks if this spell has been properly deserialized with required data.voiddecreaseRadius(int decrease) Decrease the radius of this stationary spell.voidflair(int intensity) Makes a particle effect at all points along the radius of spell and at spell loc@NotNull org.bukkit.block.BlockgetBlock()Gets the block at the center of this spell radius@NotNull UUIDGet the ID of the player that cast the spellintGet 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.LocationGet a copy of the location for this stationary spell.intGet the max duration for this spellintGet the max radius for this spellintGet the min duration for this spellintGet the min radius for this spellList<org.bukkit.entity.Player> Get the players inside this spell radius.intGet the spell's current radius@NotNull O2StationarySpellTypeGet the type of this stationary spellvoidincreaseDuration(int increase) Increase the duration of this stationary spell.voidincreaseRadius(int increase) Increase the radius of this stationary spell.booleanisActive()Is this stationary spell currently active?booleanisKilled()Is this spell killed (marked for removal)?booleanisLocationInside(@NotNull org.bukkit.Location loc) Is the location specified inside the stationary spell's radius?booleanChecks if this spell is permanent (never ages or expires).voidkill()This kills the spellvoidsetActive(boolean active) Set whether this spell should be active or not.abstract voidupkeep()Performs per-tick upkeep for this spell.
-
Constructor Details
-
O2StationarySpell
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 pluginpid- the UUID of the player who cast the spelllocation- 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
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
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
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- Parameters:
intensity- intensity of the flair
-
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
-