mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Old-format decks will load without exceptions
This commit is contained in:
@@ -23,7 +23,7 @@ public class DeckSerializer {
|
||||
FileUtil.writeFile(f, serializeDeck(d));
|
||||
}
|
||||
|
||||
static DeckFileHeader readDeckMetadata(final Map<String, List<String>> map, final boolean canThrow) {
|
||||
static DeckFileHeader readDeckMetadata(final Map<String, List<String>> map) {
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -33,9 +33,6 @@ public class DeckSerializer {
|
||||
}
|
||||
final List<String> general = map.get("general");
|
||||
if (general != null) {
|
||||
if (canThrow) {
|
||||
throw new OldDeckFileFormatException();
|
||||
}
|
||||
final FileSectionManual fs = new FileSectionManual();
|
||||
fs.put(DeckFileHeader.NAME, StringUtils.join(map.get(""), " "));
|
||||
fs.put(DeckFileHeader.DECK_TYPE, StringUtils.join(general, " "));
|
||||
@@ -66,19 +63,15 @@ public class DeckSerializer {
|
||||
}
|
||||
|
||||
public static Deck fromFile(final File deckFile) {
|
||||
return fromSections(FileSection.parseSections(FileUtil.readFile(deckFile)), false);
|
||||
return fromSections(FileSection.parseSections(FileUtil.readFile(deckFile)));
|
||||
}
|
||||
|
||||
public static Deck fromSections(final Map<String, List<String>> sections) {
|
||||
return fromSections(sections, false);
|
||||
}
|
||||
|
||||
static Deck fromSections(final Map<String, List<String>> sections, final boolean canThrowExtendedErrors) {
|
||||
if (sections == null || sections.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final DeckFileHeader dh = readDeckMetadata(sections, canThrowExtendedErrors);
|
||||
final DeckFileHeader dh = readDeckMetadata(sections);
|
||||
if (dh == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DeckStorage extends StorageReaderFolder<Deck> implements IItemSeria
|
||||
@Override
|
||||
protected Deck read(final File file) {
|
||||
final Map<String, List<String>> sections = FileSection.parseSections(FileUtil.readFile(file));
|
||||
Deck result = DeckSerializer.fromSections(sections, true);
|
||||
Deck result = DeckSerializer.fromSections(sections);
|
||||
|
||||
if (moveWronglyNamedDecks) {
|
||||
adjustFileLocation(file, result);
|
||||
|
||||
@@ -171,7 +171,7 @@ public class OldDeckParser {
|
||||
|
||||
final List<String> fileLines = FileUtil.readFile(f);
|
||||
final Map<String, List<String>> sections = FileSection.parseSections(fileLines);
|
||||
final DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections, false);
|
||||
final DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
|
||||
String name = dh.getName();
|
||||
|
||||
if (dh.isCustomPool()) {
|
||||
|
||||
Reference in New Issue
Block a user