From a81e8305a022bf1d4dd4e0a2e9e34eea2d9afba3 Mon Sep 17 00:00:00 2001 From: Vankka Date: Sat, 29 Jun 2024 14:06:28 +0300 Subject: [PATCH] Load storage before linked account provider --- .../discordsrv/common/AbstractDiscordSRV.java | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java index 268a0c95..dc704687 100644 --- a/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java +++ b/common/src/main/java/com/discordsrv/common/AbstractDiscordSRV.java @@ -694,42 +694,6 @@ public abstract class AbstractDiscordSRV< scheduler().runAtFixedRate(() -> updateChecker.check(false), Duration.ofHours(6)); } - if (flags.contains(ReloadFlag.LINKED_ACCOUNT_PROVIDER)) { - LinkedAccountConfig linkedAccountConfig = config().linkedAccounts; - if (linkedAccountConfig != null && linkedAccountConfig.enabled) { - LinkedAccountConfig.Provider provider = linkedAccountConfig.provider; - boolean permitMinecraftAuth = connectionConfig().minecraftAuth.allow; - if (provider == LinkedAccountConfig.Provider.AUTO) { - provider = permitMinecraftAuth && onlineMode().isOnline() ? LinkedAccountConfig.Provider.MINECRAFTAUTH : LinkedAccountConfig.Provider.STORAGE; - } - switch (provider) { - case MINECRAFTAUTH: - if (!permitMinecraftAuth) { - linkProvider = null; - logger().error("minecraftauth.me is disabled in the " + ConnectionConfig.FILE_NAME + ", " - + "but linked-accounts.provider is set to \"minecraftauth\". Linked accounts will be disabled"); - break; - } - dependencyManager.mcAuthLib().downloadRelocateAndLoad().get(); - linkProvider = new MinecraftAuthenticationLinker(this); - logger().info("Using minecraftauth.me for linked accounts"); - break; - case STORAGE: - linkProvider = new StorageLinker(this); - logger().info("Using storage for linked accounts"); - break; - default: { - linkProvider = null; - logger().error("Unknown linked account provider: \"" + provider + "\", linked accounts will not be used"); - break; - } - } - } else { - linkProvider = null; - logger().info("Linked accounts are disabled"); - } - } - if (flags.contains(ReloadFlag.STORAGE)) { if (storage != null) { storage.close(); @@ -766,6 +730,42 @@ public abstract class AbstractDiscordSRV< } } + if (flags.contains(ReloadFlag.LINKED_ACCOUNT_PROVIDER)) { + LinkedAccountConfig linkedAccountConfig = config().linkedAccounts; + if (linkedAccountConfig != null && linkedAccountConfig.enabled) { + LinkedAccountConfig.Provider provider = linkedAccountConfig.provider; + boolean permitMinecraftAuth = connectionConfig().minecraftAuth.allow; + if (provider == LinkedAccountConfig.Provider.AUTO) { + provider = permitMinecraftAuth && onlineMode().isOnline() ? LinkedAccountConfig.Provider.MINECRAFTAUTH : LinkedAccountConfig.Provider.STORAGE; + } + switch (provider) { + case MINECRAFTAUTH: + if (!permitMinecraftAuth) { + linkProvider = null; + logger().error("minecraftauth.me is disabled in the " + ConnectionConfig.FILE_NAME + ", " + + "but linked-accounts.provider is set to \"minecraftauth\". Linked accounts will be disabled"); + break; + } + dependencyManager.mcAuthLib().downloadRelocateAndLoad().get(); + linkProvider = new MinecraftAuthenticationLinker(this); + logger().info("Using minecraftauth.me for linked accounts"); + break; + case STORAGE: + linkProvider = new StorageLinker(this); + logger().info("Using storage for linked accounts"); + break; + default: { + linkProvider = null; + logger().error("Unknown linked account provider: \"" + provider + "\", linked accounts will not be used"); + break; + } + } + } else { + linkProvider = null; + logger().info("Linked accounts are disabled"); + } + } + if (flags.contains(ReloadFlag.DISCORD_CONNECTION)) { try { if (discordConnectionManager.instance() != null) {