Class HORCRUX
- All Implemented Interfaces:
Serializable
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe message players see on deathstatic final intHow long to affect someone who gets too close to the horcruxstatic final intMaximum spell duration (1000 ticks) - not used, horcrux is permanent.static final intMaximum spell radius (3 blocks) - effect range for debilitation effects.static final intMinimum spell duration (1000 ticks) - not used, horcrux is permanent.static final intMinimum spell radius (3 blocks) - effect range for debilitation effects. -
Constructor Summary
ConstructorsConstructorDescriptionHORCRUX(@NotNull Ollivanders2 plugin) Simple constructor used for deserializing saved stationary spells at server start.HORCRUX(@NotNull Ollivanders2 plugin, @NotNull UUID pid, @NotNull org.bukkit.Location location, @NotNull org.bukkit.entity.Item item) Constructs a new HORCRUX spell cast by a player. -
Method Summary
Modifier and TypeMethodDescriptionbooleanValidates that the spell was properly deserialized with all required data.voiddeserializeSpellData(@NotNull Map<String, String> spellData) Deserializes the horcrux's persistent data when loading from server restart.booleanisAffected(org.bukkit.entity.Player player) Is this player currently affected by the horcrux?Serializes the horcrux's persistent data for server restart recovery.voidupkeep()Ages the spell and manages player debilitation effects.Methods inherited from class net.pottercraft.ollivanders2.stationaryspell.O2StationarySpell
age, age, ageByPercent, decreaseRadius, flair, getBlock, getCasterID, getDuration, getLivingEntitiesInsideSpellRadius, getLocation, getMaxDuration, getMaxRadius, getMinDuration, getMinRadius, getPlayersInsideSpellRadius, getRadius, getSpellType, increaseDuration, increaseRadius, isActive, isKilled, isLocationInside, isPermanent, kill, setActive
-
Field Details
-
deathMessage
The message players see on death- See Also:
-
minRadiusConfig
public static final int minRadiusConfigMinimum spell radius (3 blocks) - effect range for debilitation effects.- See Also:
-
maxRadiusConfig
public static final int maxRadiusConfigMaximum spell radius (3 blocks) - effect range for debilitation effects.- See Also:
-
minDurationConfig
public static final int minDurationConfigMinimum spell duration (1000 ticks) - not used, horcrux is permanent.- See Also:
-
maxDurationConfig
public static final int maxDurationConfigMaximum spell duration (1000 ticks) - not used, horcrux is permanent.- See Also:
-
effectDuration
public static final int effectDurationHow long to affect someone who gets too close to the horcrux- See Also:
-
-
Constructor Details
-
HORCRUX
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:
upkeepin classO2StationarySpell
-
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
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:
checkSpellDeserializationin classO2StationarySpell- 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
-