// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2024 // www.magicbane.com package engine.ConfigParsing; import engine.ConfigParsing.EffectEntry.EffectEntry; import engine.gameManager.ConfigManager; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; public class EffectsParser { public static String EffectsPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Effects.cfg"; public static HashMap effect_data = new HashMap<>(); private static final Pattern EFFECT_REGEX = Pattern.compile("(.+?)", Pattern.DOTALL); private static final Pattern SOURCE_REGEX = Pattern.compile("(.+?)", Pattern.DOTALL); private static final Pattern MODS_REGEX = Pattern.compile("(.+?)", Pattern.DOTALL); public static void init() throws IOException { byte[] fileData = Files.readAllBytes(Paths.get(EffectsPath)); String fileContents = new String(fileData); Matcher matcher = EFFECT_REGEX.matcher(fileContents); // Iterate effect entries from .wpak config data while (matcher.find()) { EffectEntry effectEntry = parseEffectEntry(matcher.group(1)); if (effectEntry != null) effect_data.put(effectEntry.id, effectEntry); } } private static EffectEntry parseEffectEntry(String effectData) { EffectEntry effectEntry = new EffectEntry(); // Remove all lines that contain a # effectData.replaceAll("(?m)^.*#.*$", ""); return effectEntry; } }