From 975a030ebef624685d04ac5ee1be2f384dc59e1b Mon Sep 17 00:00:00 2001 From: Intelli Date: Tue, 8 Mar 2022 13:59:19 -0700 Subject: [PATCH] Fixed NullPointerException when trading with wandering traders --- .../net/coreprotect/listener/player/CraftItemListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/coreprotect/listener/player/CraftItemListener.java b/src/main/java/net/coreprotect/listener/player/CraftItemListener.java index 101612b..71a080c 100644 --- a/src/main/java/net/coreprotect/listener/player/CraftItemListener.java +++ b/src/main/java/net/coreprotect/listener/player/CraftItemListener.java @@ -171,6 +171,7 @@ public final class CraftItemListener extends Queue implements Listener { } if (addItem.getAmount() > 0) { + Location location = (isTrade || event.getInventory().getLocation() == null) ? player.getLocation() : event.getInventory().getLocation(); for (ItemStack oldItem : oldItems) { if (oldItem == null || oldItem.getType() == Material.AIR) { continue; @@ -181,10 +182,10 @@ public final class CraftItemListener extends Queue implements Listener { return; } removedItem.setAmount(removedItem.getAmount() * amountMultiplier); - logCraftedItem(event.getInventory().getLocation(), player.getName(), removedItem, isTrade ? ItemLogger.ITEM_SELL : ItemLogger.ITEM_DESTROY); + logCraftedItem(location, player.getName(), removedItem, isTrade ? ItemLogger.ITEM_SELL : ItemLogger.ITEM_DESTROY); } - logCraftedItem(event.getInventory().getLocation(), player.getName(), addItem, isTrade ? ItemLogger.ITEM_BUY : ItemLogger.ITEM_CREATE); + logCraftedItem(location, player.getName(), addItem, isTrade ? ItemLogger.ITEM_BUY : ItemLogger.ITEM_CREATE); } }