Skip to content

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

Open
MattBDev wants to merge 4 commits into
mainfrom
fix/eggs
Open

Fixed support for new egg types in 1.21.5 and later versions#4910
MattBDev wants to merge 4 commits 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 lite 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!

Comment thread Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java Outdated
# Conflicts:
#	Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java
Copilot AI review requested due to automatic review settings August 6, 2026 02:44

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

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:296

  • The egg tag field is declared using the uncommon org.bukkit.@Nullable Tag<...> syntax, which is harder to read (especially with the existing net.kyori...Tag import). Prefer annotating the field type directly and fully-qualifying org.bukkit.Tag for clarity.
    private final org.bukkit.@Nullable Tag<Material> eggTag = Bukkit.getTag(

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:1322

  • This comment says the approach "could be replaced with an Item Tag", but the implementation already uses a Bukkit item tag (with a fallback). Updating the comment would avoid confusion for future maintainers.
                // 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.

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:1325

  • Optional.ofNullable(...).map(...).orElse(...) allocates an Optional on every interaction. A simple null-check is cheaper and clearer here (this handler can run very frequently).
                boolean isEgg = Optional.ofNullable(eggTag)
                        .map(tag -> tag.isTagged(type))
                        .orElse(type.name().endsWith("EGG"));

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:2069

  • There are extra trailing blank lines at the end of the file. These often trigger formatting/checkstyle rules and add noise to diffs.
}


@MattBDev
MattBDev enabled auto-merge (squash) August 11, 2026 21:01
@NotMyFault

Copy link
Copy Markdown
Member

@copilot fix the merge conflict

Co-authored-by: NotMyFault <13383509+NotMyFault@users.noreply.github.com>
auto-merge was automatically disabled August 15, 2026 09:24

Head branch was pushed to by a user without write access

Copilot AI review requested due to automatic review settings August 15, 2026 09:24

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the merge conflict

Fixed in 692ab0a by merging main into this branch and resolving the PlayerEventListener conflict.

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

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:1325

  • Optional.ofNullable(...).map(...).orElse(...) allocates and adds overhead in a very hot event path. A simple null check keeps the same behavior (use the tag when present, otherwise fall back to the suffix check) without per-interact allocations.
                boolean isEgg = Optional.ofNullable(eggTag)
                        .map(tag -> tag.isTagged(type))
                        .orElse(type.name().endsWith("EGG"));

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:296

  • eggTag is annotated using the uncommon org.bukkit.@Nullable Tag<...> form, which reduces readability (especially with the existing net.kyori...Tag import). Prefer placing the nullability annotation on the field type and fully-qualifying org.bukkit.Tag normally.
    private final org.bukkit.@Nullable Tag<Material> eggTag = Bukkit.getTag(

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java:1322

  • The comment says this "could be replaced with an Item Tag" but the implementation already uses the vanilla minecraft:eggs item tag when available. Updating the comment would prevent future confusion about what this logic is doing.

This issue also appears on line 1323 of the same file.

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

import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.Nullable;

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.

wrong annotation type

private final WorldEdit worldEdit;
private final PlotAreaManager plotAreaManager;
private final PlotListener plotListener;
private final org.bukkit.@Nullable Tag<Material> eggTag = Bukkit.getTag(

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.

bukkit.nullable?!

// It could be replaced with an Item Tag or the exact Material in the future.
boolean isEgg = Optional.ofNullable(eggTag)
.map(tag -> tag.isTagged(type))
.orElse(type.name().endsWith("EGG"));

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.

does this not incorrectly match dragon_egg?

@PierreSchwang PierreSchwang Aug 15, 2026

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.

Should be simply replaced with Material.EGG.equals / ==

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants