From 020eac52b4af33214ce7b0dbe098dc8997ca0f2d Mon Sep 17 00:00:00 2001 From: Micle Date: Sat, 21 May 2022 17:07:43 +0100 Subject: [PATCH] Added new config options for afk protection. Renamed 'main' protection options to 'login'. --- .../micle/loginprotection/setup/Config.java | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/main/java/dev/micle/loginprotection/setup/Config.java b/src/main/java/dev/micle/loginprotection/setup/Config.java index 203074d..194aaa7 100644 --- a/src/main/java/dev/micle/loginprotection/setup/Config.java +++ b/src/main/java/dev/micle/loginprotection/setup/Config.java @@ -62,16 +62,22 @@ public final class Config { 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> MAIN_KEY_ALLOW_LIST; + public static ForgeConfigSpec.BooleanValue LOGIN_IGNORE_PLAYER_ENABLED; + public static ForgeConfigSpec.ConfigValue> 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> AFK_KEY_ALLOW_LIST; Server(ForgeConfigSpec.Builder builder) { - builder.comment("Main protection settings for protecting inactive (loading) players.").push("main"); - MAIN_IGNORE_PLAYER_ENABLED = builder + builder.comment("Settings for protecting players while they are joining.").push("login"); + LOGIN_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 + .define("mobsIgnorePlayerEnabled", true); + builder.push("allowed_keys"); + LOGIN_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" + @@ -82,6 +88,29 @@ public final class Config { 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.push("grace_period"); POST_GRACE_ENABLED = builder