Skip to content

Commit

Permalink
Fixed crash when slot is invalid in potion command
Browse files Browse the repository at this point in the history
Now, instead of a crash because of an unhandled
IndexOutOfBoundsException, the command will return and print the reason
it failed and the valid slots to use to the DevConsole
  • Loading branch information
Skrelpoid committed Nov 6, 2018
1 parent 89eca98 commit 3078b6a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/basemod/DevConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,12 @@ private static void cmdPotion(String[] tokens) {
log("use potion list to see valid ids");
return;
}

if (AbstractDungeon.player != null && (i >= AbstractDungeon.player.potionSlots || i < 0)) {
log("cannot obtain potion in invalid slot " + i);
log("use values between 0 and " + (AbstractDungeon.player.potionSlots - 1));
return;
}

AbstractDungeon.player.obtainPotion(i, p);
}
Expand Down

0 comments on commit 3078b6a

Please sign in to comment.