WorldGuard

WorldGuard

8M Downloads

Explosions created by BlockExplodeEvent are not prevented.

LadyCailinBot opened this issue ยท 6 comments

commented

WORLDGUARD-3843 - Reported by d_scalzi

Explosions which trigger the [BlockExplodeEvent|https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockExplodeEvent.html] are currently not prevented by WorldGuard. The most common explosion which triggers this event is [World#createExplosion|https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#createExplosion-double-double-double-float-boolean-boolean-]. These explosions bypass the TNT: DENY and OTHER-EXPLOSIONS: DENY flags and occur even when tnt is disabled in the configuration. Affected version is at least WorldGuard 6.1.3-SNAPSHOT;c904242. Release 6.1 claims to have added support for this event but it's not functioning.

commented

Comment by wizjany

can you give an example of a behavior that isn't protected from this? (i.e. what throws this event that you can't protect against)

commented

Comment by d_scalzi

Any explosion which is created by the API method [World#createExplosion|https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#createExplosion-double-double-double-float-boolean-boolean-]. For example if a plugin for some reason triggers this explosion you would expect worldguard to cancel it if the explosion is in a region with either TNT or OTHER-EXPLOSION denied (depending on which better fits this scenario). You might also expect worldguard to cancel the explosion if explosions are disabled globally in the configuration.

commented

Comment by wizjany

it doesn't look like there's any way to see if a plugin is doing the exploding, so from worldguard's point of view if a "member" block destroys other blocks, it's handled with build permissions as normal.
if the explosion is outside a region, the damage should also be protected by build permissions as normal.

given that a plugin can make arbitrary blocks "explode", i think we would have to make a pretty specific "fix" for this, since we generally don't bother accounting for plugins doing weird things. it would be better if the plugin checked the relevant flags before exploding things if it was worried about that.

commented

Comment by d_scalzi

I understand what you're saying, however these eplosions always trigger the BlockExplodeEvent so worldguard should be able to listen to it and cancel it if the necessary protections are in place. Just as ender crystal explosions are prevented, these could be aswell. I've done some tests with other protection plugins to see the consensus on this and GriefPrevention does prevent these explosions in their claimed regions. I'm by no means an expert in WorldGuard's internals but I do believe the plugin should be able to protect against explosions which trigger this event.

commented

Comment by DerPavlov

I just want to point out that [World#createExplosion|https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#createExplosion-double-double-double-float-boolean-boolean-] is an important method and is heavily used.
[Cannons|https://dev.bukkit.org/projects/cannons] uses this method for explosions, since there is no other bukkit method for doing that. It was working fine in the beginning, but since spigot/bukkit changed it to BlockExplodeEvent Worldguard does not detect "bukkit" explosion anymore.

The "Build"/"TNT/"Other-explosion" flag do not prevent the explosion damage. The only way I found is relaying the event to the previously used EntityExplodeEvent with entity null. For 2 years I am using that code as a fix:

    
public void blockExplodeEvent(BlockExplodeEvent event) {
    EntityExplodeEvent explodeEvent = new EntityExplodeEvent(null, event.getBlock().getLocation(), event.blockList(), event.getYield());
    Bukkit.getServer().getPluginManager().callEvent(explodeEvent);
    event.setCancelled(explodeEvent.isCancelled());
}```
commented

Comment by PseudoKnight

This is the relevant commit:

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/e387d8dc7752a7f03e6baa1dadaf66ec2e7e3512

As you can see, previously WG would handle it via the EntityExplodeEvent. It can no longer do this after the commit.