2024-06-13 19:07:34 +02:00
|
|
|
package com.hypherionmc.craterlib;
|
|
|
|
|
2025-01-14 17:14:57 +02:00
|
|
|
import com.hypherionmc.craterlib.client.gui.config.ClothConfigScreenBuilder;
|
2024-06-13 19:07:34 +02:00
|
|
|
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
2025-01-14 17:14:57 +02:00
|
|
|
import com.hypherionmc.craterlib.core.config.AbstractConfig;
|
2024-06-13 19:07:34 +02:00
|
|
|
import com.hypherionmc.craterlib.core.config.ConfigController;
|
2025-01-14 17:14:57 +02:00
|
|
|
import com.hypherionmc.craterlib.core.config.annotations.ClothScreen;
|
2024-06-13 19:07:34 +02:00
|
|
|
import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
2025-01-14 17:14:57 +02:00
|
|
|
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
2024-06-13 19:07:34 +02:00
|
|
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
|
|
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author HypherionSA
|
|
|
|
*/
|
|
|
|
public class CraterLibModMenuIntegration implements ModMenuApi {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
|
|
|
|
Map<String, ConfigScreenFactory<?>> configScreens = new HashMap<>();
|
|
|
|
|
2024-08-10 15:17:10 +02:00
|
|
|
ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
|
2025-01-14 17:14:57 +02:00
|
|
|
AbstractConfig config = watcher.getLeft();
|
|
|
|
if (config.getClass().isAnnotationPresent(NoConfigScreen.class))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (watcher.getLeft().getClass().isAnnotationPresent(ClothScreen.class) && (ModloaderEnvironment.INSTANCE.isModLoaded("cloth_config") || ModloaderEnvironment.INSTANCE.isModLoaded("cloth-config") || ModloaderEnvironment.INSTANCE.isModLoaded("clothconfig"))) {
|
|
|
|
configScreens.put(config.getModId(), screen -> ClothConfigScreenBuilder.buildConfigScreen(config, screen));
|
|
|
|
} else {
|
|
|
|
//configScreens.put(config.getModId(), screen -> new CraterConfigScreen(config, screen));
|
2024-06-13 19:07:34 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return configScreens;
|
|
|
|
}
|
|
|
|
}
|