Class PrayerService
- java.lang.Object
-
- com.kraken.api.service.prayer.PrayerService
-
public class PrayerService extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description PrayerService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivatePrayer(net.runelite.api.Prayer prayer)Wrapper method which turns a prayer on.voiddeactivateAll()Deactivates all prayers (including preserve)booleandeactivateAll(boolean keepPreserve)Deactivates all prayers.booleandeactivateAll(boolean keepPreserveOn, boolean onlyProtectionPrayers, int maxActions)Deactivates prayers based on the provided parameters.booleandeactivatePrayer(net.runelite.api.Prayer prayer)Wrapper method which turns a prayer off.voiddeactivateProtectionPrayers()Deactivates all protection prayers (protect from range, melee, and magic) but will keep other prayers like preserve and protect item active.voiddisableQuickPrayers()Turns off the set quick prayersvoidenableQuickPrayers()Turns on the set quick prayersvoidflickQuickPrayers()Performs a quick flick of the player's quick prayers.InteractablePrayergetActiveOverhead()Retrieves the currently active overheadInteractablePrayer.static java.util.List<InteractablePrayer>getActivePrayers()Retrieves a list of all currently active prayers.booleanisActive(net.runelite.api.Prayer prayer)Returns true if the prayer is active and false otherwise.booleanisOutOfPrayer()Checks if the player is out of prayer.booleanisQuickPrayerEnabled()Determines if quick prayers are currently enabled for the player.booleanisQuickPrayerSet(InteractablePrayer prayer)Checks if a given quick prayer is setvoidoneTickFlick(boolean disableAll, net.runelite.api.Prayer... prayers)Performs a one-tick prayer flick, enabling and disabling specified prayers within the same game tick.voidsetQuickPrayers(InteractablePrayer... prayers)Sets the quick prayers for the player by sending the appropriate widget action packets.booleantoggle(net.runelite.api.Prayer prayer)Toggles a prayer on or off.booleantoggle(net.runelite.api.Prayer prayer, boolean activate)Toggles a prayer on or off.voidtoggleQuickPrayers()Toggles the set quick prayers.
-
-
-
Method Detail
-
activatePrayer
public void activatePrayer(net.runelite.api.Prayer prayer)
Wrapper method which turns a prayer on.- Parameters:
prayer- The prayer to turn on.
-
deactivatePrayer
public boolean deactivatePrayer(net.runelite.api.Prayer prayer)
Wrapper method which turns a prayer off.- Parameters:
prayer- The prayer to turn off.- Returns:
- Boolean true if the prayer was activated/deactivated successfully and false otherwise.
-
toggle
public boolean toggle(net.runelite.api.Prayer prayer)
Toggles a prayer on or off. This will use reflection based prayer toggles by default.- Parameters:
prayer- The Prayer to toggle- Returns:
- Boolean true if the prayer was activated/deactivated successfully and false otherwise.
-
toggle
public boolean toggle(net.runelite.api.Prayer prayer, boolean activate)Toggles a prayer on or off.- Parameters:
prayer- The Prayer to toggleactivate- True if the prayer should be turned on and false if it should be turned off- Returns:
- Boolean true if the prayer was activated/deactivated successfully and false otherwise.
-
isActive
public boolean isActive(net.runelite.api.Prayer prayer)
Returns true if the prayer is active and false otherwise.- Parameters:
prayer- Prayer to check.- Returns:
- Boolean true if the prayer is active (on) and false otherwise.
-
deactivateAll
public boolean deactivateAll(boolean keepPreserveOn, boolean onlyProtectionPrayers, int maxActions)Deactivates prayers based on the provided parameters. This method can limit the deactivation to specific types of prayers and ensure certain prayers are preserved.This method iterates through all available
Prayervalues, selectively deactivating prayers according to the following conditions:- It skips prayers with names containing "RP_" (Ruinous Prayers).
- If
keepPreserveOnistrue, thePRESERVEprayer will not be deactivated. - If
onlyProtectionPrayersistrue, only prayers categorized as protection prayers will be deactivated. - Deactivation will stop once the number of actions taken reaches
maxActions.
- Parameters:
keepPreserveOn- a boolean indicating whether thePRESERVEprayer should remain active.onlyProtectionPrayers- a boolean indicating whether only protection prayers should be deactivated.maxActions- the maximum number of deactivation actions to perform.- Returns:
trueif all applicable prayers were successfully processed within themaxActionslimit;falseif the method aborted early due to reaching themaxActionslimit.
-
deactivateAll
public boolean deactivateAll(boolean keepPreserve)
Deactivates all prayers. This method allows specifying whether to keep the preserve prayer on when deactivating other prayers- Parameters:
keepPreserve- true to retain specified preserved states during deactivation, false to deactivate entirely without preservation.- Returns:
- true if the deactivation process completes successfully, false otherwise.
-
deactivateAll
public void deactivateAll()
Deactivates all prayers (including preserve)
-
deactivateProtectionPrayers
public void deactivateProtectionPrayers()
Deactivates all protection prayers (protect from range, melee, and magic) but will keep other prayers like preserve and protect item active.
-
oneTickFlick
public void oneTickFlick(boolean disableAll, net.runelite.api.Prayer... prayers)Performs a one-tick prayer flick, enabling and disabling specified prayers within the same game tick. This ensures minimal prayer drain while maintaining the effects of the selected prayers.The method first identifies any currently active prayers and deactivates them if needed. Then, the specified prayers in the @<varargs> parameter are activated. If
disableAllis set totrue, all active prayers are deactivated before activating the specified ones; otherwise, only the prayers included in the list are toggled.- Parameters:
disableAll- Abooleanvalue indicating if all currently active prayers should be disabled before activating the specified prayers. Iftrue, all existing prayers (except Ruinous Prayers) are deactivated.prayers- A varargs list ofPrayerobjects that should be activated during the one-tick flick process. These prayers are toggled on after any necessary deactivations are completed. If no prayers are provided, no activation takes place.
-
getActivePrayers
public static java.util.List<InteractablePrayer> getActivePrayers()
Retrieves a list of all currently active prayers.This method iterates through all available
InteractablePrayerinstances and checks if they are active by invokingisActive()on each. Any prayers identified as active are added to the returned list.- Returns:
- A
ListofInteractablePrayerobjects that are currently active.
-
getActiveOverhead
public InteractablePrayer getActiveOverhead()
Retrieves the currently active overheadInteractablePrayer.This method iterates through all available
InteractablePrayervalues and checks each one for the following conditions:- The prayer is currently active, as determined by its state.
- The prayer is classified as an overhead prayer based on additional logic.
null.- Returns:
- The active overhead
InteractablePrayer, ornullif no overhead prayer is active.
-
isQuickPrayerSet
public boolean isQuickPrayerSet(InteractablePrayer prayer)
Checks if a given quick prayer is set- Parameters:
prayer- The quick prayer to check- Returns:
- True if the quick prayer is set and false otherwise
-
isQuickPrayerEnabled
public boolean isQuickPrayerEnabled()
Determines if quick prayers are currently enabled for the player.The method checks the value of the @VarbitID.QUICKPRAYER_ACTIVE game state variable to assess whether quick prayers are active. A return value of
trueindicates that quick prayers are enabled, whilefalsesignifies that they are disabled.- Returns:
trueif quick prayers are enabled,falseotherwise.
-
setQuickPrayers
public void setQuickPrayers(InteractablePrayer... prayers)
Sets the quick prayers for the player by sending the appropriate widget action packets. If a specified prayer is already set as a quick prayer, it will be skipped.- Parameters:
prayers- The @varargs array ofInteractablePrayerobjects to be set as quick prayers. Null values and prayers that are already set will be ignored.
-
isOutOfPrayer
public boolean isOutOfPrayer()
Checks if the player is out of prayer.- Returns:
- Returns true if the player is out of prayer and false if they still have prayer.
-
toggleQuickPrayers
public void toggleQuickPrayers()
Toggles the set quick prayers. If the quick prayers are on, they will be turned off. If they are off, they will be turned on.
-
enableQuickPrayers
public void enableQuickPrayers()
Turns on the set quick prayers
-
disableQuickPrayers
public void disableQuickPrayers()
Turns off the set quick prayers
-
flickQuickPrayers
public void flickQuickPrayers()
Performs a quick flick of the player's quick prayers.This method is designed to activate and deactivate the player's quick prayers in a single operation. If quick prayers are currently disabled, they will be turned on by invoking
enableQuickPrayers(). If quick prayers are already enabled, the method performs a rapid sequence of toggles by callingtoggleQuickPrayers()twice.The behavior of this method ensures that quick prayers are briefly flicked and restored, which may be used in scenarios such as prayer management or minimizing prayer drain during certain game activities.
- If quick prayers are not enabled, they are activated, and no toggle operation is performed.
- If quick prayers are enabled, they are toggled off and back on in quick succession.
-
-