Class ConcealmentShieldSpell
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CAVE_INIMICUM,REPELLO_MUGGLETON
Concealment shield spells create protective barriers that:
- Hide players inside the area from those outside (via visibility toggle)
- Prevent certain entities from entering the protected area
- Block entities outside from targeting players inside
- Prevent chat from those outside reaching those inside
- Optionally trigger proximity alarms when hostile entities approach
Subclasses customize behavior through abstract methods: canEnter(LivingEntity),
canSee(LivingEntity), canHear(LivingEntity), canTarget(LivingEntity),
and checkAlarm(LivingEntity).
- Since:
- 2.21
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether this spell triggers proximity alarms when hostile entities approach.Messages displayed to players who attempt to enter but are denied access.protected final intThe fixed duration (in ticks) of the proximity alarm cooldown (1 minute).protected intCurrent cooldown counter for proximity alarms.protected intThe distance (in blocks) beyond the spell radius that triggers proximity alarms. -
Constructor Summary
ConstructorsConstructorDescriptionConcealmentShieldSpell(@NotNull Ollivanders2 plugin) Constructs a concealment spell from deserialized data at server start.ConcealmentShieldSpell(@NotNull Ollivanders2 plugin, @NotNull UUID pid, @NotNull org.bukkit.Location location, int radius, int duration) Constructs a new concealment shield spell cast by a player. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancanEnter(@NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity can enter the spell area.protected abstract booleancanHear(@NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity outside the spell area can hear sounds from inside.protected abstract booleancanSee(@NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity outside the spell area can see players inside.abstract booleancanTarget(@NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity outside the spell area can target players inside.protected abstract booleancheckAlarm(@NotNull org.bukkit.entity.LivingEntity entity) Checks if a non-player entity outside the spell area should trigger a proximity alarm.protected abstract booleancheckAlarm(@NotNull org.bukkit.entity.Player player) Checks if a player outside the spell area should trigger a proximity alarm.voiddeserializeSpellData(@NotNull Map<String, String> spellData) Deserializes concealment spell data from storage.booleanDoes this spell alarm on proximity?protected voiddoProximityCheck(@NotNull org.bukkit.entity.LivingEntity entity) Checks and triggers a proximity alarm if conditions are met.protected @Nullable StringGets a random entry denial message to display to players blocked from entering.Get the entry deny messages.intThe radius from the spell center for proximity checks for this spellprotected voidhandleEntityMove(@NotNull org.bukkit.entity.LivingEntity entity, @NotNull org.bukkit.Location toLocation, @NotNull org.bukkit.Location fromLocation) Handles visibility and proximity logic when an entity moves relative to the spell boundary.protected voidHides or shows players in the spell area based on visibility rules.booleanisInProximity(org.bukkit.Location alertLocation) Checks if a location is within the proximity alarm detection radius.protected abstract voidPerforms the proximity alarm action for this spell.Serializes concealment spell data for persistence.protected voidtoggleVisibility(@NotNull org.bukkit.entity.Player player) Toggles the visibility of a specific player based on concealment rules.protected voidunhidePlayer(@NotNull org.bukkit.entity.Player player) Shows a player to all online players (removes concealment).protected voidShows all players in the spell area to other online players.voidupkeep()Performs per-tick upkeep for this concealment spell.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
-
alarmOnProximity
protected boolean alarmOnProximityWhether this spell triggers proximity alarms when hostile entities approach. -
proximityRadiusModifier
protected int proximityRadiusModifierThe distance (in blocks) beyond the spell radius that triggers proximity alarms. Extends the effective alarm radius outward from the spell's boundary. -
proximityCooldownTimer
protected int proximityCooldownTimerCurrent cooldown counter for proximity alarms. Prevents the alarm from triggering repeatedly. Decremented each tick when active, prevents new alarms when greater than zero. -
proximityCooldownLimit
protected final int proximityCooldownLimitThe fixed duration (in ticks) of the proximity alarm cooldown (1 minute). Reset when a proximity alarm is triggered.- See Also:
-
entryDenyMessages
Messages displayed to players who attempt to enter but are denied access. One message is chosen randomly from this list each time entry is denied.
-
-
Constructor Details
-
ConcealmentShieldSpell
Constructs a concealment spell from deserialized data at server start.Used only for loading saved spells from disk. Subclasses should not call this for spell casting - use the full constructor instead.
- Parameters:
plugin- a callback to the MC plugin
-
ConcealmentShieldSpell
public ConcealmentShieldSpell(@NotNull @NotNull Ollivanders2 plugin, @NotNull @NotNull UUID pid, @NotNull @NotNull org.bukkit.Location location, int radius, int duration) Constructs a new concealment shield spell cast by a player.Initializes the spell with the specified properties and immediately hides all players currently in the spell area (based on the
canSee(LivingEntity)implementation).- Parameters:
plugin- a callback to the MC pluginpid- the UUID of the player who cast the spelllocation- the center location of the spellradius- the initial radius for this spellduration- the initial duration for this spell in ticks
-
-
Method Details
-
upkeep
public void upkeep()Performs per-tick upkeep for this concealment spell.Ages the spell by one tick, decrements the proximity alarm cooldown timer, and kills the spell when duration reaches zero.
- Specified by:
upkeepin classO2StationarySpell
-
getEntryDenyMessages
Get the entry deny messages.- Returns:
- the entry deny messages
-
hidePlayersInSpellArea
protected void hidePlayersInSpellArea()Hides or shows players in the spell area based on visibility rules.Iterates through all players in the spell radius and toggles their visibility according to the
toggleVisibility(Player)logic andcanSee(LivingEntity)implementation. -
toggleVisibility
protected void toggleVisibility(@NotNull @NotNull org.bukkit.entity.Player player) Toggles the visibility of a specific player based on concealment rules.For each online player (viewer), hides or shows the target player based on:
- Whether the target is inside the spell area
- Whether the viewer can see into the spell area (via
canSee(LivingEntity)) - Whether the target has other invisibility effects
Does not hide the target from themselves.
- Parameters:
player- the player whose visibility to toggle
-
unhidePlayersInSpellArea
protected void unhidePlayersInSpellArea()Shows all players in the spell area to other online players.Called when the spell ends to remove the concealment effect from all affected players.
-
unhidePlayer
protected void unhidePlayer(@NotNull @NotNull org.bukkit.entity.Player player) Shows a player to all online players (removes concealment).Called when a player leaves the spell area or when the spell ends. Does not unhide players who have other invisibility effects.
- Parameters:
player- the player to show
-
getAreaEntryDenialMessage
Gets a random entry denial message to display to players blocked from entering.Selects a random message from the configured
entryDenyMessageslist. Used when a player attempts to enter the spell area but fails thecanEnter(LivingEntity)check.- Returns:
- a random message from the configured list, or null if no messages are configured
-
doProximityCheck
protected void doProximityCheck(@NotNull @NotNull org.bukkit.entity.LivingEntity entity) Checks and triggers a proximity alarm if conditions are met.Tests whether the entity meets alarm conditions via
checkAlarm(LivingEntity)orcheckAlarm(Player)and triggersproximityAlarm()if conditions match. Does nothing if the proximity alarm cooldown is active.- Parameters:
entity- the living entity that may trigger the alarm
-
isInProximity
public boolean isInProximity(org.bukkit.Location alertLocation) Checks if a location is within the proximity alarm detection radius.The proximity radius extends
proximityRadiusModifierblocks beyond the spell's boundary.- Parameters:
alertLocation- the location to check- Returns:
- true if the location is within the proximity alarm radius, false otherwise
-
getProximityRadius
public int getProximityRadius()The radius from the spell center for proximity checks for this spell- Returns:
- the proximity radius
-
doesAlarmOnProximty
public boolean doesAlarmOnProximty()Does this spell alarm on proximity?- Returns:
- true if it alarms on proximity, false otherwise
-
handleEntityMove
protected void handleEntityMove(@NotNull @NotNull org.bukkit.entity.LivingEntity entity, @NotNull @NotNull org.bukkit.Location toLocation, @NotNull @NotNull org.bukkit.Location fromLocation) Handles visibility and proximity logic when an entity moves relative to the spell boundary.Called asynchronously after a player move event completes successfully. Handles three cases:
- Entity entering: Re-evaluates visibility for all players in the area if entry is allowed
- Entity leaving: Unhides the departing player to all viewers
- Proximity check: Triggers proximity alarm if entity moves near the boundary
Assumes the move event completed and entry restrictions have already been checked.
- Parameters:
entity- the living entity that movedtoLocation- the location the entity moved tofromLocation- the location the entity moved from
-
serializeSpellData
Serializes concealment spell data for persistence.This base implementation returns an empty map. Subclasses can override to save spell-specific configuration like proximity alarm settings or custom messages.
- Returns:
- a map of serialized spell-specific data
-
deserializeSpellData
Deserializes concealment spell data from storage.This base implementation does nothing. Subclasses can override to restore spell-specific configuration that was previously saved.
- Parameters:
spellData- the map of saved spell-specific data
-
canHear
protected abstract boolean canHear(@NotNull @NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity outside the spell area can hear sounds from inside.Used by
doOnAsyncPlayerChatEvent(AsyncPlayerChatEvent)to determine if chat from players inside should reach this entity.- Parameters:
entity- the entity outside the spell area to check (not null)- Returns:
- true if the entity can hear conversations inside the spell area, false if sounds are concealed
-
canSee
protected abstract boolean canSee(@NotNull @NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity outside the spell area can see players inside.Used by
toggleVisibility(Player)to determine whether to hide concealed players from this entity's view.- Parameters:
entity- the entity outside the spell area to check (not null)- Returns:
- true if the entity can see players inside the spell area, false if players are hidden
-
canTarget
public abstract boolean canTarget(@NotNull @NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity outside the spell area can target players inside.Used by
doOnEntityTargetEvent(EntityTargetEvent)to determine if targeting attempts from outside should succeed.- Parameters:
entity- the entity outside the spell area to check (not null)- Returns:
- true if the entity can target players inside the spell area, false if targeting is blocked
-
canEnter
public abstract boolean canEnter(@NotNull @NotNull org.bukkit.entity.LivingEntity entity) Determines if an entity can enter the spell area.Used by
doOnPlayerMoveEvent(PlayerMoveEvent)to determine if a player attempting to cross the spell boundary should be allowed entry.- Parameters:
entity- the entity attempting to enter the spell area (not null)- Returns:
- true if the entity can enter the spell area, false if entry is blocked
-
checkAlarm
protected abstract boolean checkAlarm(@NotNull @NotNull org.bukkit.entity.Player player) Checks if a player outside the spell area should trigger a proximity alarm.Called by
doProximityCheck(LivingEntity)when an entity moves within the proximity alarm radius. Allows subclasses to implement spell-specific alarm conditions.- Parameters:
player- the player outside the spell area at proximity distance (not null)- Returns:
- true if the alarm conditions are met, false otherwise
-
checkAlarm
protected abstract boolean checkAlarm(@NotNull @NotNull org.bukkit.entity.LivingEntity entity) Checks if a non-player entity outside the spell area should trigger a proximity alarm.Called by
doProximityCheck(LivingEntity)when an entity moves within the proximity alarm radius. Allows subclasses to implement spell-specific alarm conditions.- Parameters:
entity- the non-player entity outside the spell area at proximity distance (not null)- Returns:
- true if the alarm conditions are met, false otherwise
-
proximityAlarm
protected abstract void proximityAlarm()Performs the proximity alarm action for this spell.Called by
doProximityCheck(LivingEntity)when proximity alarm conditions are met. Typically, sends a message or triggers an effect to alert players inside the spell area.
-