Fix Crash when importing deck

removed "sideboard"
This commit is contained in:
Anthony Calosa
2016-07-11 16:35:57 +08:00
committed by GitHub
parent 6d4a068453
commit 5cde230723
@@ -34,21 +34,18 @@ public class DeckImporter
{ {
while (scanner.hasNext()) while (scanner.hasNext())
{ {
boolean foundSideboard = false;
String line = scanner.nextLine(); String line = scanner.nextLine();
if(line.toLowerCase().contains("sideboard")) line = line.trim();
foundSideboard = true; if (!line.equals("")) // don't write out blank lines
{
String[] slines = line.split("\\s+"); String[] slines = line.split("\\s+");
String arranged = ""; String arranged = "";
for(int idx = 1; idx < slines.length; idx++) for(int idx = 1; idx < slines.length; idx++)
{ {
arranged += slines[idx] + " "; arranged += slines[idx] + " ";
} }
if ((isNumeric(slines[0])||foundSideboard) && arranged != null) if ((isNumeric(slines[0])) && arranged != null)
{ {
if (foundSideboard)
deck += prefix;
if (slines[1] != null && slines[1].startsWith("[")) if (slines[1] != null && slines[1].startsWith("["))
{ {
arranged = arranged.substring(5); arranged = arranged.substring(5);
@@ -61,6 +58,7 @@ public class DeckImporter
} }
} }
} }
}
File profile = new File(activePath+"/Res/settings/options.txt"); File profile = new File(activePath+"/Res/settings/options.txt");
if(profile.exists() && !profile.isDirectory()) if(profile.exists() && !profile.isDirectory())
{ {
@@ -87,14 +85,11 @@ public class DeckImporter
if (!toSave.exists()) { if (!toSave.exists()) {
toSave.createNewFile(); toSave.createNewFile();
} }
// get the content in bytes // get the content in bytes
byte[] contentInBytes = deck.getBytes(); byte[] contentInBytes = deck.getBytes();
fop.write(contentInBytes); fop.write(contentInBytes);
fop.flush(); fop.flush();
fop.close(); fop.close();
message = "Import Deck Success!\n\n"+deck; message = "Import Deck Success!\n\n"+deck;
} }
catch (IOException e) catch (IOException e)