Fixed hopper transactions not always being logged (fixes #490)

This commit is contained in:
Intelli 2024-01-24 17:44:18 -07:00
parent f7fea2b298
commit af1d4402eb
5 changed files with 35 additions and 76 deletions

View file

@ -680,6 +680,30 @@ public class Util extends Queue {
return false;
}
/* return true if item can be added to container */
public static boolean canAddContainer(ItemStack[] container, ItemStack item, int forceMaxStack) {
for (ItemStack containerItem : container) {
if (containerItem == null || containerItem.getType() == Material.AIR) {
return true;
}
int maxStackSize = containerItem.getMaxStackSize();
if (forceMaxStack > 0 && (forceMaxStack < maxStackSize || maxStackSize == -1)) {
maxStackSize = forceMaxStack;
}
if (maxStackSize == -1) {
maxStackSize = 1;
}
if (containerItem.isSimilar(item) && containerItem.getAmount() < maxStackSize) {
return true;
}
}
return false;
}
public static int getArtId(String name, boolean internal) {
int id = -1;
name = name.toLowerCase(Locale.ROOT).trim();

View file

@ -120,7 +120,7 @@ public class ItemMetaHandler {
List<Map<String, Object>> list = new ArrayList<>();
List<Object> modifiers = new ArrayList<>();
if (item.hasItemMeta() && item.getItemMeta() != null) {
if (item != null && item.hasItemMeta() && item.getItemMeta() != null) {
ItemMeta itemMeta = item.getItemMeta().clone();
if (itemMeta.hasAttributeModifiers()) {