Klasse ThreatService

java.lang.Object
de.delinkedde.mobarenareborn.threat.ThreatService

public final class ThreatService extends Object
Turns recorded threat into mob targeting and keeps the threat table tidy.

When a player damages an arena mob the threat is recorded and the mob is retargeted to its top-threat player. A taunt overrides threat so the tank becomes the target. A periodic prune removes records for mobs that no longer exist (for example mobs removed when a round ends without a death event).

Targeting uses the public Mob.setTarget(LivingEntity) API; no server internals are touched.

  • Konstruktordetails

    • ThreatService

      public ThreatService(@NotNull @NotNull MobArenaPlugin plugin)
      Parameter:
      plugin - the owning plugin, used for scheduling the prune task
  • Methodendetails

    • start

      public void start()
      Starts the periodic prune task. Safe to call once during enable.
    • stop

      public void stop()
      Cancels the prune task and clears all threat.
    • onDamage

      public void onDamage(@NotNull @NotNull LivingEntity mob, @NotNull @NotNull Player player, double amount)
      Records damage threat and retargets the mob.
      Parameter:
      mob - the damaged arena mob
      player - the attacking player
      amount - the damage dealt
    • taunt

      public void taunt(@NotNull @NotNull Collection<? extends LivingEntity> mobs, @NotNull @NotNull Player tank, double threatValue)
      Forces the given mobs to target a player by setting maximum threat (taunt).
      Parameter:
      mobs - the mobs to taunt
      tank - the player to draw aggro to
      threatValue - the absolute threat value to assign
    • removeMob

      public void removeMob(@NotNull @NotNull UUID mob)
      Removes threat records for a mob.
      Parameter:
      mob - the mob id
    • removePlayer

      public void removePlayer(@NotNull @NotNull UUID player)
      Removes a player from all threat records.
      Parameter:
      player - the player id