[FEATURE] MixProvider init

This commit is contained in:
Gravita 2023-09-06 20:17:45 +07:00
parent d4cc28f96a
commit 0fb6102c29
2 changed files with 18 additions and 1 deletions

View file

@ -73,6 +73,11 @@ public final void init(LaunchServer srv, String name) {
this.name = name; this.name = name;
if (links != null) link(srv); if (links != null) link(srv);
core.init(srv); core.init(srv);
if(mixes != null) {
for(var m : mixes.values()) {
m.init(srv, core);
}
}
features = new HashSet<>(); features = new HashSet<>();
getFeatures(core.getClass(), features); getFeatures(core.getClass(), features);
} }
@ -96,5 +101,10 @@ public final void close() throws IOException {
if (textureProvider != null) { if (textureProvider != null) {
textureProvider.close(); textureProvider.close();
} }
if(mixes != null) {
for(var m : mixes.values()) {
m.close();
}
}
} }
} }

View file

@ -2,9 +2,11 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.core.AuthCoreProvider;
import pro.gravit.utils.ProviderMap; import pro.gravit.utils.ProviderMap;
public class MixProvider { public abstract class MixProvider implements AutoCloseable{
public static final ProviderMap<MixProvider> providers = new ProviderMap<>("MixProvider"); public static final ProviderMap<MixProvider> providers = new ProviderMap<>("MixProvider");
private static final Logger logger = LogManager.getLogger(); private static final Logger logger = LogManager.getLogger();
private static boolean registredProviders = false; private static boolean registredProviders = false;
@ -15,9 +17,14 @@ public static void registerProviders() {
} }
} }
public abstract void init(LaunchServer server, AuthCoreProvider core);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T isSupport(Class<T> clazz) { public <T> T isSupport(Class<T> clazz) {
if (clazz.isAssignableFrom(getClass())) return (T) this; if (clazz.isAssignableFrom(getClass())) return (T) this;
return null; return null;
} }
@Override
public abstract void close();
} }