diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java b/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java
new file mode 100644
index 00000000..7d8d1c95
--- /dev/null
+++ b/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java
@@ -0,0 +1,64 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2021 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.bausystem.features.world;
+
+import net.minecraft.server.v1_15_R1.NBTBase;
+import net.minecraft.server.v1_15_R1.NBTTagCompound;
+import net.minecraft.server.v1_15_R1.NBTTagList;
+import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
+import org.bukkit.inventory.ItemStack;
+
+public class InventoryListener_15 {
+
+ public static boolean checkItemStack(ItemStack item) {
+ net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
+ NBTTagCompound tag = nmsItem.getTag();
+ assert tag != null;
+ NBTTagCompound blockTag = tag.getCompound("BlockEntityTag");
+ assert blockTag != null;
+ if (blockTag.hasKey("Items")) {
+ return drillDown(blockTag.getList("Items", 10), 0, 0) > 1024;
+ }
+ return false;
+ }
+
+ private static int drillDown(NBTTagList items, int layer, int start) {
+ if (layer > 2) return start;
+ int invalid = start;
+ for (NBTBase nbtBase : items) {
+ if (!(nbtBase instanceof NBTTagCompound))
+ continue;
+ NBTTagCompound slot = (NBTTagCompound) nbtBase;
+ if (slot.hasKey("tag")) {
+ invalid += slot.getByte("Count");
+ NBTTagCompound iTag = slot.getCompound("tag");
+ if (iTag.hasKey("BlockEntityTag")) {
+ NBTTagCompound blockTag = iTag.getCompound("BlockEntityTag");
+ if (blockTag.hasKey("Items")) {
+ invalid = drillDown(blockTag.getList("Items", 10), layer + 1, invalid);
+ }
+ }
+ }
+ if (invalid > 1024)
+ break;
+ }
+ return invalid;
+ }
+}
diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java
index efc0ac8e..f992e210 100644
--- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java
+++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java
@@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.core.Core;
+import de.steamwar.core.VersionedCallable;
import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.EventHandler;
@@ -60,6 +61,11 @@ public class InventoryListener implements Listener {
}
stack.setItemMeta(meta);
}
+ if (VersionedCallable.call(new VersionedCallable(() -> InventoryListener_15.checkItemStack(stack), 15))) {
+ e.setCurrentItem(null);
+ return;
+ }
+
e.setCurrentItem(stack);
}
}