Class PrayerToggleGuard
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne unconfirmed toggle: the direction asked for and when it was sent. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanWhether toggles of this prayer are subject to the hold.static booleanmayToggle(PrayerToggleGuard.Toggle last, boolean enabled, long nowMs) static PrayerToggleGuard.Togglerecord(boolean enabled, long nowMs)
-
Field Details
-
HOLD_MS
public static final long HOLD_MS- See Also:
-
-
Method Details
-
mayToggle
- Parameters:
last- the previous unconfirmed toggle of this prayer (fromrecord(boolean, long)), or null for noneenabled- the direction now wantednowMs- the current time in milliseconds- Returns:
- false only while an identical toggle is unconfirmed and younger than
HOLD_MS
-
record
- Returns:
- the record of a toggle sent now, to pass to
mayToggle(privbot.mechanics.PrayerToggleGuard.Toggle, boolean, long)next time
-
guarded
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.
-