mirror of
https://github.com/xzb23/Minecraft-Command-Permission-Control.git
synced 2026-11-22 00:34:36 +08:00
47 lines
1.8 KiB
Java
47 lines
1.8 KiB
Java
package com.ataku.stopcheat;
|
|
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
|
|
import net.minecraft.core.registries.BuiltInRegistries;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.item.Item;
|
|
import net.neoforged.bus.api.SubscribeEvent;
|
|
import net.neoforged.fml.common.EventBusSubscriber;
|
|
import net.neoforged.fml.event.config.ModConfigEvent;
|
|
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.
|
|
// Demonstrates how to use Neo's config APIs
|
|
public class Config {
|
|
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
|
|
|
|
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>> BLOCKLIST = BUILDER
|
|
.comment("禁用的指令列表")
|
|
.comment("格式为{cmd/指令}:{checkIndex/禁用第几个参数}:{arg1[,arg2,...]/禁用的参数1[,禁用的参数2,...]}")
|
|
.comment("其中{checkIndex}填0代表禁用整个指令")
|
|
.defineList("blocked_commands", List.of("give:0:", "fill:0:", "gamemode:1:creative"), obj -> obj instanceof String);
|
|
|
|
|
|
|
|
|
|
public static final ModConfigSpec.ConfigValue<String> BROADCASTMSG = BUILDER
|
|
.comment("有人作弊时的广播内容")
|
|
.define("broadcastmsg", "§c不准作弊哦(>v0");
|
|
|
|
|
|
|
|
|
|
static final ModConfigSpec SPEC = BUILDER.build();
|
|
|
|
private static boolean validateItemName(final Object obj) {
|
|
return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(ResourceLocation.parse(itemName));
|
|
}
|
|
}
|