128 lines
6.2 KiB
Java
128 lines
6.2 KiB
Java
package com.micle.loginprotection.setup;
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.micle.loginprotection.LoginProtection;
|
|
import net.minecraftforge.common.ForgeConfigSpec;
|
|
import net.minecraftforge.fml.ModLoadingContext;
|
|
import net.minecraftforge.fml.common.Mod;
|
|
import net.minecraftforge.fml.config.ModConfig;
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
import java.util.List;
|
|
|
|
@Mod.EventBusSubscriber(modid = LoginProtection.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
public final class Config {
|
|
public static final Server SERVER;
|
|
public static final ForgeConfigSpec SERVER_SPEC;
|
|
static {
|
|
Pair<Server, ForgeConfigSpec> spec_pair = new ForgeConfigSpec.Builder().configure(Server::new);
|
|
SERVER = spec_pair.getLeft();
|
|
SERVER_SPEC = spec_pair.getRight();
|
|
}
|
|
|
|
public static void init() {
|
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_SPEC);
|
|
}
|
|
|
|
public static class Server {
|
|
public enum KEYS {
|
|
PAUSE,
|
|
DEBUG,
|
|
FULLSCREEN,
|
|
PERSPECTIVE,
|
|
SMOOTH_CAMERA,
|
|
SCREENSHOT,
|
|
SPECTATOR_OUTLINES,
|
|
ADVANCEMENTS,
|
|
PLAYER_LIST,
|
|
CHAT,
|
|
SOCIAL_INTERACTIONS,
|
|
LOAD_HOTBAR_ACTIVATOR,
|
|
SAVE_HOTBAR_ACTIVATOR,
|
|
SWAP_ITEM,
|
|
INVENTORY,
|
|
HOTBAR,
|
|
DROP_ITEM,
|
|
USE_ITEM,
|
|
PICK_BLOCK,
|
|
ATTACK,
|
|
MOVE,
|
|
SNEAK,
|
|
JUMP
|
|
}
|
|
|
|
public static ForgeConfigSpec.BooleanValue POST_GRACE_ENABLED;
|
|
public static ForgeConfigSpec.BooleanValue POST_GRACE_IGNORE_PLAYER_ENABLED;
|
|
public static ForgeConfigSpec.IntValue POST_GRACE_DURATION;
|
|
public static ForgeConfigSpec.BooleanValue POST_DROWN_ENABLED;
|
|
public static ForgeConfigSpec.BooleanValue POST_WATER_ENABLED;
|
|
public static ForgeConfigSpec.IntValue POST_WATER_DURATION;
|
|
public static ForgeConfigSpec.BooleanValue POST_LAVA_ENABLED;
|
|
public static ForgeConfigSpec.IntValue POST_LAVA_DURATION;
|
|
public static ForgeConfigSpec.BooleanValue POST_FIRE_ENABLED;
|
|
public static ForgeConfigSpec.IntValue POST_FIRE_DURATION;
|
|
|
|
public static ForgeConfigSpec.BooleanValue MAIN_IGNORE_PLAYER_ENABLED;
|
|
public static ForgeConfigSpec.ConfigValue<List<? extends String>> MAIN_KEY_ALLOW_LIST;
|
|
|
|
Server(ForgeConfigSpec.Builder builder) {
|
|
builder.comment("Main protection settings for protecting inactive (loading) players.").push("main");
|
|
MAIN_IGNORE_PLAYER_ENABLED = builder
|
|
.comment("Whether mobs will ignore a protected player. (They will not attack/aggro)")
|
|
.define("ignorePlayerEnabled", true);
|
|
builder.push("allow_keys");
|
|
MAIN_KEY_ALLOW_LIST = builder
|
|
.comment("Allowed keys players can press without becoming active.\n" +
|
|
"Available values: PAUSE, DEBUG, FULLSCREEN, PERSPECTIVE, SMOOTH_CAMERA, SCREENSHOT, SPECTATOR_OUTLINES,\n" +
|
|
"ADVANCEMENTS, PLAYER_LIST, CHAT, SOCIAL_INTERACTIONS, LOAD_HOTBAR_ACTIVATOR, SAVE_HOTBAR_ACTIVATOR,\n" +
|
|
"SWAP_ITEM, INVENTORY, HOTBAR, DROP_ITEM, USE_ITEM, PICK_BLOCK, ATTACK, MOVE, SNEAK, JUMP")
|
|
.defineList("allowedKeys", Lists.newArrayList(KEYS.PAUSE.toString(), KEYS.DEBUG.toString(), KEYS.FULLSCREEN.toString(), KEYS.PERSPECTIVE.toString(), KEYS.SMOOTH_CAMERA.toString(),
|
|
KEYS.SCREENSHOT.toString(), KEYS.SPECTATOR_OUTLINES.toString(), KEYS.ADVANCEMENTS.toString(), KEYS.PLAYER_LIST.toString(), KEYS.CHAT.toString(), KEYS.SOCIAL_INTERACTIONS.toString(),
|
|
KEYS.LOAD_HOTBAR_ACTIVATOR.toString(), KEYS.SAVE_HOTBAR_ACTIVATOR.toString(), KEYS.SWAP_ITEM.toString(), KEYS.HOTBAR.toString(), KEYS.PICK_BLOCK.toString()), o -> o instanceof String);
|
|
builder.pop();
|
|
builder.pop();
|
|
|
|
builder.comment("Additional protection settings that apply as soon as a player becomes active.").push("post");
|
|
builder.push("grace_period");
|
|
POST_GRACE_ENABLED = builder
|
|
.comment("Whether a player receives a grace period after becoming active or not.")
|
|
.define("graceEnabled", false);
|
|
POST_GRACE_DURATION = builder
|
|
.comment("Grace period duration in seconds.")
|
|
.defineInRange("graceDuration", 10, 1, Integer.MAX_VALUE/40);
|
|
POST_GRACE_IGNORE_PLAYER_ENABLED = builder
|
|
.comment("Whether mobs will ignore a player during their grace period.")
|
|
.define("graceIgnorePlayerEnabled", false);
|
|
builder.pop();
|
|
builder.push("water_protection");
|
|
POST_DROWN_ENABLED = builder
|
|
.comment("Whether a player's air supply gets refilled.")
|
|
.define("drownEnabled", true);
|
|
POST_WATER_ENABLED = builder
|
|
.comment("Whether a player receives water breating when in water.")
|
|
.define("waterEnabled", false);
|
|
POST_WATER_DURATION = builder
|
|
.comment("Water breathing duration in seconds.")
|
|
.defineInRange("waterDuration", 10, 1, Integer.MAX_VALUE/20);
|
|
builder.pop();
|
|
builder.push("lava_protection");
|
|
POST_LAVA_ENABLED = builder
|
|
.comment("Whether a player receives fire resistance when in lava.")
|
|
.define("lavaEnabled", true);
|
|
POST_LAVA_DURATION = builder
|
|
.comment("Fire resistance duration in seconds.")
|
|
.defineInRange("lavaDuration", 10, 1, Integer.MAX_VALUE/20);
|
|
builder.pop();
|
|
builder.push("fire_protection");
|
|
POST_FIRE_ENABLED = builder
|
|
.comment("Whether a player receives fire resistance when on fire.")
|
|
.define("fireEnabled", false);
|
|
POST_FIRE_DURATION = builder
|
|
.comment("Fire resistance duration in seconds.")
|
|
.defineInRange("fireDuration", 10, 1, Integer.MAX_VALUE/20);
|
|
builder.pop();
|
|
builder.pop();
|
|
}
|
|
}
|
|
}
|