mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] MixProvider init
This commit is contained in:
parent
d4cc28f96a
commit
0fb6102c29
2 changed files with 18 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<MixProvider> 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> T isSupport(Class<T> clazz) {
|
||||
if (clazz.isAssignableFrom(getClass())) return (T) this;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void close();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue