Skip to content

Commit

Permalink
Fixes #4020
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerwolph committed May 20, 2024
1 parent 45601c8 commit d4ae0ba
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d4ae0ba

Please sign in to comment.