forked from MagicBane/Server
Parsing conditions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package engine.ConfigParsing.EffectEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class EffectEntry {
|
||||
@@ -9,5 +10,5 @@ public class EffectEntry {
|
||||
public int icon;
|
||||
public HashSet<String> sources = new HashSet<>();
|
||||
public ArrayList<EffectModifier> mods = new ArrayList<>();
|
||||
public HashSet<String> conditions = new HashSet<>();
|
||||
public HashMap<String, Float> conditions = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class EffectsParser {
|
||||
public static HashMap<String, EffectEntry> effect_data = new HashMap<>();
|
||||
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 CONDITIONS_REGEX = Pattern.compile("(?<=CONDITIONBEGIN)(.+?)(?=CONDITIONEND)", Pattern.DOTALL);
|
||||
private static final Pattern MODS_REGEX = Pattern.compile("(?<=MODSBEGIN)(.+?)(?=MODSEND)", Pattern.DOTALL);
|
||||
private static final Pattern STRSPLIT_REGEX = Pattern.compile("([^\"]\\S*|\"[^\"]*\")\\s*");
|
||||
|
||||
@@ -107,6 +108,16 @@ public class EffectsParser {
|
||||
effectEntry.mods.add(effectModifier);
|
||||
}
|
||||
|
||||
// Parse Conditions
|
||||
|
||||
matcher = CONDITIONS_REGEX.matcher(effectData);
|
||||
|
||||
while (matcher.find()) {
|
||||
String[] condition = matcher.group().split(" ");
|
||||
effectEntry.conditions.put(condition[0].trim(), Float.parseFloat(condition[1]));
|
||||
}
|
||||
|
||||
|
||||
return effectEntry;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user