Fixed risk of NullPointerException when logging container transactions

This commit is contained in:
Intelli 2021-07-25 16:53:58 -06:00
parent 130614bfdd
commit d2614ed6dc
2 changed files with 12 additions and 7 deletions

View file

@ -46,10 +46,14 @@ public class ContainerLogger extends Queue {
ItemStack[] oi1 = oldList.get(0);
ItemStack[] oldInventory = Util.getContainerState(oi1);
ItemStack[] newInventory = Util.getContainerState(contents);
if (ConfigHandler.forceContainer.get(loggingContainerId) != null) {
List<ItemStack[]> forceList = ConfigHandler.forceContainer.get(loggingContainerId);
if (forceList != null) {
int forceSize = 0;
if (!forceList.isEmpty()) {
newInventory = Util.getContainerState(forceList.get(0));
int forceSize = modifyForceContainer(loggingContainerId, null);
forceSize = modifyForceContainer(loggingContainerId, null);
}
if (forceSize == 0) {
ConfigHandler.forceContainer.remove(loggingContainerId);
}

View file

@ -125,9 +125,10 @@ public final class InventoryChangeListener extends Queue implements Listener {
ItemStack[] containerState = Util.getContainerState(inventoryData);
// If items have been removed by a hopper, merge into containerState
if (ConfigHandler.transactingChest.get(transactingChestId) != null) {
List<Object> transactingChestList = Collections.synchronizedList(new ArrayList<>(ConfigHandler.transactingChest.get(transactingChestId)));
if (transactingChestList.size() > 0) {
List<Object> transactingChest = ConfigHandler.transactingChest.get(transactingChestId);
if (transactingChest != null) {
List<Object> transactingChestList = Collections.synchronizedList(new ArrayList<>(transactingChest));
if (!transactingChestList.isEmpty()) {
ItemStack[] newState = new ItemStack[containerState.length + transactingChestList.size()];
int count = 0;