Class PrayerToggleGuard

java.lang.Object
privbot.mechanics.PrayerToggleGuard

public final class PrayerToggleGuard extends Object
Stops a prayer toggle the state read never confirmed from being sent again and again.

A prayer click toggles. When a prayer's state cannot be read, the read stays "off" after a successful click, and re-clicking turns the prayer back off. After one unconfirmed toggle, the same toggle waits until the read changes (the caller drops the record) or HOLD_MS passes. Protection prayers ("Protect from ...") and curse deflections ("Deflect ...") are read from the overhead icon and are never held here.

What it proves: mayToggle(privbot.mechanics.PrayerToggleGuard.Toggle, boolean, long) answers false only while an earlier identical toggle is unconfirmed and younger than HOLD_MS.

Unreadable looks like: a null PrayerToggleGuard.Toggle means no earlier unconfirmed toggle, so the click is allowed.

Thread rule: static and pure. Callers keep the records; no client calls, safe on any thread.

  • Field Details

  • Method Details

    • mayToggle

      public static boolean mayToggle(PrayerToggleGuard.Toggle last, boolean enabled, long nowMs)
      Parameters:
      last - the previous unconfirmed toggle of this prayer (from record(boolean, long)), or null for none
      enabled - the direction now wanted
      nowMs - the current time in milliseconds
      Returns:
      false only while an identical toggle is unconfirmed and younger than HOLD_MS
    • record

      public static PrayerToggleGuard.Toggle record(boolean enabled, long nowMs)
      Returns:
      the record of a toggle sent now, to pass to mayToggle(privbot.mechanics.PrayerToggleGuard.Toggle, boolean, long) next time
    • guarded

      public static boolean guarded(String prayerName)
      Whether toggles of this prayer are subject to the hold. False for protection and deflect prayers, which the overhead icon confirms; true for every other named prayer; false for a null name.