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
addAccount(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp, java.lang.String characterID, java.lang.String sessionID)
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
getAccountBankPin()
Gets the currently selected account's bank pinstatic 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
getAccountTOTPKey()
Gets the currently selected account's TOTP keystatic 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
isLegacyAccount()
Checks if the current account is a legacy accountstatic 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 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, java.lang.String characterID, java.lang.String sessionID)
static boolean
updateBanStatus(java.lang.String nickname, boolean banned)
Updates the ban status on an account based on the given nickname.
-
-
-
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
-
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, java.lang.String characterID, java.lang.String sessionID)
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 neededcharacterID
- character ID retrieved from the jagex launcher accountssessionID
- session ID retrieved from the jagex launcher accounts- 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:
-
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, java.lang.String characterID, java.lang.String sessionID)
-
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
-
getAccountBankPin
public static java.lang.String getAccountBankPin()
Gets the currently selected account's bank pin- Returns:
- current account bank pin or null if no selected account
-
getAccountTOTPKey
public static java.lang.String getAccountTOTPKey()
Gets the currently selected account's TOTP key- Returns:
- current account TOTP key or null if no selected account
-
isLegacyAccount
public static boolean isLegacyAccount()
Checks if the current account is a legacy account- Returns:
- true if it is or if there is no account set
-
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
-
updateBanStatus
public static boolean updateBanStatus(java.lang.String nickname, boolean banned)
Updates the ban status on an account based on the given nickname.- Parameters:
nickname
- nickname to match against the saved account, also checks the given nickname against the account usernamebanned
- True if banned, False if not- Returns:
- True if successfully sets an account's ban status. False if the account was not found.
-
-