整理代码 and 使用配置文件保存配置

This commit is contained in:
xzb23 committed 2026-08-19 15:11:40 +08:00
1 parent feb96541ff
commit 445a2addcd
3 files changed
+32 -54

No files matched your search

+13 -13
View File
@@ -17,22 +17,22 @@ import net.neoforged.neoforge.common.ModConfigSpec;
public class Config {
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
public static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
.comment("Whether to log the dirt block on common setup")
.define("logDirtBlock", true);
public static final ModConfigSpec.IntValue VERSION = BUILDER
.comment("Config Version")
.defineInRange("version", 1, 0, Integer.MAX_VALUE);
public static final ModConfigSpec.ConfigValue<List<? extends String>> BLOCKED_COMMANDS = BUILDER
.comment("禁用的指令列表")
.defineList("blocked_commands", List.of("give", "fill"), obj -> obj instanceof String);
public static final ModConfigSpec.ConfigValue<String> BROADCASTMSG = BUILDER
.comment("有人作弊时的广播内容")
.define("broadcastmsg", "§c不准作弊哦(>v0");
public static final ModConfigSpec.IntValue MAGIC_NUMBER = BUILDER
.comment("A magic number")
.defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);
public static final ModConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
.comment("What you want the introduction message to be for the magic number")
.define("magicNumberIntroduction", "The magic number is... ");
// a list of strings that are treated as resource locations for items
public static final ModConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
.comment("A list of items to log on common setup.")
.defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), () -> "", Config::validateItemName);
static final ModConfigSpec SPEC = BUILDER.build();