From 9e1d5af97dd12a87058c8a361ccaf1d741127dee Mon Sep 17 00:00:00 2001 From: Intelli Date: Wed, 19 Jul 2023 17:11:47 -0600 Subject: [PATCH] Fixed NullPointerException while logging container transactions --- .../net/coreprotect/database/logger/ContainerLogger.java | 3 +++ src/main/java/net/coreprotect/utility/Util.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/coreprotect/database/logger/ContainerLogger.java b/src/main/java/net/coreprotect/database/logger/ContainerLogger.java index 11b6e60..f2f0386 100644 --- a/src/main/java/net/coreprotect/database/logger/ContainerLogger.java +++ b/src/main/java/net/coreprotect/database/logger/ContainerLogger.java @@ -57,6 +57,9 @@ public class ContainerLogger extends Queue { ItemStack[] oi1 = oldList.get(0); ItemStack[] oldInventory = Util.getContainerState(oi1); ItemStack[] newInventory = Util.getContainerState(contents); + if (oldInventory == null || newInventory == null) { + return; + } List forceList = ConfigHandler.forceContainer.get(loggingContainerId); if (forceList != null) { diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index 96f6090..fb4329f 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -610,7 +610,10 @@ public class Util extends Queue { } public static ItemStack[] getContainerState(ItemStack[] array) { - ItemStack[] result = array.clone(); + ItemStack[] result = array == null ? null : array.clone(); + if (result == null) { + return result; + } int count = 0; for (ItemStack itemStack : array) {