Class AccountManager

java.lang.Object
com.github.mafelp.accounts.AccountManager

public class AccountManager extends Object
Manager for creating, saving and loading linked discord and minecraft accounts.
  • Field Details

    • linkedAccounts

      private static List<Account> linkedAccounts
      The list of all linked accounts
    • accountFile

      private static final File accountFile
      The file in which the accounts are saved.
  • Constructor Details

    • AccountManager

      public AccountManager()
  • Method Details

    • createAccountsFile

      public static void createAccountsFile() throws IOException
      The method to create an account file.
      Throws:
      IOException - the exception thrown, when the file could not be created, due to an error.
    • saveAccounts

      public static void saveAccounts() throws FileNotFoundException
      The method that saves linkedAccounts to a JSON file.
      Throws:
      FileNotFoundException - the exception thrown, when the file does not exists, we try to write to.
    • loadAccounts

      public static void loadAccounts() throws IOException
      The method that handles starting of the thread, which should load the accounts in.
      Throws:
      IOException - The exception that is being thrown, if the accounts.json File does not exists or the AccountLoader encounters an IOException.
    • getLinkedAccounts

      public static List<Account> getLinkedAccounts()
      The getter for the list of Linked Accounts.
      Returns:
      The linked Accounts list, currently used.
    • setLinkedAccounts

      protected static List<Account> setLinkedAccounts(List<Account> set)
      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

      public static List<Account> addAccount(Account account)
      Adds an Account to the list of linked accounts.
      Parameters:
      account - The account to add
      Returns:
      the list of all linked Accounts.
    • removeAccount

      public static List<Account> removeAccount(Account account)
      Removes an account from the linked accounts.
      Parameters:
      account - The account link to be removed
      Returns:
      The now list of accounts.
    • getAllMinecraftAccountNames

      public static List<String> getAllMinecraftAccountNames()
      Gets all names of minecraft Players who have an account and all the usernames.
      Returns:
      The list of names and usernames.