mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-30 22:53:24 +01:00
Fix equip NPE. This fixes CITIZENS-62.
This commit is contained in:
parent
37ba042c29
commit
b12b9e11ba
@ -83,19 +83,22 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
|||||||
}
|
}
|
||||||
Messaging.send(equipper, "<e>" + getName() + " <a>had all of its items removed.");
|
Messaging.send(equipper, "<e>" + getName() + " <a>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)
|
if (trait.get(slot) != null && trait.get(slot).getType() != Material.AIR)
|
||||||
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(), trait.get(slot));
|
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(), trait.get(slot));
|
||||||
|
|
||||||
|
// Now edit the equipment based on the slot
|
||||||
if (type != Material.AIR) {
|
if (type != Material.AIR) {
|
||||||
|
// Set the proper slot with one of the item
|
||||||
|
hand.setAmount(1);
|
||||||
|
trait.set(slot, hand);
|
||||||
|
|
||||||
if (hand.getAmount() > 1)
|
if (hand.getAmount() > 1)
|
||||||
hand.setAmount(hand.getAmount() - 1);
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
else
|
else
|
||||||
hand = null;
|
hand = null;
|
||||||
equipper.setItemInHand(hand);
|
equipper.setItemInHand(hand);
|
||||||
hand.setAmount(1);
|
|
||||||
}
|
}
|
||||||
trait.set(slot, hand);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user