IntellectualSites / PlotSquared

PlotSquared - Reinventing the plotworld
GNU General Public License v3.0
542 stars 736 forks source link

Instabreak drops items when disabled in BlockBreakEvent. #4508

Open nicolube opened 2 hours ago

nicolube commented 2 hours ago

Server Implementation

Paper

Server Version

1.20

Describe the bug

Instabreak dropes items when disabled in BlockBreakEvent.

To Reproduce

  1. Write a Plugin with an BlockBreakListener that disables drops.
  2. Enable instabreak on a plot
  3. Break Blocks
  4. Items still drop

Expected behaviour

Items only stopping when blockbreak event says it should

Screenshots / Videos

No response

Error log (if applicable)

No response

Plot Debugpaste

https://athion.net/ISPaster/paste/view/14b8c2d536ca470293e0f3a37ec0bbab

PlotSquared Version

7.3.12-SNAPSHOT

Checklist

Anything else?

Compiled form latest src

TheMeinerLP commented 2 hours ago

Can you please attach code for reproduction ?

nicolube commented 2 hours ago
@EventHandler
public void onBlockBreakEvent(BlockBreakEvent event) {
    event.setDropItems(false);
}
TheMeinerLP commented 2 hours ago

I would consider setting the event priority. The events are sorted and called by Bukkit in the following order: LOWEST -> LOWEST -> NORMAL -> HIGH -> HIGHEST -> MONITOR See: https://jd.papermc.io/paper/1.21.1/org/bukkit/event/EventHandler.html

nicolube commented 2 hours ago

I would consider setting the event priority. The events are sorted and called by Bukkit in the following order: LOWEST -> LOWEST -> NORMAL -> HIGH -> HIGHEST -> MONITOR See: https://jd.papermc.io/paper/1.21.1/org/bukkit/event/EventHandler.html

BlockBreakEvent with instabreak falg is called by PlotSquared... And is executes breakNaturally when not cancled... Does not check if dropItems is disabled...

I would suggest u check before proposing a solution that will not work. https://github.com/IntellectualSites/PlotSquared/blob/main/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java#L523

dordsor21 commented 2 hours ago

For instabreak P2 uses Block#breakNaturally and I do not know what event(s) that would send, and what it would be determined as have being "done" by

nicolube commented 2 hours ago

Would u guys just look 2 mins at ur own code before replying? The this is a very simple issue and easy to fix.

SirYwell commented 1 hour ago

We don't make any guarantees about what information is used from the BlockBreakEvent. I guess this is a feature request then. Feel free to open a PR.

nicolube commented 1 hour ago

Well, is this a feature request or a bug?

Well, I would say it is most definitely a bug, when calling Bukkit-evnets, the behavior of the event should mimic Bukkit as closely as possible.

If're not doing that, u break other plugins.

Which events are being called at an block break by a player?\ As far as I know...

  1. BlockBreakEvent
  2. BlockDropItemEvent (if it has drops)

Well to be super correct, the BlockDropItems event should also be called when makeing a fake block break by an player