From 975845375fb4e9c99af396fccc8f3adc0e25168d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 10 Aug 2024 18:13:15 -0400 Subject: [PATCH] Effect Modifier parsing work. --- src/engine/ConfigParsing/EffectsParser.java | 29 ++++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/engine/ConfigParsing/EffectsParser.java b/src/engine/ConfigParsing/EffectsParser.java index e434d912..787e84cd 100644 --- a/src/engine/ConfigParsing/EffectsParser.java +++ b/src/engine/ConfigParsing/EffectsParser.java @@ -113,22 +113,31 @@ public class EffectsParser { private static EffectModifier parseModEntry(String modData) { EffectModifier effectModifier = new EffectModifier(); - ArrayList modValues = new ArrayList<>(); String[] modEntries = modData.trim().split("\n"); - effectModifier.type = mbEnums.ModType.valueOf(modEntries[0]); + for (String modEntry : modEntries) { - switch (effectModifier.type) { - case AnimOverride: - effectModifier.min = Integer.parseInt(modEntries[1]); - effectModifier.max = Integer.parseInt(modEntries[2]); - break; - default: - Logger.error("Unhandled type: " + effectModifier.type); - break; + ArrayList modValues = new ArrayList<>(); + Matcher matcher = STRSPLIT_REGEX.matcher(modEntry); + + while (matcher.find()) + modValues.add(matcher.group(1).trim()); + + effectModifier.type = mbEnums.ModType.valueOf(modValues.get(0).trim()); + + switch (effectModifier.type) { + case AnimOverride: + effectModifier.min = Integer.parseInt(modEntries[1]); + effectModifier.max = Integer.parseInt(modEntries[2]); + break; + default: + Logger.error("Unhandled type: " + effectModifier.type); + break; + } } + return effectModifier; }