From 7c535658f00b2b07aa4c27843ce3cff0c92b0f1e Mon Sep 17 00:00:00 2001 From: xenohedron Date: Wed, 27 Sep 2023 23:54:29 -0400 Subject: [PATCH] more defensive null checking in draft panel --- .../java/mage/client/draft/DraftPanel.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java index 2dce939378fe..381449737195 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java @@ -122,9 +122,7 @@ public DraftPanel() { } ); - protectionTimer = new Timer(protectionTime, e -> { - protectionTimer.stop(); - }); + protectionTimer = new Timer(protectionTime, e -> protectionTimer.stop()); } public void cleanUp() { @@ -337,7 +335,7 @@ public void loadBooster(DraftPickView draftPickView) { if (!draftBooster.isEmptyGrid()) { SessionHandler.setBoosterLoaded(draftId); // confirm to the server that the booster has been successfully loaded, otherwise the server will re-send the booster - if(pickNo != protectionPickNo && !protectionTimer.isRunning()) { + if (pickNo != protectionPickNo && !protectionTimer.isRunning()) { // Restart the protection timer. protectionPickNo = pickNo; protectionTimer.restart(); @@ -451,7 +449,7 @@ private void showAgainAllHiddenCards() { // that's why instead of proactively logging our pick we instead // log *last* pick from the list of picks. // To make this possible we cache the list of cards from the - // previous booster and it's sequence number (pack number / pick number) + // previous booster and its sequence number (pack number / pick number) // in fields currentBooster and currentBoosterHeader. private void logLastPick(DraftPickView pickView) { if (!isLogging()) { @@ -472,11 +470,13 @@ private void logLastPick(DraftPickView pickView) { private String getCurrentSetCode() { // TODO: Record set codes for random drafts correctly - if (setCodes.size() >= packNo) { - return setCodes.get(packNo - 1); - } else { - return " "; + if (setCodes != null && setCodes.size() >= packNo) { + String setCode = setCodes.get(packNo - 1); + if (setCode != null) { // Not sure how, but got a NPE from this method P1P2 in a ZEN/ZEN/WWK draft + return setCode; + } } + return " "; } private static boolean isLogging() {