SteamWar/BauSystem2.0
Archiviert
12
0
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Chaoscaot 2021-05-24 11:42:13 +02:00
Ursprung bcc5836ec2
Commit c25e9fdb8d
2 geänderte Dateien mit 30 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -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))

Datei anzeigen

@ -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.<Boolean>call(new VersionedCallable<Boolean>(() -> 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.<Boolean>call(new VersionedCallable<Boolean>(() -> 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.<Boolean>call(new VersionedCallable<Boolean>(() -> InventoryListener_15.checkItemStack(event.getItemInHand()), 15))) {
event.setCancelled(true);
event.setBuild(false);
p.getInventory().setItemInMainHand(null);
p.getInventory().setItemInOffHand(null);
}
}
}