Class PROTEGO
PROTEGO is an active spell shield charm that protects the affected player from projectile attacks by actively tracking incoming projectiles and removing them when they cross the shield boundary. Unlike passive shields, PROTEGO continuously monitors the positions of tracked projectiles (arrows, snowballs, eggs, splash/lingering potions) within a 120-block range of the player. When a projectile enters the shield radius, it is immediately removed and an impact particle effect (INSTANT_EFFECT) is displayed. The spell inherits the base shield mechanism from SpellShieldEffect (spell blocking, level checking, entity targeting prevention).
Shield Configuration:
- Active projectile tracking: continuously monitors projectiles in range
- Maximum tracking distance: 120 blocks (arrow flight distance)
- Supported projectiles: arrows, snowballs, eggs, splash/lingering potions
- Shield removal on projectile entry: projectile is instantly removed
- Pulse effect: disabled (flairPulse = false)
- Impact flair: enabled (flairOnSpellImpact = true) with INSTANT_EFFECT particles
The Shield Charm - Protego - was a charm that protected the caster with an invisible shield that deflected spells.
- See Also:
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionPROTEGO(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating an active projectile-tracking spell shield. -
Method Summary
Modifier and TypeMethodDescriptionvoidTrack projectile positions and remove those crossing the shield boundary.booleanisProjectileTracked(@NotNull org.bukkit.entity.Projectile projectile) Check if a specific projectile is currently being tracked by this shield.Methods inherited from class net.pottercraft.ollivanders2.effect.ShieldSpellEffect
doRemove, getRadiusMethods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, kill, setPermanent
-
Constructor Details
-
PROTEGO
public PROTEGO(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid) Constructor for creating an active projectile-tracking spell shield.Creates a spell shield that actively tracks and blocks projectile attacks. The shield initializes with projectile tracking enabled, impact particle effects configured for INSTANT_EFFECT particles, and displays an initial visual flair at the shield location. Tracked projectiles within 120 blocks are continuously monitored and removed when they cross the shield boundary.
- Parameters:
plugin- a callback to the MC pluginduration- the duration of the shield effect in game ticksisPermanent- is this effect permanent (does not age)pid- the unique ID of the player to shield with projectile protection
-
-
Method Details
-
checkEffect
public void checkEffect()Track projectile positions and remove those crossing the shield boundary.Called each game tick. This method ages the base shield effect and then iterates through all tracked projectiles to check if any have crossed the shield radius boundary. When a projectile enters the protected area, it is immediately removed and an impact flair particle effect is displayed (if flairOnSpellImpact is enabled). Dead projectiles are cleaned from the tracking list. Projectiles can also be blocked through the base SpellShieldEffect mechanism.
- Overrides:
checkEffectin classShieldSpellEffect
-
isProjectileTracked
public boolean isProjectileTracked(@NotNull @NotNull org.bukkit.entity.Projectile projectile) Check if a specific projectile is currently being tracked by this shield.This method is primarily used for testing to verify that projectiles launched within range are properly added to the tracking list.
- Parameters:
projectile- the projectile to check- Returns:
- true if the projectile is in the tracking list, false otherwise
-