From 0fb6102c29c5c8457f3a9420d1d3a1ffa1be78e5 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:17:45 +0700 Subject: [PATCH] [FEATURE] MixProvider init --- .../pro/gravit/launchserver/auth/AuthProviderPair.java | 10 ++++++++++ .../pro/gravit/launchserver/auth/mix/MixProvider.java | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java index ba47063a..9a8ad920 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java @@ -73,6 +73,11 @@ public final void init(LaunchServer srv, String name) { this.name = name; if (links != null) link(srv); core.init(srv); + if(mixes != null) { + for(var m : mixes.values()) { + m.init(srv, core); + } + } features = new HashSet<>(); getFeatures(core.getClass(), features); } @@ -96,5 +101,10 @@ public final void close() throws IOException { if (textureProvider != null) { textureProvider.close(); } + if(mixes != null) { + for(var m : mixes.values()) { + m.close(); + } + } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/mix/MixProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/mix/MixProvider.java index cb74a8f4..b2ca8ad7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/mix/MixProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/mix/MixProvider.java @@ -2,9 +2,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.auth.core.AuthCoreProvider; import pro.gravit.utils.ProviderMap; -public class MixProvider { +public abstract class MixProvider implements AutoCloseable{ public static final ProviderMap providers = new ProviderMap<>("MixProvider"); private static final Logger logger = LogManager.getLogger(); private static boolean registredProviders = false; @@ -15,9 +17,14 @@ public static void registerProviders() { } } + public abstract void init(LaunchServer server, AuthCoreProvider core); + @SuppressWarnings("unchecked") public T isSupport(Class clazz) { if (clazz.isAssignableFrom(getClass())) return (T) this; return null; } + + @Override + public abstract void close(); }