Added new config options for afk protection. Renamed 'main' protection options to 'login'.

This commit is contained in:
2022-05-21 17:07:43 +01:00
parent 5a0820dd14
commit 4ed3487362

View File

@ -62,16 +62,22 @@ public final class Config {
public static ForgeConfigSpec.BooleanValue POST_FIRE_ENABLED; public static ForgeConfigSpec.BooleanValue POST_FIRE_ENABLED;
public static ForgeConfigSpec.IntValue POST_FIRE_DURATION; public static ForgeConfigSpec.IntValue POST_FIRE_DURATION;
public static ForgeConfigSpec.BooleanValue MAIN_IGNORE_PLAYER_ENABLED; public static ForgeConfigSpec.BooleanValue LOGIN_IGNORE_PLAYER_ENABLED;
public static ForgeConfigSpec.ConfigValue<List<? extends String>> MAIN_KEY_ALLOW_LIST; public static ForgeConfigSpec.ConfigValue<List<? extends String>> LOGIN_KEY_ALLOW_LIST;
public static ForgeConfigSpec.BooleanValue AFK_PROTECTION_ENABLED;
public static ForgeConfigSpec.IntValue AFK_TIME_THRESHOLD;
public static ForgeConfigSpec.BooleanValue AFK_APPLY_POST_EFFECTS;
public static ForgeConfigSpec.BooleanValue AFK_IGNORE_PLAYER_ENABLED;
public static ForgeConfigSpec.ConfigValue<List<? extends String>> AFK_KEY_ALLOW_LIST;
Server(ForgeConfigSpec.Builder builder) { Server(ForgeConfigSpec.Builder builder) {
builder.comment("Main protection settings for protecting inactive (loading) players.").push("main"); builder.comment("Settings for protecting players while they are joining.").push("login");
MAIN_IGNORE_PLAYER_ENABLED = builder LOGIN_IGNORE_PLAYER_ENABLED = builder
.comment("Whether mobs will ignore a protected player. (They will not attack/aggro)") .comment("Whether mobs will ignore a protected player. (They will not attack/aggro)")
.define("ignorePlayerEnabled", true); .define("mobsIgnorePlayerEnabled", true);
builder.push("allow_keys"); builder.push("allowed_keys");
MAIN_KEY_ALLOW_LIST = builder LOGIN_KEY_ALLOW_LIST = builder
.comment("Allowed keys players can press without becoming active.\n" + .comment("Allowed keys players can press without becoming active.\n" +
"Available values: PAUSE, DEBUG, FULLSCREEN, PERSPECTIVE, SMOOTH_CAMERA, SCREENSHOT, SPECTATOR_OUTLINES,\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" + "ADVANCEMENTS, PLAYER_LIST, CHAT, SOCIAL_INTERACTIONS, LOAD_HOTBAR_ACTIVATOR, SAVE_HOTBAR_ACTIVATOR,\n" +
@ -82,6 +88,29 @@ public final class Config {
builder.pop(); builder.pop();
builder.pop(); builder.pop();
builder.comment("Settings for protecting players that are afk.").push("afk");
AFK_PROTECTION_ENABLED = builder
.comment("Enable protection of afk players?")
.define("enabled", true);
AFK_TIME_THRESHOLD = builder
.comment("How long a player needs to be afk to become protected. (seconds)")
.defineInRange("timeThreshold", 600, 1, Integer.MAX_VALUE/40);
AFK_APPLY_POST_EFFECTS = builder
.comment("Whether to apply any post protection effects to afk players.")
.define("applyPostProtectionEffects", false);
AFK_IGNORE_PLAYER_ENABLED = builder
.comment("Whether mobs will ignore a protected player. (They will not attack/aggro")
.define("mobsIgnorePlayerEnabled", true);
builder.push("allowed_keys");
AFK_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.FULLSCREEN.toString(), KEYS.SCREENSHOT.toString(), KEYS.ADVANCEMENTS.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.comment("Additional protection settings that apply as soon as a player becomes active.").push("post");
builder.push("grace_period"); builder.push("grace_period");
POST_GRACE_ENABLED = builder POST_GRACE_ENABLED = builder