Fix Crash when importing deck
removed "sideboard"
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user