Class 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
      void activatePrayer​(net.runelite.api.Prayer prayer)
      Wrapper method which turns a prayer on.
      void deactivateAll()
      Deactivates all prayers (including preserve)
      boolean deactivateAll​(boolean keepPreserve)
      Deactivates all prayers.
      boolean deactivateAll​(boolean keepPreserveOn, boolean onlyProtectionPrayers, int maxActions)
      Deactivates prayers based on the provided parameters.
      boolean deactivatePrayer​(net.runelite.api.Prayer prayer)
      Wrapper method which turns a prayer off.
      void deactivateProtectionPrayers()
      Deactivates all protection prayers (protect from range, melee, and magic) but will keep other prayers like preserve and protect item active.
      void disableQuickPrayers()
      Turns off the set quick prayers
      void enableQuickPrayers()
      Turns on the set quick prayers
      void flickQuickPrayers()
      Performs a quick flick of the player's quick prayers.
      InteractablePrayer getActiveOverhead()
      Retrieves the currently active overhead InteractablePrayer.
      static java.util.List<InteractablePrayer> getActivePrayers()
      Retrieves a list of all currently active prayers.
      boolean isActive​(net.runelite.api.Prayer prayer)
      Returns true if the prayer is active and false otherwise.
      boolean isOutOfPrayer()
      Checks if the player is out of prayer.
      boolean isQuickPrayerEnabled()
      Determines if quick prayers are currently enabled for the player.
      boolean isQuickPrayerSet​(InteractablePrayer prayer)
      Checks if a given quick prayer is set
      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.
      void setQuickPrayers​(InteractablePrayer... prayers)
      Sets the quick prayers for the player by sending the appropriate widget action packets.
      boolean toggle​(net.runelite.api.Prayer prayer)
      Toggles a prayer on or off.
      boolean toggle​(net.runelite.api.Prayer prayer, boolean activate)
      Toggles a prayer on or off.
      void toggleQuickPrayers()
      Toggles the set quick prayers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PrayerService

        public PrayerService()
    • 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 toggle
        activate - 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 Prayer values, selectively deactivating prayers according to the following conditions:

        • It skips prayers with names containing "RP_" (Ruinous Prayers).
        • If keepPreserveOn is true, the PRESERVE prayer will not be deactivated.
        • If onlyProtectionPrayers is true, 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 the PRESERVE prayer should remain active.
        onlyProtectionPrayers - a boolean indicating whether only protection prayers should be deactivated.
        maxActions - the maximum number of deactivation actions to perform.
        Returns:
        true if all applicable prayers were successfully processed within the maxActions limit; false if the method aborted early due to reaching the maxActions limit.
      • 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 disableAll is set to true, all active prayers are deactivated before activating the specified ones; otherwise, only the prayers included in the list are toggled.

        Parameters:
        disableAll - A boolean value indicating if all currently active prayers should be disabled before activating the specified prayers. If true, all existing prayers (except Ruinous Prayers) are deactivated.
        prayers - A varargs list of Prayer objects 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 InteractablePrayer instances and checks if they are active by invoking isActive() on each. Any prayers identified as active are added to the returned list.

        Returns:
        A List of InteractablePrayer objects that are currently active.
      • getActiveOverhead

        public InteractablePrayer getActiveOverhead()
        Retrieves the currently active overhead InteractablePrayer.

        This method iterates through all available InteractablePrayer values 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.
        If a prayer meets both conditions, it is returned immediately. If no active overhead prayer is found, the method returns null.
        Returns:
        The active overhead InteractablePrayer, or null if 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 true indicates that quick prayers are enabled, while false signifies that they are disabled.

        Returns:
        true if quick prayers are enabled, false otherwise.
      • 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 of InteractablePrayer objects 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 calling toggleQuickPrayers() 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.