From 30f0f78efcc0f4584fb33ffa61f15d96effb3c1d Mon Sep 17 00:00:00 2001 From: KHobbits Date: Wed, 24 Aug 2011 03:09:27 +0100 Subject: [PATCH] Fixing NPE on Entity Listener (Powertool). --- .../essentials/EssentialsEntityListener.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index 3e53e3eea..91c4bdce4 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -37,13 +37,17 @@ public class EssentialsEntityListener extends EntityListener User attacker = ess.getUser(eAttack); ItemStack is = attacker.getItemInHand(); List commandList = attacker.getPowertool(is); - for(String command : commandList) + if (commandList != null && !commandList.isEmpty()) { - if (command != null && !command.isEmpty()) + for (String command : commandList) { - attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName())); - event.setCancelled(true); - return; + + if (command != null && !command.isEmpty()) + { + attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName())); + event.setCancelled(true); + return; + } } } }