mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Use try/catch block to avoid crash from bad pattern
This commit is contained in:
@@ -378,7 +378,7 @@ public class CardStorageReader {
|
|||||||
public static void parseAllCards(String[] args) {
|
public static void parseAllCards(String[] args) {
|
||||||
if (args.length < 2) { return; }
|
if (args.length < 2) { return; }
|
||||||
|
|
||||||
final int[] updatedCounts = new int[args.length - 1];
|
final int[] counts = new int[args.length];
|
||||||
final List<File> allFiles = new ArrayList<File>();
|
final List<File> allFiles = new ArrayList<File>();
|
||||||
final CardRulesReader rulesReader = new CardRulesReader();
|
final CardRulesReader rulesReader = new CardRulesReader();
|
||||||
final CardStorageReader reader = new CardStorageReader(NewConstants.CARD_DATA_DIR, false, null);
|
final CardStorageReader reader = new CardStorageReader(NewConstants.CARD_DATA_DIR, false, null);
|
||||||
@@ -395,24 +395,26 @@ public class CardStorageReader {
|
|||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.print(rules.getName());
|
System.out.print(rules.getName());
|
||||||
|
|
||||||
|
counts[0]++;
|
||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
switch (args[i]) {
|
switch (args[i]) {
|
||||||
case "updateAbilityManaSymbols":
|
case "updateAbilityManaSymbols":
|
||||||
if (updateAbilityManaSymbols(rules, lines, file)) {
|
if (updateAbilityManaSymbols(rules, lines, file)) {
|
||||||
updatedCounts[i - 1]++;
|
counts[i]++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException ex) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < args.length; i++) {
|
System.out.println();
|
||||||
int count = updatedCounts[i - 1];
|
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
int count = counts[i];
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.print(args[i] + " - " + count + "card" + (count != 1 ? "s" : ""));
|
System.out.print(args[i] + " - " + count + " card" + (count != 1 ? "s" : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,17 +429,23 @@ public class CardStorageReader {
|
|||||||
}
|
}
|
||||||
s = s.trim();
|
s = s.trim();
|
||||||
if (s.isEmpty()) { continue; }
|
if (s.isEmpty()) { continue; }
|
||||||
String pattern = s.replaceAll("\\{([WUBRGSXYZ]|[0-9]+)\\}", "$1[ ]\\?").replaceAll("\\{C\\}", "Chaos");
|
try {
|
||||||
if (pattern.length() != s.length()) {
|
String pattern = s.replaceAll("\\{([WUBRGSXYZ]|[0-9]+)\\}", "$1[ ]\\?").replaceAll("\\{C\\}", "Chaos");
|
||||||
pattern = "Description\\$(.*)" + pattern;
|
if (pattern.length() != s.length()) {
|
||||||
s = "Description\\$$1" + s;
|
pattern = "Description\\$(.*)" + pattern;
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
s = "Description\\$$1" + s;
|
||||||
String newLine = lines.get(i).replaceAll(pattern, s);
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
if (newLine.length() != lines.get(i).length()) {
|
String newLine = lines.get(i).replaceAll(pattern, s);
|
||||||
updated = true;
|
if (newLine.length() != lines.get(i).length()) {
|
||||||
lines.set(i, newLine);
|
updated = true;
|
||||||
}
|
lines.set(i, newLine);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
System.out.print(" - Exception: " + ex.getMessage());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updated) {
|
if (updated) {
|
||||||
|
|||||||
Reference in New Issue
Block a user