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.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:1319
Optional+ lambda allocation here is unnecessary on a high-frequencyPlayerInteractEventpath. You can keep the same behavior with a simple null-check (and it also makes the intent clearer).
// This new variable detects all current and future eggs.
// It could be replaced with an Item Tag or the exact Material in the future.
boolean isEgg = Optional.ofNullable(Bukkit.getTag(org.bukkit.Tag.REGISTRY_ITEMS, NamespacedKey.minecraft("eggs"), Material.class))
.map(tag -> tag.isTagged(type))
.orElse(type.name().endsWith("EGG"));
|
Please take a moment and address the merge conflicts of your pull request. Thanks! |
1 similar comment
|
Please take a moment and address the merge conflicts of your pull request. Thanks! |
| // 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. | ||
| boolean isEgg = Optional.ofNullable(Bukkit.getTag(org.bukkit.Tag.REGISTRY_ITEMS, NamespacedKey.minecraft("eggs"), Material.class)) |
There was a problem hiding this comment.
I think based on the JavaDocs of either Bukkit.getTag or something along the lines the result of said method should be cached (seems to be an expensive method, potentially).
There was a problem hiding this comment.
Would you prefer to make the call to Bukkit.getTag() a static field when the PlayerEventListener class is initialized?
There was a problem hiding this comment.
Yeah, that would be the best approach I'd say
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.