From d4ae0ba06389f608a3b0309618cf3d34025a731d Mon Sep 17 00:00:00 2001 From: Dinnerwolph Date: Mon, 20 May 2024 17:17:17 +0200 Subject: [PATCH] Fixes #4020 --- .../slimefun4/utils/SlimefunUtils.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index 5fc3bda47f..441c606a06 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -21,8 +21,10 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; @@ -489,6 +491,23 @@ private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemM return ((PotionMeta) itemMeta).getBasePotionData().equals(((PotionMeta) sfitemMeta).getBasePotionData()); } + // Fixes #4020: Book and Head Player Comparison + + if (itemMeta instanceof BookMeta itemBookMeta && sfitemMeta instanceof BookMeta sfItemBookMeta) { + if(itemBookMeta.getAuthor() != sfItemBookMeta.getAuthor()) + return false; + if(itemBookMeta.getTitle() != sfItemBookMeta.getTitle()) + return false; + if(itemBookMeta.getPageCount() != sfItemBookMeta.getPageCount()) + return false; + } + + if (itemMeta instanceof SkullMeta itemHeadMeta && sfitemMeta instanceof SkullMeta sfItemHeadMeta) { + if(itemHeadMeta.getOwningPlayer() != sfItemHeadMeta.getOwningPlayer()) + return false; + } + + return true; }