Class ShieldSpellEffect

java.lang.Object
net.pottercraft.ollivanders2.effect.O2Effect
net.pottercraft.ollivanders2.effect.ShieldSpellEffect
Direct Known Subclasses:
FUMOS, PROTEGO

public abstract class ShieldSpellEffect extends O2Effect
Parent class for all shield effects that block incoming spells.

ShieldSpellEffect provides a protective barrier that blocks spell projectiles from hitting the protected player. The shield operates within a specified radius around the player and prevents spells based on a spell level comparison: the shield can only block spells up to one level higher than the shield spell itself. For example, a shield at level OWL can block spells up to level NEWT (one level higher), but cannot block level EXPERT spells.

Protection Mechanics:

  • Radius: The shield protects in a sphere of radius around the player
  • Spell Level Check: Incoming spell level must be ≤ (shield level + 1) to be blocked
  • Entity Targeting: Prevents enemies from targeting the protected player via entity targeting events
  • Self Exemption: Does not block spells cast by the protected player themselves

Visual Effects:

Subclasses can configure two types of visual particle effects:
  • Pulse Flair: A periodic visual effect displayed every 10 ticks (flairPulse, pulseFlairParticle)
  • Impact Flair: A visual effect displayed when a spell hits the shield boundary (flairOnSpellImpact, impactFlairParticle)
  • Constructor Details

    • ShieldSpellEffect

      public ShieldSpellEffect(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid)
      Constructor for creating a spell shield effect.

      Creates a protective shield around the target player. This constructor attempts to look up the player entity and kills the effect if the player is not found online. Subclasses should set shield configuration fields (radius, flairPulse, flairOnSpellImpact, particles) during initialization.

      Parameters:
      plugin - a callback to the MC plugin
      duration - the duration of the shield in game ticks
      isPermanent - is this effect permanent (does not age)
      pid - the unique ID of the player to protect
  • Method Details

    • checkEffect

      public void checkEffect()
      Check the effect each game tick and apply visual effects.

      This method executes once per tick and performs the following:

      1. Ages the effect by 1 tick (for non-permanent effects)
      2. Returns early if the effect has been killed
      3. If flairPulse is enabled and the duration is divisible by 10 (every 10 ticks / 0.5 seconds), displays the pulse flair particle effect
      Specified by:
      checkEffect in class O2Effect
    • doRemove

      public void doRemove()
      Perform cleanup when this shield effect is removed.

      This method is called when the shield expires or is explicitly removed. The default implementation does nothing, as shields do not require special cleanup (particles and targeting restrictions are automatically handled). Subclasses can override to perform additional cleanup if needed.

      Specified by:
      doRemove in class O2Effect
    • getRadius

      public int getRadius()
      Get the radius for this shield spell effect.
      Returns:
      the radius for this shield spell effect.