diff --git a/src/main/java/com/ataku/stopcheat/Config.java b/src/main/java/com/ataku/stopcheat/Config.java index 7c3d238..9f75dab 100644 --- a/src/main/java/com/ataku/stopcheat/Config.java +++ b/src/main/java/com/ataku/stopcheat/Config.java @@ -1,6 +1,12 @@ package com.ataku.stopcheat; import java.util.List; + +import net.neoforged.api.distmarker.Dist; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.loading.FMLEnvironment; +import net.neoforged.neoforge.client.gui.ConfigurationScreen; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; import net.neoforged.neoforge.common.ModConfigSpec; // An example config class. This is not required, but it's a good idea to have one to keep your config organized. @@ -27,4 +33,11 @@ public class Config { static final ModConfigSpec SPEC = BUILDER.build(); + + public static void configGUI(ModContainer container) { + container.registerExtensionPoint( + IConfigScreenFactory.class, + ConfigurationScreen::new + ); + } } diff --git a/src/main/java/com/ataku/stopcheat/stopcheat.java b/src/main/java/com/ataku/stopcheat/stopcheat.java index 9a75408..d9d3a00 100644 --- a/src/main/java/com/ataku/stopcheat/stopcheat.java +++ b/src/main/java/com/ataku/stopcheat/stopcheat.java @@ -1,6 +1,8 @@ package com.ataku.stopcheat; +import net.neoforged.api.distmarker.Dist; import net.neoforged.fml.event.config.ModConfigEvent; +import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.neoforge.event.entity.player.PlayerEvent; import org.slf4j.Logger; @@ -35,6 +37,10 @@ public class stopcheat { NeoForge.EVENT_BUS.addListener(this::loadl10nandconfig); // 注册配置文件 modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC); + + // 游戏内配置界面 + if (FMLEnvironment.dist == Dist.DEDICATED_SERVER){return;} //专用服务端不注册 + else {Config.configGUI(modContainer);} } private void commonSetup(FMLCommonSetupEvent event) { diff --git a/src/main/resources/assets/stopcheat/lang/en_us.json b/src/main/resources/assets/stopcheat/lang/en_us.json index d4f0d15..e26660a 100644 --- a/src/main/resources/assets/stopcheat/lang/en_us.json +++ b/src/main/resources/assets/stopcheat/lang/en_us.json @@ -3,5 +3,9 @@ "aza.stopcheat.warn.config.stopindex": "{} configuration unavailable, args_STOPINDEX error, reset to 0", "aza.stopcheat.log.intercept": "{} used {} command and was intercepted", "aza.stopcheat.broadcast.reload": "Configuration reloaded", - "aza.stopcheat.broadcast.cheat": "§cNo cheating allowed (>v0" + "aza.stopcheat.broadcast.cheat": "§cNo cheating allowed (>v0", + + "stopcheat.configuration.version": "Config Version", + "stopcheat.configuration.blacked_commands": "Blacklisted Commands", + "stopcheat.configuration.pass_users": "Bypass Users" } \ No newline at end of file diff --git a/src/main/resources/assets/stopcheat/lang/zh_cn.json b/src/main/resources/assets/stopcheat/lang/zh_cn.json index 1a56874..574929c 100644 --- a/src/main/resources/assets/stopcheat/lang/zh_cn.json +++ b/src/main/resources/assets/stopcheat/lang/zh_cn.json @@ -3,5 +3,9 @@ "aza.stopcheat.warn.config.stopindex": "{} 配置不可用, args_STOPINDEX错误,重置为0", "aza.stopcheat.log.intercept": "{} 使用 {} 命令被拦截", "aza.stopcheat.broadcast.reload": "配置重载完成", - "aza.stopcheat.broadcast.cheat": "§c不准作弊哦(>v0" + "aza.stopcheat.broadcast.cheat": "§c不准作弊哦(>v0", + + "stopcheat.configuration.version": "配置文件版本", + "stopcheat.configuration.blacked_commands": "禁用指令列表", + "stopcheat.configuration.pass_users": "白名单玩家" } \ No newline at end of file