From b12b9e11ba904fe6411fe3e6ebee5a98417dd5ad Mon Sep 17 00:00:00 2001 From: aPunch Date: Thu, 3 May 2012 15:53:35 -0500 Subject: [PATCH] Fix equip NPE. This fixes CITIZENS-62. --- .../net/citizensnpcs/npc/entity/CitizensHumanNPC.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java index 89968a462..488819945 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java @@ -83,19 +83,22 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable { } Messaging.send(equipper, "" + getName() + " had all of its items removed."); } - // Now edit the equipment based on the slot + // Drop any previous equipment on the ground if (trait.get(slot) != null && trait.get(slot).getType() != Material.AIR) equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(), trait.get(slot)); + // Now edit the equipment based on the slot if (type != Material.AIR) { + // Set the proper slot with one of the item + hand.setAmount(1); + trait.set(slot, hand); + if (hand.getAmount() > 1) hand.setAmount(hand.getAmount() - 1); else hand = null; equipper.setItemInHand(hand); - hand.setAmount(1); } - trait.set(slot, hand); } @Override