Skip to content

Commit

Permalink
Drop old item for 'offhand' editing
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 31, 2016
1 parent d44b7bf commit d561fe9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/citizensnpcs/editor/EquipmentEditor.java
Expand Up @@ -66,6 +66,10 @@ public void run() {
if (hand.getType() == Material.AIR || hand.getAmount() <= 0) {
return;
}
ItemStack old = npc.getTrait(Equipment.class).get(finalSlot);
if (old != null && old.getType() != Material.AIR) {
event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), old);
}
npc.getTrait(Equipment.class).set(finalSlot,
new ItemStack(event.getPlayer().getInventory().getItemInMainHand().getType(), 1));
hand.setAmount(hand.getAmount() - 1);
Expand Down

0 comments on commit d561fe9

Please sign in to comment.