fix classloading for mod menu by moving registration methods to OmegaConfigGui class, fix versioning
This commit is contained in:
@@ -2,21 +2,47 @@ package draylar.omegaconfiggui;
|
||||
|
||||
import draylar.omegaconfig.OmegaConfig;
|
||||
import draylar.omegaconfig.api.Config;
|
||||
import draylar.omegaconfiggui.api.screen.OmegaModMenu;
|
||||
import draylar.omegaconfiggui.api.screen.OmegaScreenFactory;
|
||||
import me.shedaniel.clothconfiglite.api.ConfigScreen;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.LiteralText;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class OmegaConfigGui {
|
||||
|
||||
private static final Map<Config, OmegaScreenFactory<Screen>> REGISTERED_CONFIGURATIONS = new HashMap<>();
|
||||
public static boolean modMenuInitialized = false;
|
||||
|
||||
/**
|
||||
* Registers a ModMenu configuration screen for the given {@link Config} instance.
|
||||
*
|
||||
* @param config registered config to create a ModMenu screen for
|
||||
* @param <T> config type
|
||||
*/
|
||||
public static <T extends Config> void registerConfigScreen(T config) {
|
||||
if(FabricLoader.getInstance().isModLoaded("modmenu")) {
|
||||
OmegaScreenFactory<Screen> factory = OmegaConfigGui.getConfigScreenFactory(config);
|
||||
|
||||
if(modMenuInitialized) {
|
||||
OmegaModMenu.injectScreen(config, factory);
|
||||
} else {
|
||||
REGISTERED_CONFIGURATIONS.put(config, factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a factory which provides new Cloth Config Lite {@link Screen} instances for the given {@link Config}.
|
||||
*
|
||||
* @param config Omega Config instance to create the screen factory for
|
||||
* @return a factory which provides new Cloth Config Lite {@link Screen} instances for the given {@link Config}.
|
||||
*/
|
||||
@@ -60,4 +86,8 @@ public class OmegaConfigGui {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
public static Map<Config, OmegaScreenFactory<Screen>> getConfigScreenFactories() {
|
||||
return REGISTERED_CONFIGURATIONS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user