1
0
This commit is contained in:
Lee
2024-04-05 17:07:57 +01:00
parent d7d2bb76ac
commit 4e4e122f31
19 changed files with 179 additions and 166 deletions

View File

@ -27,8 +27,8 @@ import java.util.concurrent.TimeUnit;
@Log4j2
public class AccountManager extends Manager implements Listener {
private final long SAVE_INTERVAL = 5; // in minutes
private static final Map<UUID, Account> ACCOUNTS = new HashMap<>();
private final long SAVE_INTERVAL = 5; // in minutes
public AccountManager() {
CommandManager.registerCommand(new SaveAccountsCommand());
@ -46,11 +46,6 @@ public class AccountManager extends Manager implements Listener {
}, SAVE_INTERVAL, SAVE_INTERVAL, TimeUnit.MINUTES);
}
@Override
public Priority getPriority() {
return Priority.LOWEST;
}
/**
* Gets the account for the specified player.
*
@ -61,16 +56,6 @@ public class AccountManager extends Manager implements Listener {
return ACCOUNTS.get(uuid);
}
/**
* Checks if an account is already registered for the specified player.
*
* @param uuid the player's UUID
* @return true if the account is already registered, false otherwise
*/
private boolean isAccountLoaded(UUID uuid) {
return ACCOUNTS.containsKey(uuid);
}
/**
* Registers an account for the specified player.
*
@ -102,6 +87,21 @@ public class AccountManager extends Manager implements Listener {
log.info("Saved {}/{} accounts. ({}ms)", saved, ACCOUNTS.size(), System.currentTimeMillis() - before);
}
@Override
public Priority getPriority() {
return Priority.LOWEST;
}
/**
* Checks if an account is already registered for the specified player.
*
* @param uuid the player's UUID
* @return true if the account is already registered, false otherwise
*/
private boolean isAccountLoaded(UUID uuid) {
return ACCOUNTS.containsKey(uuid);
}
@EventHandler
public void onAsyncPlayerPreLoginEvent(AsyncPlayerPreLoginEvent event) {
UUID uuid = event.getUniqueId();