Class MethodProvider

  • Direct Known Subclasses:
    MethodContext

    public class MethodProvider
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  MethodProvider.LogType  
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodProvider()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean addAccount​(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin)
      Adds an Account to the Account manager list
      boolean containsAccount​(java.lang.String nickname)
      Checks if the client has an account with the supplied nickname
      boolean containsAccountWithEmail​(java.lang.String email)
      Checks if the client has an account with the supplied email
      void deleteAccount​(java.lang.String nickname)
      Removes the account with the specified nickname from the accounts list.
      Client getClient()
      Deprecated.
      Player getLocalPlayer()  
      boolean isUserSponsor()
      Checks whether the DreamBot member logged into the client is a Sponsor or above (This includes but may not be limited to: Staff, Ex-Staff, Scripters, and Lead Designer)
      boolean isUserVIP()
      Checks whether the DreamBot member logged into the client is a VIP member or above (this includes but may not be limited to: Staff, Ex-Staff, Sponsor, Scripters, and Lead Designer)
      static void log​(java.lang.Object object)  
      static void log​(java.lang.String message)  
      static void log​(MethodProvider.LogType type, java.lang.String message)
      Logs a message to the console with specified LogType
      static void logError​(java.lang.Object object)  
      static void logError​(java.lang.String message)  
      static void logInfo​(java.lang.Object object)  
      static void logInfo​(java.lang.String message)
      Logs a message to the console
      static void setRandomThread​(java.lang.Thread randomThread)  
      static void sleep​(int ms)
      Sleeps for specified milliseconds Do NOT use this in custom mouse algorithms, as it will cause blocking forever during random events, use Thread#sleep instead
      static void sleep​(int min, int max)
      Sleeps for a random number of milliseconds between min (inclusive) and max (exclusive)
      static boolean sleepUntil​(Condition predicate, int timeout, int polling)
      Sleep until the given timeout value or condition is met; polling at a rate defined by used.
      static boolean sleepUntil​(Condition predicate, long timeout)
      Sleeps until the passed predicate returns true or sleeping for longer than the timeout.
      static boolean sleepUntil​(Condition predicate, Condition resetCondition, int timeout, int polling)
      Sleep until the given timeout value after a false reset condition or the condition is met.
      static boolean sleepWhile​(Condition predicate, int timeout, int polling)
      Sleep while the given timeout value or condition is met; polling at a rate defined by used.
      static boolean sleepWhile​(Condition predicate, long timeOut)
      Sleeps until the passed predicate returns false.
      static boolean sleepWhile​(Condition predicate, Condition resetCondition, int timeout, int polling)
      Sleeps while the given timeout value after a false reset condition or the condition is met.
      • Methods inherited from class java.lang.Object

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

      • MethodProvider

        public MethodProvider()
    • Method Detail

      • sleep

        public static void sleep​(int ms)
        Sleeps for specified milliseconds Do NOT use this in custom mouse algorithms, as it will cause blocking forever during random events, use Thread#sleep instead
        Parameters:
        ms - milliseconds to sleep for
      • sleep

        public static void sleep​(int min,
                                 int max)
        Sleeps for a random number of milliseconds between min (inclusive) and max (exclusive)
        Parameters:
        min - minimum number of milliseconds
        max - maximum number of milliseconds
      • sleepUntil

        public static boolean sleepUntil​(Condition predicate,
                                         long timeout)
        Sleeps until the passed predicate returns true or sleeping for longer than the timeout. Polls every 50ms by default.
        Parameters:
        predicate - predicate
        timeout - millis time out
      • sleepUntil

        public static boolean sleepUntil​(Condition predicate,
                                         Condition resetCondition,
                                         int timeout,
                                         int polling)
        Sleep until the given timeout value after a false reset condition or the condition is met. Polls at the rate set. Please be careful with the reset condition as something that is always true will keep sleeping until the script is stopped.
        Parameters:
        predicate - the condition to check for completion at the given polling rate
        resetCondition - the condition that will reset the timeout as long as it's true
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • sleepUntil

        public static boolean sleepUntil​(Condition predicate,
                                         int timeout,
                                         int polling)
        Sleep until the given timeout value or condition is met; polling at a rate defined by used.
        Parameters:
        predicate - the condition to check at the given polling rate
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • sleepWhile

        public static boolean sleepWhile​(Condition predicate,
                                         long timeOut)
        Sleeps until the passed predicate returns false. Polls every 50ms by default.
        Parameters:
        predicate - predicate
        timeOut - millis time out
      • sleepWhile

        public static boolean sleepWhile​(Condition predicate,
                                         int timeout,
                                         int polling)
        Sleep while the given timeout value or condition is met; polling at a rate defined by used.
        Parameters:
        predicate - the predicate to check at the given polling rate
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • sleepWhile

        public static boolean sleepWhile​(Condition predicate,
                                         Condition resetCondition,
                                         int timeout,
                                         int polling)
        Sleeps while the given timeout value after a false reset condition or the condition is met. Polls at the rate set. Please be careful with the reset condition as something that is always true will keep sleeping until the script is stopped.
        Parameters:
        predicate - the condition to check for completion at the given polling rate
        resetCondition - the condition that will reset the timeout as long as it's true
        timeout - the timeout is the max amount of time allowed to sleep before continuing
        polling - the polling is rate at which to check the given condition
      • logInfo

        public static void logInfo​(java.lang.String message)
        Logs a message to the console
        Parameters:
        message - Message to log
      • logInfo

        public static void logInfo​(java.lang.Object object)
      • logError

        public static void logError​(java.lang.String message)
      • logError

        public static void logError​(java.lang.Object object)
      • log

        public static void log​(java.lang.String message)
      • log

        public static void log​(java.lang.Object object)
      • log

        public static void log​(MethodProvider.LogType type,
                               java.lang.String message)
        Logs a message to the console with specified LogType
        Parameters:
        type - LogType of message
        message - Message to log
      • setRandomThread

        public static void setRandomThread​(java.lang.Thread randomThread)
      • getLocalPlayer

        public Player getLocalPlayer()
      • getClient

        @Deprecated
        public Client getClient()
        Deprecated.
        Gets the Client this MethodProvider is set to
        Returns:
        Client of MethodProvider
      • isUserVIP

        public boolean isUserVIP()
        Checks whether the DreamBot member logged into the client is a VIP member or above (this includes but may not be limited to: Staff, Ex-Staff, Sponsor, Scripters, and Lead Designer)
        Returns:
        true if VIP or above
      • isUserSponsor

        public boolean isUserSponsor()
        Checks whether the DreamBot member logged into the client is a Sponsor or above (This includes but may not be limited to: Staff, Ex-Staff, Scripters, and Lead Designer)
        Returns:
        true if Sponsor or above
      • addAccount

        public boolean addAccount​(java.lang.String nickname,
                                  java.lang.String username,
                                  java.lang.String password,
                                  java.lang.String pin)
        Adds an Account to the Account manager list
        Parameters:
        nickname - Nickname of the Account
        username - Username of the Account
        password - Password of the Account
        pin - Pin of the Account
        Returns:
        False if account already exists, otherwise True.
      • deleteAccount

        public void deleteAccount​(java.lang.String nickname)
        Removes the account with the specified nickname from the accounts list.
        Parameters:
        nickname -
      • containsAccount

        public boolean containsAccount​(java.lang.String nickname)
        Checks if the client has an account with the supplied nickname
        Parameters:
        nickname - The account's nickname
        Returns:
        true if the client has a matching account, false otherwise
      • containsAccountWithEmail

        public boolean containsAccountWithEmail​(java.lang.String email)
        Checks if the client has an account with the supplied email
        Parameters:
        email - The account's email
        Returns:
        true if the client has a matching account, false otherwise