Fixed removeIf in telekinesis

This commit is contained in:
Auxilor 2021-02-20 11:59:09 +00:00
parent 4e4ff6cd05
commit 3d1dd8e02d

View File

@ -22,6 +22,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDropItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
@ -171,7 +172,19 @@ public class Telekinesis extends EcoEnchant {
int xp = event.getXp();
Collection<ItemStack> drops = event.getDrops();
drops.removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER));
drops.removeIf(itemStack -> {
if (itemStack == null) {
return true;
}
ItemMeta meta = itemStack.getItemMeta();
if (meta == null) {
return false;
}
if (meta.getPersistentDataContainer() == null) {
return false;
}
return meta.getPersistentDataContainer().has(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER);
});
new DropQueue(player)
.addItems(drops)