|
|
@ -14,6 +14,7 @@ import engine.gameManager.ConfigManager; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.nio.file.Paths; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.regex.Pattern; |
|
|
@ -25,7 +26,7 @@ public class EffectsParser { |
|
|
|
private static final Pattern EFFECT_REGEX = Pattern.compile("(?<=EFFECTBEGIN)(.+?)(?=EFFECTEND)", Pattern.DOTALL); |
|
|
|
private static final Pattern EFFECT_REGEX = Pattern.compile("(?<=EFFECTBEGIN)(.+?)(?=EFFECTEND)", Pattern.DOTALL); |
|
|
|
private static final Pattern SOURCE_REGEX = Pattern.compile("(?<=SOURCEBEGIN)(.+?)(?=SOURCEEND)", Pattern.DOTALL); |
|
|
|
private static final Pattern SOURCE_REGEX = Pattern.compile("(?<=SOURCEBEGIN)(.+?)(?=SOURCEEND)", Pattern.DOTALL); |
|
|
|
private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEEND)", Pattern.DOTALL); |
|
|
|
private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEEND)", Pattern.DOTALL); |
|
|
|
|
|
|
|
private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\".+?\")\\s*"); |
|
|
|
public static void init() throws IOException { |
|
|
|
public static void init() throws IOException { |
|
|
|
|
|
|
|
|
|
|
|
byte[] fileData = Files.readAllBytes(Paths.get(EffectsPath)); |
|
|
|
byte[] fileData = Files.readAllBytes(Paths.get(EffectsPath)); |
|
|
@ -53,15 +54,20 @@ public class EffectsParser { |
|
|
|
// Parse effect entry description
|
|
|
|
// Parse effect entry description
|
|
|
|
|
|
|
|
|
|
|
|
String firstLine = effectData.substring(0, effectData.indexOf('\n')); |
|
|
|
String firstLine = effectData.substring(0, effectData.indexOf('\n')); |
|
|
|
String[] effectDescription = firstLine.split(" "); |
|
|
|
ArrayList<String> effectDescription = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Matcher matcher = STRSPLIT_REGEX.matcher(firstLine); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (matcher.find()) |
|
|
|
|
|
|
|
effectDescription.add(matcher.group(1)); |
|
|
|
|
|
|
|
|
|
|
|
effectEntry.id = effectDescription[0]; |
|
|
|
effectEntry.id = effectDescription.get(0); |
|
|
|
effectEntry.name = effectDescription[1]; |
|
|
|
effectEntry.name = effectDescription.get(1); |
|
|
|
effectEntry.icon = Integer.parseInt(effectDescription[2]); |
|
|
|
effectEntry.icon = Integer.parseInt(effectDescription.get(2)); |
|
|
|
|
|
|
|
|
|
|
|
// Parse source entries
|
|
|
|
// Parse source entries
|
|
|
|
|
|
|
|
|
|
|
|
Matcher matcher = SOURCE_REGEX.matcher(effectData); |
|
|
|
matcher = SOURCE_REGEX.matcher(effectData); |
|
|
|
|
|
|
|
|
|
|
|
while (matcher.find()) |
|
|
|
while (matcher.find()) |
|
|
|
effectEntry.sources.add(matcher.group().trim()); |
|
|
|
effectEntry.sources.add(matcher.group().trim()); |
|
|
|