Permalink
Browse files

Avoid possible NPE when paying prizes.

  • Loading branch information...
1 parent 3d48df5 commit f86fd58bc1fb704485eb4108efbe9b47d9b7e891 @mkalus committed May 5, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/main/java/de/beimax/simplespleef/game/GameStandard.java
@@ -1843,6 +1843,10 @@ protected void payPrizeItems(Player player) {
} else prize = prizes.get(generator.nextInt(prizes.size() - 1));
// interpret line to Item Stack
ItemStack itemStack = MaterialHelper.getItemStackFromString(prize, false);
+ if (itemStack == null) { // fix NPE
+ SimpleSpleef.log.warning("[SimpleSpleef] Item prize error: NPE for prize index #" + prize + "! Ignoring prize.");
+ return;
+ }
// give prizes to player
player.getInventory().addItem(itemStack);
// player gets message

0 comments on commit f86fd58

Please sign in to comment.