Class ShotTracker

java.lang.Object
privbot.mechanics.ShotTracker

public final class ShotTracker extends Object
Tells a new projectile launch from one already seen. A projectile stays in the client's list for its whole flight, so a plugin that reacts to every sighting reacts many times; this reports each launch once.

What it proves: a shot returned by fresh(java.util.Collection<privbot.mechanics.ShotView>) was not in the previous call's list (by ShotView.key()). A key that leaves the list and later returns is a new shot.

Unreadable looks like: this holds no client state. Pass only shots that were actually read; a failed read should skip the call, because an empty list would make every live shot look new on the next call.

Thread rule: not thread safe; keep it on the one worker thread that samples shots. No client calls.

  • Constructor Details

    • ShotTracker

      public ShotTracker()
  • Method Details

    • fresh

      public List<ShotView> fresh(Collection<ShotView> active)
      The shots in active whose key is new, in input order. Afterwards, keys not in active are forgotten.
    • clear

      public void clear()