Package org.dreambot.api.methods
Class MethodProvider
- java.lang.Object
-
- org.dreambot.api.methods.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 listboolean
bulkImportAccounts(java.io.File file)
Bulk imports accounts using the same format as shown in the Account Manager.boolean
containsAccount(java.lang.String nickname)
Checks if the client has an account with the supplied nicknameboolean
containsAccountWithEmail(java.lang.String email)
Checks if the client has an account with the supplied emailvoid
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.awt.Color color, java.lang.Object message)
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 LogTypestatic 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 consolestatic 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 insteadstatic 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.
-
-
-
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 millisecondsmax
- 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
- predicatetimeout
- 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 rateresetCondition
- the condition that will reset the timeout as long as it's truetimeout
- the timeout is the max amount of time allowed to sleep before continuingpolling
- 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 ratetimeout
- the timeout is the max amount of time allowed to sleep before continuingpolling
- 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
- predicatetimeOut
- 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 ratetimeout
- the timeout is the max amount of time allowed to sleep before continuingpolling
- 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 rateresetCondition
- the condition that will reset the timeout as long as it's truetimeout
- the timeout is the max amount of time allowed to sleep before continuingpolling
- 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(java.awt.Color color, java.lang.Object message)
-
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 messagemessage
- 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 Accountusername
- Username of the Accountpassword
- Password of the Accountpin
- Pin of the Account- Returns:
- False if account already exists, otherwise True.
-
bulkImportAccounts
public boolean bulkImportAccounts(java.io.File file)
Bulk imports accounts using the same format as shown in the Account Manager. Note: This can only be used by VIP users as it is a VIP feature.- Parameters:
file
- The file containing the accounts formatted correctly- Returns:
- true if we are able to read the file, false otherwise
-
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
-
-