Class PROTEGO_TOTALUM
- All Implemented Interfaces:
Serializable
Protego Totalum creates an area where:
- Players cannot move into the protected area from outside
- Hostile mobs that enter have their AI disabled so they cannot move or attack
- Creatures cannot spawn inside the protected area
- Entities already inside the area can move freely, including leaving
Note: There is no EntityMoveEvent in Spigot, so hostile mobs are handled by disabling their AI rather than blocking their movement directly.
- Since:
- 2.21
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum spell duration (30 minutes).static final intMaximum spell radius (40 blocks).static final intMinimum spell duration (5 minutes).static final intMinimum spell radius (5 blocks). -
Constructor Summary
ConstructorsConstructorDescriptionPROTEGO_TOTALUM(@NotNull Ollivanders2 plugin) Simple constructor used for deserializing saved stationary spells at server start.PROTEGO_TOTALUM(@NotNull Ollivanders2 plugin, @NotNull UUID pid, @NotNull org.bukkit.Location location, int radius, int duration) Constructs a new PROTEGO_TOTALUM spell cast by a player. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserializeSpellData(@NotNull Map<String, String> spellData) Deserializes protego totalum spell data from saved state.List<org.bukkit.entity.Entity> Gets the entities currently affected by this spell (AI disabled).Serializes the protego totalum spell data for persistence.voidupkeep()Ages the spell and manages hostile mobs inside the protected area.Methods inherited from class net.pottercraft.ollivanders2.stationaryspell.O2StationarySpell
age, age, ageByPercent, checkSpellDeserialization, decreaseRadius, flair, getBlock, getCasterID, getDuration, getLivingEntitiesInsideSpellRadius, getLocation, getMaxDuration, getMaxRadius, getMinDuration, getMinRadius, getPlayersInsideSpellRadius, getRadius, getSpellType, increaseDuration, increaseRadius, isActive, isKilled, isLocationInside, isPermanent, kill, setActive
-
Field Details
-
minRadiusConfig
public static final int minRadiusConfigMinimum spell radius (5 blocks).- See Also:
-
maxRadiusConfig
public static final int maxRadiusConfigMaximum spell radius (40 blocks).- See Also:
-
minDurationConfig
public static final int minDurationConfigMinimum spell duration (5 minutes).- See Also:
-
maxDurationConfig
public static final int maxDurationConfigMaximum spell duration (30 minutes).- See Also:
-
-
Constructor Details
-
PROTEGO_TOTALUM
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
-
PROTEGO_TOTALUM
public PROTEGO_TOTALUM(@NotNull @NotNull Ollivanders2 plugin, @NotNull @NotNull UUID pid, @NotNull @NotNull org.bukkit.Location location, int radius, int duration) Constructs a new PROTEGO_TOTALUM spell cast by a player.Creates a protective barrier at the specified location with the given radius and duration. The barrier will block players from entering, disable AI on hostile mobs, and prevent creature spawns inside the protected area.
- 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 spell (not null)radius- the radius for this spell (will be clamped to min/max values)duration- the duration of the spell in ticks (will be clamped to min/max values)
-
-
Method Details
-
getTrackedAffectedEntities
Gets the entities currently affected by this spell (AI disabled).Returns a copy of the affected entities list to prevent external modifications.
- Returns:
- a list of entities with disabled AI (not null, may be empty)
-
upkeep
public void upkeep()Ages the spell and manages hostile mobs inside the protected area.Checks for hostile entities inside the spell area and disables their AI so they cannot move or attack. Affected entities are tracked so their AI can be restored when the spell ends.
- Specified by:
upkeepin classO2StationarySpell
-
serializeSpellData
Serializes the protego totalum spell data for persistence.The spell has no extra data to serialize beyond the base spell properties. Affected entities are not saved because they will be re-detected and re-affected when the server restarts and the spell resumes.
- Returns:
- an empty map (the spell has no custom data to serialize)
-
deserializeSpellData
Deserializes protego totalum spell data from saved state.The spell has no extra data to deserialize, so this method does nothing.
- Parameters:
spellData- the serialized spell data map (not used)
-