Conversation
There was a problem hiding this comment.
Pull request overview
This pull request updates PlotSquared’s Bukkit PlayerEventListener interaction handling to recognize newly added egg item types (e.g., blue/brown eggs in 1.21.5+) the same way as the classic egg, ensuring they trigger the same spawn-related event classification.
Changes:
- Introduces a shared
isEggboolean to detect egg-like materials and reuse the check across Paper and non-Paper branches. - Expands the Paper branch condition to treat any “*egg” material similarly, matching the non-Paper behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| } else { | ||
| if (type.toString().toLowerCase().endsWith("egg")) { | ||
| if (MaterialTags.SPAWN_EGGS.isTagged(type) || isEgg) { |
There was a problem hiding this comment.
Spawn eggs are not the same as regular eggs so the || here is valid and needed. However, I should have probably reversed this check so isEgg is checked BEFORE the MaterialTag since it will probably be true in almost all cases. I'm willing to change it for PR approval, but it honestly won't make much of a difference.
| } | ||
| // 1.21.5 (Spring to Life) introduced brown_egg and blue_egg. | ||
| // This new variable detects all current and future eggs. | ||
| // It could be replaced with an Item Tag or the exact Material in the future. |
There was a problem hiding this comment.
Not wanting to be nit-picky, but why not now already, given the eggs tag was introduced in 1.21.5? Something like
boolean isEgg = Optional.ofNullable(Bukkit.getTag(org.bukkit.Tag.REGISTRY_ITEMS, NamespacedKey.minecraft("eggs"), Material.class))
.map(tag -> tag.isTagged(type))
.orElseGet(() -> type.name().endsWith("EGG"));with some caching?
There was a problem hiding this comment.
You're not being nitpicky. I've been gone for awhile so I appreciate the constructive feedback. That is actually a more elegant solution and actually almost what I did. I guess I went the lazy way? 😅
There was a problem hiding this comment.
A simple Material.EGG.equals(type) should suffice in the orElse part, wasn't thinking much
Overview
Fixes an issue where blue and brown eggs aren't treated the same as regular eggs.
Description
Includes a new variable to detect all eggs in game and treat them the same.
Submitter Checklist
@since TODO.