String usage cleanup
This commit is contained in:
@@ -57,10 +57,10 @@ public class PowersParser {
|
|||||||
private static PowerEntry parsePowerEntry(String powerData) {
|
private static PowerEntry parsePowerEntry(String powerData) {
|
||||||
|
|
||||||
PowerEntry powerEntry = new PowerEntry();
|
PowerEntry powerEntry = new PowerEntry();
|
||||||
|
StringBuilder conditionBuilder = new StringBuilder();
|
||||||
|
StringBuilder powerBuilder = new StringBuilder();
|
||||||
StringBuilder conditionString = new StringBuilder();
|
String conditionString;
|
||||||
StringBuilder powerString = new StringBuilder();
|
String powerString;
|
||||||
|
|
||||||
int endPos = 0;
|
int endPos = 0;
|
||||||
|
|
||||||
@@ -69,23 +69,22 @@ public class PowersParser {
|
|||||||
Matcher matcher = CONDITION_REGEX.matcher(powerData);
|
Matcher matcher = CONDITION_REGEX.matcher(powerData);
|
||||||
|
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
conditionString.append(matcher.group().trim());
|
conditionBuilder.append(matcher.group().trim());
|
||||||
powerString.append(powerData, endPos, matcher.start());
|
powerBuilder.append(powerData, endPos, matcher.start());
|
||||||
endPos = matcher.end();
|
endPos = matcher.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
powerString.append(powerData.substring(endPos));
|
powerBuilder.append(powerData.substring(endPos));
|
||||||
|
|
||||||
// Cleanup dangling tags and lines that contain a # and leading/trailing blank lines
|
// Cleanup dangling tags and lines that contain a # and leading/trailing blank lines
|
||||||
|
|
||||||
powerString = new StringBuilder(powerString.toString().replaceAll("CONDITIONBEGINCONDITIONEND", ""));
|
powerString = powerBuilder.toString().replaceAll("CONDITIONBEGINCONDITIONEND", "")
|
||||||
powerString = new StringBuilder(powerString.toString().replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", ""));
|
.replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "");
|
||||||
|
conditionString = conditionBuilder.toString().replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", "");
|
||||||
conditionString = new StringBuilder(conditionString.toString().replaceAll("(?m)^(\\s*#.*|\\s*)\r?\n?", ""));
|
|
||||||
|
|
||||||
// Parse header line in power data
|
// Parse header line in power data
|
||||||
|
|
||||||
List<String> lineData = Arrays.asList(powerString.toString().trim().split("\n"));
|
List<String> lineData = Arrays.asList(powerString.trim().split("\n"));
|
||||||
List<String> powerHeader = new ArrayList<>();
|
List<String> powerHeader = new ArrayList<>();
|
||||||
|
|
||||||
String headerString = lineData.get(0);
|
String headerString = lineData.get(0);
|
||||||
@@ -152,7 +151,6 @@ public class PowersParser {
|
|||||||
ActionEntry actionEntry;
|
ActionEntry actionEntry;
|
||||||
List<String> arguments;
|
List<String> arguments;
|
||||||
Matcher matcher1;
|
Matcher matcher1;
|
||||||
ArrayList<String> args;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "ACTION":
|
case "ACTION":
|
||||||
@@ -200,14 +198,14 @@ public class PowersParser {
|
|||||||
case "EQPREREQ":
|
case "EQPREREQ":
|
||||||
EquipmentPreReq equipmentPreReq = new EquipmentPreReq();
|
EquipmentPreReq equipmentPreReq = new EquipmentPreReq();
|
||||||
matcher1 = STRSPLIT_REGEX.matcher(lineValues.get(1).trim());
|
matcher1 = STRSPLIT_REGEX.matcher(lineValues.get(1).trim());
|
||||||
args = new ArrayList<>();
|
arguments = new ArrayList<>();
|
||||||
|
|
||||||
while (matcher1.find())
|
while (matcher1.find())
|
||||||
args.add(matcher1.group().trim());
|
arguments.add(matcher1.group().trim());
|
||||||
|
|
||||||
equipmentPreReq.slot = mbEnums.EquipSlotType.valueOf(args.get(0));
|
equipmentPreReq.slot = mbEnums.EquipSlotType.valueOf(arguments.get(0));
|
||||||
equipmentPreReq.skill = args.get(1).replaceAll("\"", "");
|
equipmentPreReq.skill = arguments.get(1).replaceAll("\"", "");
|
||||||
equipmentPreReq.level = Integer.parseInt(args.get(2));
|
equipmentPreReq.level = Integer.parseInt(arguments.get(2));
|
||||||
powerEntry.equipmentPreReq = equipmentPreReq;
|
powerEntry.equipmentPreReq = equipmentPreReq;
|
||||||
break;
|
break;
|
||||||
case "CANCASTWHILEMOVING":
|
case "CANCASTWHILEMOVING":
|
||||||
@@ -296,9 +294,9 @@ public class PowersParser {
|
|||||||
|
|
||||||
// Parse power conditions
|
// Parse power conditions
|
||||||
|
|
||||||
if (!conditionString.toString().isEmpty()) {
|
if (conditionString.isEmpty() == false) {
|
||||||
|
|
||||||
String[] conditions = conditionString.toString().split("\n");
|
List<String> conditions = Arrays.asList(conditionString.split("\n"));
|
||||||
|
|
||||||
for (String condition : conditions) {
|
for (String condition : conditions) {
|
||||||
List<String> parameters = Arrays.asList(condition.trim().split("\\s+"));
|
List<String> parameters = Arrays.asList(condition.trim().split("\\s+"));
|
||||||
|
|||||||
Reference in New Issue
Block a user