Skip to content

Fixed support for new egg types in 1.21.5 and later versions - #4910

Open
MattBDev wants to merge 1 commit into
mainfrom
fix/eggs
Open

Fixed support for new egg types in 1.21.5 and later versions#4910
MattBDev wants to merge 1 commit into
mainfrom
fix/eggs

Conversation

@MattBDev

Copy link
Copy Markdown
Contributor

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

  • Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • Ensure that the pull request title represents the desired changelog entry.
  • New public fields and methods are annotated with @since TODO.
  • I read and followed the contribution guidelines.

Copilot AI review requested due to automatic review settings July 29, 2026 18:58
@MattBDev
MattBDev requested a review from a team as a code owner July 29, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 isEgg boolean 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.

Comment thread Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java Outdated
Copilot AI review requested due to automatic review settings July 31, 2026 02:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-frequency PlayerInteractEvent path. 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"));

@github-actions

Copy link
Copy Markdown

Please take a moment and address the merge conflicts of your pull request. Thanks!

1 similar comment
@github-actions

Copy link
Copy Markdown

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))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would you prefer to make the call to Bukkit.getTag() a static field when the PlayerEventListener class is initialized?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, that would be the best approach I'd say

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants