Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4020 #4193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Comment on lines +496 to +508
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the codestyle this looks good, only thing I think is wrong is the if statements are missing brackets and some spaces.

Other than that functionally its probably okay but you can inline the returns to be like
return itemBookMeta.getAuthor().equals(sfItemBookMeta.getAuthor() && etc etc
or
return itemHeadMeta.getOwningPlayer().equals(sfItemHeadMeta.getOwningPlayer());
I'm not 100% sure that the player check is a good idea since it's nullable iirc, so you might need to change that, I'd have to check to be completely sure



return true;
}

Expand Down
Loading