Skip to content

Protect cushions from being broken by players not added to the plot - #4976

Open
JJS1906 wants to merge 1 commit into
IntellectualSites:mainfrom
JJS1906:fix-cushion-break-4959
Open

JJS1906 wants to merge 1 commit into
IntellectualSites:mainfrom
JJS1906:fix-cushion-break-4959

Conversation

@JJS1906

@JJS1906 JJS1906 commented Nov 29, 2026

Copy link
Copy Markdown

Hey! On 26.3, players who aren't added to a plot can break cushions there (#4959). I looked into it: a cushion is a block-attached entity, but not a Hanging, so Paper doesn't fire HangingBreakByEntityEvent for it. It fires the new io.papermc.paper.event.entity.EntityBreakByEntityEvent instead, and PlotSquared doesn't listen to that yet.

What I changed:

  • moved the checks from onHangingBreakByEntity into shouldCancelEntityBreak(remover, entity). Hanging entities behave exactly the same as before.
  • added EntityBreakEventBridge, which registers a handler for EntityBreakByEntityEvent reflectively. It only does that if the class exists at runtime, since PlotSquared still compiles against the 1.21.1 API, and it only applies to entities inside a plot area.

So cushions now follow the same rules as item frames and paintings, including the hanging-break flag. If you'd rather have a separate flag for them, let me know and I'll change it.

It compiles fine. I haven't been able to test this exact build on a live 26.3 server yet.

Fixes #4959

Cushions (26.3) are block-attached entities but not Hanging, so Paper fires
io.papermc.paper.event.entity.EntityBreakByEntityEvent instead of
HangingBreakByEntityEvent. Move the hanging break checks into
shouldCancelEntityBreak() and register a reflective handler for the new
event (only if it exists at runtime, only inside plot areas).

Fixes IntellectualSites#4959
@JJS1906
JJS1906 requested a review from a team as a code owner November 29, 2026 15:15
@MattBDev MattBDev self-assigned this Nov 29, 2026
@MattBDev MattBDev added Priority This issue has priority over backburner issues and should be fixed as soon as possible. Major bug fix This PR fixes a major bug labels Nov 29, 2026
@MattBDev

Copy link
Copy Markdown
Contributor

I'll review this shortly and see how it compares to the fix I was working on. Hopefully I can give this a quick approval so we can get it merged in.

@PierreSchwang

Copy link
Copy Markdown
Member

I'm not a fan of this approach - why not just update the paper dependency and register the listener (in a separate class) when running the appropriate Minecraft version?

@JJS1906

JJS1906 commented Nov 29, 2026

Copy link
Copy Markdown
Author

@MattBDev thanks for the quick look — glad if this can go in soon!

@PierreSchwang fair point. Some background on the reflection bridge: PlotSquared compiles against paper-api 1.21.1, but EntityBreakByEntityEvent (which fires for cushions on 26.3) only exists in a newer Paper API — so a direct @EventHandler wouldn't compile against the current baseline. That said, a clean version-gated listener (like ProjectileEventListener1211 behind isNewerOrEqualThan) is just as fine by me; it would only need a paper-api bump to a version that ships the event. I didn't want to just raise that myself without checking with you first, since you keep the baseline conservative on purpose.

Honestly both ways are fine by me — just let me know what you prefer. If you're ok with the bump, point me at the target paper-api version and I'll switch it to the direct listener; if not, that's completely fine too. Happy to adjust either way.

@MattBDev

MattBDev commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

From a quick glance from my phone since I'm not at my computer, I believe this is the exact approach I originally took to solve the issue. I ended up just creating another branch with updated JDK and api requirements because I wasn't a fan of the approach but understood it was probably the only approach given our current dependency restriction.
We can't move to paper-api 26.3 that introduces this event unless we decide we are bumping the minimum Java requirement to Java 25. Personally, I'm in favor of doing this but this needs to be a unanimous decision among the team.
For this reason, I'm going to approve this request but leave it unmerged until we can get the opinion from the others @IntellectualSites/plotsquared-team

@JJS1906

JJS1906 commented Nov 30, 2026

Copy link
Copy Markdown
Author

Thanks for the feedback, @MattBDev! As mentioned above, happy to switch it to a direct listener if the team goes with Java 25.

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

Labels

Major bug fix This PR fixes a major bug Priority This issue has priority over backburner issues and should be fixed as soon as possible.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Players not added to a plot can break placed cushions (minecraft:cushion, 26.3)

3 participants