Implemented configurable keybinding options that will allow players perform certain actions while protected without becoming active.

This commit is contained in:
2021-09-30 17:47:14 +01:00
parent 51b528a0f4
commit 50a4a57a63
2 changed files with 134 additions and 2 deletions

View File

@ -1,10 +1,39 @@
package com.micle.loginprotection.setup;
import com.google.common.collect.Lists;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig;
import java.util.List;
public class Config {
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 SERVER_CONFIG;
public static ForgeConfigSpec.BooleanValue POST_GRACE_ENABLED;
@ -19,6 +48,7 @@ public class Config {
public static ForgeConfigSpec.IntValue POST_FIRE_DURATION;
public static ForgeConfigSpec.BooleanValue MAIN_IGNORE_PLAYER_ENABLED;
public static ForgeConfigSpec.ConfigValue<List<? extends KEYS>> MAIN_KEY_ALLOW_LIST;
public static void init() {
initServer();
@ -33,6 +63,16 @@ public class Config {
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, KEYS.DEBUG, KEYS.FULLSCREEN, KEYS.PERSPECTIVE, KEYS.SMOOTH_CAMERA,
KEYS.SCREENSHOT, KEYS.SPECTATOR_OUTLINES, KEYS.ADVANCEMENTS, KEYS.PLAYER_LIST, KEYS.CHAT, KEYS.SOCIAL_INTERACTIONS,
KEYS.LOAD_HOTBAR_ACTIVATOR, KEYS.SAVE_HOTBAR_ACTIVATOR, KEYS.SWAP_ITEM, KEYS.HOTBAR, KEYS.PICK_BLOCK), o -> o instanceof KEYS);
builder.pop();
builder.pop();
builder.comment("Additional protection settings that apply as soon as a player becomes active.").push("post");