Package com.github.mafelp.accounts
Class AccountManager
java.lang.Object
com.github.mafelp.accounts.AccountManager
public class AccountManager
extends java.lang.Object
Manager for creating, saving and loading linked discord and minecraft accounts.
-
Field Summary
Fields Modifier and Type Field Description private static java.io.FileaccountFileThe file in which the accounts are saved.private static java.util.List<Account>linkedAccountsThe list of all linked accounts -
Constructor Summary
Constructors Constructor Description AccountManager() -
Method Summary
Modifier and Type Method Description static java.util.List<Account>addAccount(Account account)Adds an Account to the list of linked accounts.static voidcreateAccountsFile()The method to create an account file.static java.util.List<Account>getLinkedAccounts()The getter for the list of Linked Accounts.static voidloadAccounts()The method that handles starting of the thread, which should load the accounts in.static java.util.List<Account>removeAccount(Account account)Removes an account from the linked accounts.static voidsaveAccounts()The method that saves linkedAccounts to a JSON file.protected static java.util.List<Account>setLinkedAccounts(java.util.List<Account> set)The setter for the list of Linked Accounts.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
linkedAccounts
The list of all linked accounts -
accountFile
private static final java.io.File accountFileThe file in which the accounts are saved.
-
-
Constructor Details
-
AccountManager
public AccountManager()
-
-
Method Details
-
createAccountsFile
public static void createAccountsFile() throws java.io.IOExceptionThe method to create an account file.- Throws:
java.io.IOException- the exception thrown, when the file could not be created, due to an error.
-
saveAccounts
public static void saveAccounts() throws java.io.FileNotFoundExceptionThe method that saves linkedAccounts to a JSON file.- Throws:
java.io.FileNotFoundException- the exception thrown, when the file does not exists, we try to write to.
-
loadAccounts
public static void loadAccounts() throws java.io.IOExceptionThe method that handles starting of the thread, which should load the accounts in.- Throws:
java.io.IOException- The exception that is being thrown, if the accounts.json File does not exists or theAccountLoaderencounters anIOException.
-
getLinkedAccounts
The getter for the list of Linked Accounts.- Returns:
- The linked Accounts list, currently used.
-
setLinkedAccounts
The setter for the list of Linked Accounts. This should only be used by this package!- Parameters:
set- The List to set the linked accounts to.- Returns:
- the list, this method has set, aka. the input list.
-
addAccount
Adds an Account to the list of linked accounts.- Parameters:
account- The account to add- Returns:
- the list of all linked Accounts.
-
removeAccount
Removes an account from the linked accounts.- Parameters:
account- The account link to be removed- Returns:
- The now list of accounts.
-