From e4a1a08cf5fa897c0f4ce8216db8ee4b2e6e9566 Mon Sep 17 00:00:00 2001 From: Micle Date: Sat, 24 May 2025 23:51:25 +0100 Subject: [PATCH] Added config options for operations. --- .../java/dev/micle/xptools/config/Config.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/dev/micle/xptools/config/Config.java b/src/main/java/dev/micle/xptools/config/Config.java index 687ee33..1320aa4 100644 --- a/src/main/java/dev/micle/xptools/config/Config.java +++ b/src/main/java/dev/micle/xptools/config/Config.java @@ -76,6 +76,11 @@ public final class Config { private static ForgeConfigSpec.ConfigValue> blockBreakOperationsRaw; public static List blockBreakOperationItems; + private static ForgeConfigSpec.ConfigValue> entityKillGlobalOperationsRaw; + public static List entityKillGlobalOperationItems; + private static ForgeConfigSpec.ConfigValue> entityKillOperationsRaw; + public static List entityKillOperationItems; + Server(ForgeConfigSpec.Builder builder) { builder.comment("Settings for debugging").push("debug"); debugExtra = builder @@ -105,6 +110,21 @@ public final class Config { .comment("'#forge:ores,multiply,1,2,1,false' - Multiplies xp drop of all blocks tagged forge:ores by 1-2, allows additional operations.") .define("blockBreakOperations", new ArrayList<>()); builder.pop(); + + builder.comment("Settings for entity killing").push("entity_killing"); + builder.comment("Available operations: " + Arrays.toString(OperationType.values())); + entityKillGlobalOperationsRaw = builder + .comment("List of global operations. Format: '[operation],[min],[max],[priority]'") + .comment("Global operations are run before any unique operations.") + .comment("Examples:") + .comment("'set,0,0,0' - Sets the xp of all blocks to 0.") + .define("entityKillGlobalOperations", new ArrayList<>()); + entityKillOperationsRaw = builder + .comment("List of unique operations. Format: '[entity_id],[operation],[min],[max],[priority],[is_last]'") + .comment("Examples:") + .comment("'minecraft:creeper,set,2,2,0,true' - Sets the xp drop for killing creepers to 2, takes highest priority and stops any additional operations.") + .define("entityKillOperations", new ArrayList<>()); + builder.pop(); } private static void onConfigReload() { @@ -123,6 +143,19 @@ public final class Config { for (String s : blockBreakOperationsRaw.get()) { blockBreakOperationItems.add(OperationItem.fromConfig(s)); } + + // Parse all entity kill global operations + entityKillGlobalOperationItems = new ArrayList<>(); + for (String s : entityKillGlobalOperationsRaw.get()) { + entityKillGlobalOperationItems.add(GlobalOperationItem.fromConfig(s)); + } + entityKillGlobalOperationItems.sort(Comparator.comparingInt(OperationItem::getPriority)); + + // Parse all entity kill unique operations + entityKillOperationItems = new ArrayList<>(); + for (String s : entityKillOperationsRaw.get()) { + entityKillOperationItems.add(OperationItem.fromConfig(s)); + } } } }