Class Snapshot<S>

java.lang.Object
privbot.ui.overlay.Snapshot<S>
Type Parameters:
S - the published value; make it immutable (a record-style class or a copied bean)
All Implemented Interfaces:
Supplier<S>

public final class Snapshot<S> extends Object implements Supplier<S>
State published on the game tick and read on the render thread.

On Impact the overlay renderer runs on the game's render thread, where a client hook (GameThread.ensure) times out; the working overlays all follow the same idiom — copy what the overlay needs into plain fields on the tick, read only those in render. This type is that idiom with a name: a plugin publishes an immutable value from its tick handler and hands the same holder to PrivBotOverlays, whose composers receive the value and nothing else.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Forget the value; overlays composed from this snapshot stop rendering until the next publish.
    static <S> Snapshot<S>
    A snapshot with nothing published yet; overlays reading it draw nothing until the first publish.
    get()
    The current value, or null when nothing has been published (render thread).
    boolean
    True when nothing is published (never published, or cleared).
    static <S> Snapshot<S>
    of(S initial)
    A snapshot that starts with initial (may be null).
    void
    publish(S next)
    Replace the published value (tick thread).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • empty

      public static <S> Snapshot<S> empty()
      A snapshot with nothing published yet; overlays reading it draw nothing until the first publish.
    • of

      public static <S> Snapshot<S> of(S initial)
      A snapshot that starts with initial (may be null).
    • publish

      public void publish(S next)
      Replace the published value (tick thread).
    • clear

      public void clear()
      Forget the value; overlays composed from this snapshot stop rendering until the next publish.
    • get

      public S get()
      The current value, or null when nothing has been published (render thread).
      Specified by:
      get in interface Supplier<S>
    • isEmpty

      public boolean isEmpty()
      True when nothing is published (never published, or cleared).