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! |
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java
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 (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 existingnet.kyori...Tagimport). Prefer annotating the field type directly and fully-qualifyingorg.bukkit.Tagfor 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 anOptionalon 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.
}
|
@copilot fix the merge conflict |
Co-authored-by: NotMyFault <13383509+NotMyFault@users.noreply.github.com>
Head branch was pushed to by a user without write access
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 (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
eggTagis annotated using the uncommonorg.bukkit.@Nullable Tag<...>form, which reduces readability (especially with the existingnet.kyori...Tagimport). Prefer placing the nullability annotation on the field type and fully-qualifyingorg.bukkit.Tagnormally.
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:eggsitem 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; |
| private final WorldEdit worldEdit; | ||
| private final PlotAreaManager plotAreaManager; | ||
| private final PlotListener plotListener; | ||
| private final org.bukkit.@Nullable Tag<Material> eggTag = Bukkit.getTag( |
| // 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")); |
There was a problem hiding this comment.
does this not incorrectly match dragon_egg?
There was a problem hiding this comment.
Should be simply replaced with Material.EGG.equals / ==
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.