Refactor all arrays to arraylist usage.

This commit is contained in:
2024-08-21 13:06:35 -04:00
parent 4bcf00fd6f
commit d0f1a73a9f
3 changed files with 90 additions and 86 deletions
+32 -32
View File
@@ -22,6 +22,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -66,14 +67,13 @@ public class PowerActionParser {
powerActionData = powerActionData.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "").trim();
String[] lineData = powerActionData.split("\n");
List<String> lineData = Arrays.asList(powerActionData.split("\n"));
// Parse effect entry header
Iterator<String> entryIterator = Arrays.stream(lineData).iterator();
Iterator<String> entryIterator = lineData.iterator();
String headerLine = entryIterator.next();
ArrayList<String> headerData = new ArrayList<>();
List<String> headerData = new ArrayList<>();
Matcher matcher = STRSPLIT_REGEX.matcher(headerLine.trim());
@@ -206,90 +206,90 @@ public class PowerActionParser {
while (entryIterator.hasNext()) {
String lineValue = entryIterator.next();
String[] lineValues = lineValue.split("=");
String key = lineValues[0].trim();
String[] arguments;
List<String> lineValues = Arrays.asList(lineValue.split("="));
String key = lineValues.get(0).trim();
List<String> arguments;
switch (key) {
case "BODYPARTS":
arguments = lineValues[1].trim().split("\\s+");
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments)
powerActionEntry.bodyparts.add(Integer.parseInt(bodyPart));
break;
case "FEMALEBODYPARTS":
arguments = lineValues[1].trim().split("\\s+");
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String bodyPart : arguments)
powerActionEntry.femaleBodyParts.add(Integer.parseInt(bodyPart));
break;
case "SCALEFACTOR":
arguments = lineValues[1].trim().split("\\s+");
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String scaleFactor : arguments)
powerActionEntry.scaleFactor.add(Float.parseFloat(scaleFactor));
break;
case "ISRESISTABLE":
powerActionEntry.isResistible = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.isResistible = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "ISAGGRESSIVE":
powerActionEntry.isAggressive = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.isAggressive = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "BLADETRAILS":
powerActionEntry.bladeTrails = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.bladeTrails = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "SHOULDSHOWWEAPONS":
powerActionEntry.shouldShowWeapons = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.shouldShowWeapons = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "SHOULDSHOWARMOR":
powerActionEntry.shouldShowArmor = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.shouldShowArmor = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "APPLYEFFECTBLANK":
powerActionEntry.applyEffectBlank = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.applyEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "WEAROFFEFFECTBLANK":
powerActionEntry.wearOffEffectBlank = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.wearOffEffectBlank = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "ATTACKANIMS":
arguments = lineValues[1].trim().split("\\s+");
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
for (String animation : arguments)
powerActionEntry.attackAnimations.add(Integer.parseInt(animation));
break;
case "REMOVEALL":
powerActionEntry.removeAll = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.removeAll = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "EFFECTID":
effectDescription = new EffectDescription();
effectDescription.effect_id = lineValues[1].trim();
effectDescription.effect_id = lineValues.get(1).trim();
powerActionEntry.effects.add(effectDescription);
break;
case "LEVELCAP":
arguments = lineValues[1].trim().split("\\s+");
powerActionEntry.levelCap = Integer.parseInt(arguments[0]);
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerActionEntry.levelCap = Integer.parseInt(arguments.get(0));
if (arguments.length > 1) // Not all level caps have a curve
powerActionEntry.levelCurve = mbEnums.CompoundCurveType.valueOf(arguments[1]);
if (arguments.size() > 1) // Not all level caps have a curve
powerActionEntry.levelCurve = mbEnums.CompoundCurveType.valueOf(arguments.get(1));
break;
case "CLEARAGGRO":
powerActionEntry.clearAggro = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.clearAggro = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "TARGETBECOMESPET":
powerActionEntry.targetBecomesPet = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.targetBecomesPet = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "DESTROYOLDPET":
powerActionEntry.destroyOldPet = Boolean.parseBoolean(lineValues[1].trim());
powerActionEntry.destroyOldPet = Boolean.parseBoolean(lineValues.get(1).trim());
break;
case "DAMAGETYPE":
powerActionEntry.damageType = mbEnums.DamageType.valueOf(lineValues[1].trim().toUpperCase());
powerActionEntry.damageType = mbEnums.DamageType.valueOf(lineValues.get(1).trim().toUpperCase());
break;
case "ROOTFSMID":
powerActionEntry.rootFsmID = mbEnums.MobBehaviourType.valueOf(lineValues[1].trim());
powerActionEntry.rootFsmID = mbEnums.MobBehaviourType.valueOf(lineValues.get(1).trim());
break;
case "SPLASHDAMAGE":
arguments = lineValues[1].trim().split("\\s+");
powerActionEntry.splashDamageMin = Integer.parseInt(arguments[0]);
powerActionEntry.splashDamageMax = Integer.parseInt(arguments[1]);
arguments = Arrays.asList(lineValues.get(1).trim().split("\\s+"));
powerActionEntry.splashDamageMin = Integer.parseInt(arguments.get(0));
powerActionEntry.splashDamageMax = Integer.parseInt(arguments.get(1));
break;
case "APPLYEFFECTOTHER":
case "APPLYEFFECTSELF":