From 0a9e4d48b538562c8bd7c08450bfa043d4de1f32 Mon Sep 17 00:00:00 2001 From: Steffion Date: Mon, 5 Aug 2013 11:57:18 +0200 Subject: [PATCH] Fixed 2 NPE errors. --- src/nl/Steffion/BlockHunt/InventoryHandler.java | 6 ++++-- .../BlockHunt/Listeners/OnInventoryClickEvent.java | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/nl/Steffion/BlockHunt/InventoryHandler.java b/src/nl/Steffion/BlockHunt/InventoryHandler.java index b7136c8..d0f50a9 100644 --- a/src/nl/Steffion/BlockHunt/InventoryHandler.java +++ b/src/nl/Steffion/BlockHunt/InventoryHandler.java @@ -183,8 +183,10 @@ public class InventoryHandler { arenaNameNote_IM.setLore(lores); arenaNameNote.setItemMeta(arenaNameNote_IM); panel.setItem(0, arenaNameNote); - for (int i = arena.disguiseBlocks.size(); i > 0; i = i - 1) { - panel.setItem(i, arena.disguiseBlocks.get(i - 1)); + if (arena.disguiseBlocks != null) { + for (int i = arena.disguiseBlocks.size(); i > 0; i = i - 1) { + panel.setItem(i, arena.disguiseBlocks.get(i - 1)); + } } player.openInventory(panel); } diff --git a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java index 080daf1..23dadd5 100644 --- a/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java +++ b/src/nl/Steffion/BlockHunt/Listeners/OnInventoryClickEvent.java @@ -28,10 +28,12 @@ public class OnInventoryClickEvent implements Listener { if (inv.getType().equals(InventoryType.CHEST)) { if (inv.getName().startsWith("\u00A7r")) { if (inv.getName().contains("DisguiseBlocks")) { - if (!event.getCurrentItem().getType().isBlock()) { - event.setCancelled(true); - MessageM.sendFMessage(player, - ConfigC.error_setNotABlock, true); + if (event.getCurrentItem() != null) { + if (!event.getCurrentItem().getType().isBlock()) { + event.setCancelled(true); + MessageM.sendFMessage(player, + ConfigC.error_setNotABlock, true); + } } return;