Prevent NPE if client never connected to any server and doesn't have

sets downloaded.
This commit is contained in:
rkfg 2016-02-29 19:29:10 +03:00
parent 9da86fefad
commit 3658a8c7bc
3 changed files with 25 additions and 4 deletions

View file

@ -54,6 +54,14 @@ import mage.util.TournamentUtil;
*/
public class DeckGenerator {
public static class DeckGeneratorException extends RuntimeException {
public DeckGeneratorException(String message) {
super(message);
}
}
private static final int MAX_TRIES = 8196;
private static DeckGeneratorDialog genDialog;
private static DeckGeneratorPool genPool;
@ -82,6 +90,9 @@ public class DeckGenerator {
String format = genDialog.getSelectedFormat();
List<String> setsToUse = ConstructedFormats.getSetsByFormat(format);
if (setsToUse == null) {
throw new DeckGeneratorException("Deck sets aren't initialized; please connect to a server to update the database.");
}
if (setsToUse.isEmpty()) {
// Default to using all sets
setsToUse = ExpansionRepository.instance.getSetCodes();