java.lang.Object
net.pottercraft.ollivanders2.stationaryspell.O2StationarySpell
net.pottercraft.ollivanders2.stationaryspell.HORCRUX
All Implemented Interfaces:
Serializable

public class HORCRUX extends O2StationarySpell
A stationary spell that creates a horcrux - an anchor point for player resurrection with preserved power.

Horcrux creates a permanent magical anchor that allows the spell's caster to respawn at the horcrux location when killed, while retaining all spell levels and experience. The spell:

  • Creates an anchor point as a physical item in the world
  • Prevents the player from losing spell levels on death
  • Prevents the player from losing experience on death
  • Respawns the player at the horcrux location
  • Applies debilitative effects (blindness, wither) to players near the horcrux
  • Protects the horcrux item from being picked up or despawning
  • Can only be destroyed by fiendfyre

The spell is permanent and persists across server restarts.

Since:
2.21
See Also:
  • Field Details

    • deathMessage

      public static final String deathMessage
      The message players see on death
      See Also:
    • minRadiusConfig

      public static final int minRadiusConfig
      Minimum spell radius (3 blocks) - effect range for debilitation effects.
      See Also:
    • maxRadiusConfig

      public static final int maxRadiusConfig
      Maximum spell radius (3 blocks) - effect range for debilitation effects.
      See Also:
    • minDurationConfig

      public static final int minDurationConfig
      Minimum spell duration (1000 ticks) - not used, horcrux is permanent.
      See Also:
    • maxDurationConfig

      public static final int maxDurationConfig
      Maximum spell duration (1000 ticks) - not used, horcrux is permanent.
      See Also:
    • effectDuration

      public static final int effectDuration
      How long to affect someone who gets too close to the horcrux
      See Also:
  • Constructor Details

    • HORCRUX

      public HORCRUX(@NotNull @NotNull Ollivanders2 plugin)
      Simple constructor used for deserializing saved stationary spells at server start. Do not use to cast spell.
      Parameters:
      plugin - a callback to the MC plugin
    • HORCRUX

      public HORCRUX(@NotNull @NotNull Ollivanders2 plugin, @NotNull @NotNull UUID pid, @NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull org.bukkit.entity.Item item)
      Constructs a new HORCRUX spell cast by a player.

      Creates a permanent horcrux anchor at the specified location using the provided item. The player will respawn at this location when killed, retaining all spell levels and experience.

      Parameters:
      plugin - a callback to the MC plugin (not null)
      pid - the UUID of the player who cast the spell (not null)
      location - the center location of the horcrux anchor (not null)
      item - the item representing the horcrux in the world (not null)
  • Method Details

    • upkeep

      public void upkeep()
      Ages the spell and manages player debilitation effects.

      Decrements the duration timers for affected players, removing them from the affected list when their duration expires.

      Specified by:
      upkeep in class O2StationarySpell
    • serializeSpellData

      @NotNull public @NotNull Map<String,String> serializeSpellData()
      Serializes the horcrux's persistent data for server restart recovery.

      Saves the material type and world name so the horcrux item can be properly respawned when the server restarts. This ensures the horcrux persists across server restarts.

      Returns:
      a map containing the horcrux material type and world name
    • deserializeSpellData

      public void deserializeSpellData(@NotNull @NotNull Map<String,String> spellData)
      Deserializes the horcrux's persistent data when loading from server restart.

      Restores the material type and world name that were saved. If the material type is no longer valid (removed in a Minecraft update) or if required data is missing, the spell is destroyed.

      Parameters:
      spellData - a map containing the saved horcrux material and world name
    • checkSpellDeserialization

      public boolean checkSpellDeserialization()
      Validates that the spell was properly deserialized with all required data.

      Checks that the following essential data was restored from the saved state:

      • Player UUID (caster identification)
      • Location (horcrux position)
      • Horcrux material (item type)

      If any required data is missing, the spell is invalid and should be destroyed.

      Overrides:
      checkSpellDeserialization in class O2StationarySpell
      Returns:
      true if all required data is present, false otherwise
    • isAffected

      public boolean isAffected(org.bukkit.entity.Player player)
      Is this player currently affected by the horcrux?
      Parameters:
      player - the player to check
      Returns:
      true if they are affected, false otherwise