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 index 7d8d1c95..06d5e8cf 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java @@ -40,7 +40,7 @@ public class InventoryListener_15 { } private static int drillDown(NBTTagList items, int layer, int start) { - if (layer > 2) return start; + if (layer > 2) return start + 1024; int invalid = start; for (NBTBase nbtBase : items) { if (!(nbtBase instanceof NBTTagCompound)) 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 f992e210..8dd183c5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java @@ -21,13 +21,15 @@ 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.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -49,11 +51,6 @@ public class InventoryListener implements Listener { } } - if (Core.getVersion() < 15) { - e.setCurrentItem(stack); - return; - } - if (stack.getItemMeta().hasAttributeModifiers()) { ItemMeta meta = stack.getItemMeta(); for (Attribute a : Attribute.values()) { @@ -63,9 +60,35 @@ public class InventoryListener implements Listener { } if (VersionedCallable.call(new VersionedCallable(() -> InventoryListener_15.checkItemStack(stack), 15))) { e.setCurrentItem(null); + e.setCancelled(true); + System.out.println("I"); return; } e.setCurrentItem(stack); } + + @EventHandler(ignoreCancelled = true) + public void onPlayerJoin(PlayerJoinEvent event) { + Player p = event.getPlayer(); + ItemStack[] content = event.getPlayer().getInventory().getContents(); + for (int i = 0; i < content.length; i++) { + if (content[i] == null) continue; + int finalI = i; + if (VersionedCallable.call(new VersionedCallable(() -> InventoryListener_15.checkItemStack(content[finalI]), 15))) { + p.getInventory().setItem(i, null); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onBlockPlace(BlockPlaceEvent event) { + Player p = event.getPlayer(); + if (VersionedCallable.call(new VersionedCallable(() -> InventoryListener_15.checkItemStack(event.getItemInHand()), 15))) { + event.setCancelled(true); + event.setBuild(false); + p.getInventory().setItemInMainHand(null); + p.getInventory().setItemInOffHand(null); + } + } }