Skip to content

Commit

Permalink
more defensive null checking in draft panel
Browse files Browse the repository at this point in the history
  • Loading branch information
xenohedron committed Sep 28, 2023
1 parent 1c9e954 commit 7c53565
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Mage.Client/src/main/java/mage/client/draft/DraftPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ public DraftPanel() {
}
);

protectionTimer = new Timer(protectionTime, e -> {
protectionTimer.stop();
});
protectionTimer = new Timer(protectionTime, e -> protectionTimer.stop());
}

public void cleanUp() {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()) {
Expand All @@ -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() {
Expand Down

0 comments on commit 7c53565

Please sign in to comment.