2024-06-11 19:51:28 +02:00
|
|
|
package com.hypherionmc.craterlib;
|
|
|
|
|
2025-01-14 17:14:57 +02:00
|
|
|
import com.hypherionmc.craterlib.client.gui.config.ClothConfigScreenBuilder;
|
2024-06-11 19:51:28 +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-11 19:51:28 +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-11 19:51:28 +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;
|
2025-01-15 08:21:17 +02:00
|
|
|
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
|
2024-06-11 19:51:28 +02:00
|
|
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
|
|
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
2025-01-15 08:21:17 +02:00
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
|
|
|
import net.kyori.adventure.text.format.Style;
|
|
|
|
import net.kyori.adventure.text.format.TextDecoration;
|
2024-06-11 19:51:28 +02:00
|
|
|
|
|
|
|
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 {
|
2025-01-15 08:21:17 +02:00
|
|
|
configScreens.put(config.getModId(), screen -> BridgedMinecraft.getInstance().buildWarningScreen(
|
|
|
|
Component.text("Notice").style(Style.style(NamedTextColor.YELLOW).decorate(TextDecoration.BOLD)),
|
|
|
|
Component.text("This mod does not have a config screen, or Cloth Config is not installed"),
|
|
|
|
screen
|
|
|
|
));
|
2024-06-11 19:51:28 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return configScreens;
|
|
|
|
}
|
|
|
|
}
|