Package org.dreambot.api.utilities
Class AccountManager
- java.lang.Object
-
- org.dreambot.api.utilities.AccountManager
-
public class AccountManager extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description AccountManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addAccount(java.lang.String nickname, java.lang.String username, java.lang.String password)
Adds an account with the given nickname, username, and password.static boolean
addAccount(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp)
Adds an account with the given nickname, username, password, bank pin, and totp keystatic boolean
bulkImportAccounts(java.io.File file)
Bulk imports accounts from a file Formats accepted: JSON: {"accounts":[ {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234"}, {"username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234", "pin":"1234"}, {"username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234"} ]} order agnostic nickname optional: defaults to username pin optional: defaults to empty totp optional: defaults to empty Colon Delimited: [email protected]:password1234 Account1:[email protected]:password1234 Account1:[email protected]:password1234:1234 Account1:[email protected]:password1234:1234:totp key Account1:[email protected]:password1234::totp key Given only username:password results in nickname defaulting to usernamestatic boolean
containsAccount(java.lang.String nickname)
Checks if the client has an account with the supplied nicknamestatic boolean
containsAccountWithEmail(java.lang.String email)
Checks if the client has an account with the supplied emailstatic boolean
deleteAccount(java.lang.String nickname)
Removes the account with the specified nickname from the accounts list.static java.lang.String
getAccountHash()
Hashes the selected account's username, which is allowed in SDN scripts (unlike getUsername)static java.lang.String
getAccountNickname()
Gets the currently selected account's nicknamestatic java.lang.String
getAccountUsername()
static java.util.List<java.lang.String>
getAll()
Gets a list of all account nicknamesstatic boolean
hasPin(java.lang.String nickname)
Checks if the account matching the given nickname has a bank pin value setstatic boolean
isBanned(java.lang.String nickname)
Checks if the account matching the given nickname is set to bannedstatic boolean
setAccount(java.lang.String nickname)
Sets the currently selected account based on nicknamestatic boolean
updateAccount(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp)
Updates an account based on the given username If an account does not yet exist for this username, a new one will be addedstatic boolean
updateAccount(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp, boolean banned)
Updates an account based on the given username If an account does not yet exist for this username, a new one will be added
-
-
-
Method Detail
-
setAccount
public static boolean setAccount(java.lang.String nickname)
Sets the currently selected account based on nickname- Parameters:
nickname
- Nickname of the account to select- Returns:
- True if successfully finds and sets selected account, else false
-
addAccount
public static boolean addAccount(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp)
Adds an account with the given nickname, username, password, bank pin, and totp key- Parameters:
nickname
- Nickname for the accountusername
- Login username for the accountpassword
- password for the accountpin
- bank pin for the account, empty if no bank pin neededtotp
- totp key for the account, empty if no totp key needed- Returns:
- False if account username already exists or account nickname already exists, else true if added successfully
-
updateAccount
public static boolean updateAccount(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp)
Updates an account based on the given username If an account does not yet exist for this username, a new one will be added- Parameters:
nickname
- nickname for the accountusername
- login email for the accountpassword
- login password for the accountpin
- bank pin for the account, empty if no bank pin neededtotp
- totp key for the account, empty if no totp key needed- Returns:
-
updateAccount
public static boolean updateAccount(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp, boolean banned)
Updates an account based on the given username If an account does not yet exist for this username, a new one will be added- Parameters:
nickname
- nickname for the accountusername
- login email for the accountpassword
- login password for the accountpin
- bank pin for the account, empty if no bank pin neededtotp
- totp key for the account, empty if no totp key neededbanned
- if the account is banned- Returns:
-
addAccount
public static boolean addAccount(java.lang.String nickname, java.lang.String username, java.lang.String password)
Adds an account with the given nickname, username, and password. Defaults bank pin and totp key to empty- Parameters:
nickname
- Nickname for the accountusername
- Login username for the accountpassword
- Password for the account- Returns:
- False if account username already exists or account nickname already exists, else true if added successfully
-
getAccountNickname
public static java.lang.String getAccountNickname()
Gets the currently selected account's nickname- Returns:
- current account nickname or null if no selected account
-
bulkImportAccounts
public static boolean bulkImportAccounts(java.io.File file)
Bulk imports accounts from a file Formats accepted: JSON: {"accounts":[ {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234"}, {"username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234", "pin":"1234"}, {"username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234"} ]} order agnostic nickname optional: defaults to username pin optional: defaults to empty totp optional: defaults to empty Colon Delimited: [email protected]:password1234 Account1:[email protected]:password1234 Account1:[email protected]:password1234:1234 Account1:[email protected]:password1234:1234:totp key Account1:[email protected]:password1234::totp key Given only username:password results in nickname defaulting to username- Parameters:
file
- The file containing the accounts formatted correctly- Returns:
- true if we are able to read the file, false otherwise
-
deleteAccount
public static boolean deleteAccount(java.lang.String nickname)
Removes the account with the specified nickname from the accounts list.- Parameters:
nickname
- nickname of account to delete- Returns:
- True of account successfully deleted
-
containsAccount
public static 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 static boolean containsAccountWithEmail(java.lang.String email)
Checks if the client has an account with the supplied email- Parameters:
email
- The account's login email- Returns:
- true if the client has a matching account, false otherwise
-
getAccountUsername
public static java.lang.String getAccountUsername()
-
getAccountHash
public static java.lang.String getAccountHash()
Hashes the selected account's username, which is allowed in SDN scripts (unlike getUsername)- Returns:
- A Base64 encoded SHA-256 hash of the player's username if an account is selected, otherwise returns an empty string
-
getAll
public static java.util.List<java.lang.String> getAll()
Gets a list of all account nicknames- Returns:
-
isBanned
public static boolean isBanned(java.lang.String nickname)
Checks if the account matching the given nickname is set to banned- Parameters:
nickname
- nickname to check account for, case-insensitive- Returns:
- true if found and banned, else false
-
hasPin
public static boolean hasPin(java.lang.String nickname)
Checks if the account matching the given nickname has a bank pin value set- Parameters:
nickname
- nickname of the account to check, case-insensitive- Returns:
- true if account is found and has a not empty bank pin, else false
-
-