Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,39 @@ public static boolean toggle(Rs2PrayerEnum prayer, boolean on, boolean withMouse
return sleepUntil(() -> isPrayerActive(prayer) == on, 10_000);
}

/**
* Toggles a prayer to a specific state (on or off) with optional mouse control.
* If using mouse, will automatically switch to the prayer tab if not already active.
*
* @param prayer the prayer to toggle
* @param on true to enable the prayer, false to disable it
* @param withMouse true to use mouse
* @param returnTab true to return to the original Tab
* @return true if the prayer is in the desired state after the operation, false otherwise
*/

public static boolean toggle(Rs2PrayerEnum prayer, boolean on, boolean withMouse, boolean returnTab) {
if (isOutOfPrayer()) return false;
if (isPrayerActive(prayer) == on) return true;

InterfaceTab tab = null;
tab = Rs2Tab.getCurrentTab();

if (withMouse && tab != InterfaceTab.PRAYER) {
Rs2Tab.switchTo(InterfaceTab.PRAYER);
}

invokePrayer(prayer, withMouse);

boolean toggleResult = sleepUntil(() -> isPrayerActive(prayer) == on, 10_000);

if (withMouse && returnTab && tab != null && Rs2Tab.getCurrentTab() != tab) {
Rs2Tab.switchTo(tab);
}

return toggleResult;
}

/**
* Invokes a prayer action
* Creates a menu entry and executes it with the appropriate bounds.
Expand Down