TownyAdvanced / Towny

Towny Advanced Minecraft plugin for Bukkit/Spigot.
https://townyadvanced.github.io
Other
519 stars 356 forks source link

Block set to AIR in BlockExplodeEvent #4770

Closed FrankHeijden closed 3 years ago

FrankHeijden commented 3 years ago

In the regenerationtask of towny, when a bed is exploded in the nether, towny sets the blocks in the BlockExplodeEvent#blockList() to AIR, making it impossible for other plugins after Towny to monitor block changes on the MONITOR event phase. It might be better to remove the block from the blockList() in combination with setting it to AIR, if towny can guarantee the block will be regenerated.

https://github.com/TownyAdvanced/Towny/blob/7b6a020c1ccc7c354bf28973ff2103f46cb7eab1/src/com/palmergames/bukkit/towny/regen/TownyRegenAPI.java#L524

LlmDl commented 3 years ago

No one should be making any significant changes to anything at the Monitor level. You can use the TownyExplodingBlocksEvent to change what is being blown up. We have to change the block to air in order to reliably prevent blocks from dropping, because the Bukkit API does not allow the drops to be cleared reliably.

FrankHeijden commented 3 years ago

I wasn't referring to making changes on the monitor level, I am monitoring the event to determine the exact outcome of the event -- but due to how towny sets the blocks to AIR this becomes impossible to check solely from this event phase.

LlmDl commented 3 years ago

Ah yes sorry. You could use the same event to get the blocklist involved. Towny will reliably revert those blocks.

FrankHeijden commented 3 years ago

but this requires plugins to explicitly hook into towny to fix the event -- something which I can see other plugins could also have problems with.

LlmDl commented 3 years ago

Towny wouldn't have to do it if Bukkit could reliably set the explosion yield to 0/clear the drops.

FrankHeijden commented 3 years ago

The BlockExplodeEvent does have a setYield(float) method, if setting the yield to 0 doesn't work, shouldn't this be brought up to the spigot team instead?

LlmDl commented 3 years ago

Reported by a Towny team member already: https://hub.spigotmc.org/jira/browse/SPIGOT-5155

FrankHeijden commented 3 years ago

But the issue was marked as fixed?

LlmDl commented 3 years ago

It would appear that it does work now. That's good news.