PlotSquared icon indicating copy to clipboard operation
PlotSquared copied to clipboard

Instabreak drops items when disabled in BlockBreakEvent.

Open nicolube opened this issue 1 year ago • 8 comments

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

  • [X] I have included a Plot debugpaste.
  • [X] I am using the newest build from https://www.spigotmc.org/resources/77506/ and the issue still persists.

Anything else?

Compiled form latest src

nicolube avatar Sep 30 '24 07:09 nicolube

Can you please attach code for reproduction ?

TheMeinerLP avatar Sep 30 '24 08:09 TheMeinerLP

@EventHandler
public void onBlockBreakEvent(BlockBreakEvent event) {
    event.setDropItems(false);
}

nicolube avatar Sep 30 '24 08:09 nicolube

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

TheMeinerLP avatar Sep 30 '24 08:09 TheMeinerLP

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

nicolube avatar Sep 30 '24 08:09 nicolube

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

dordsor21 avatar Sep 30 '24 08:09 dordsor21

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

nicolube avatar Sep 30 '24 08:09 nicolube

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.

SirYwell avatar Sep 30 '24 08:09 SirYwell

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

nicolube avatar Sep 30 '24 08:09 nicolube