garbagemule / MobArena

MobArena plugin for Minecraft
GNU General Public License v3.0
195 stars 151 forks source link

entityExplode overide LWC and WorldGuard explode protection #704

Closed lackooka closed 2 years ago

lackooka commented 3 years ago

Bug report

Short description

When the plugin is active, the LWC and the Worldguard proctects are just overide in global because it is Highest priority.

I found in the code which is in the MAGlobalListener.class at 193th and 199th line:

@EventHandler(priority = EventPriority.HIGHEST)
public void entityExplode(EntityExplodeEvent event) {
    for (Arena arena : am.getArenas())
        arena.getEventListener().onEntityExplode(event);
}

@EventHandler(priority = EventPriority.HIGHEST)
public void blockExplode(BlockExplodeEvent event) {
    // Create a copy of the block list so we can clear and re-add
    List<Block> blocks = new ArrayList<>(event.blockList());

    // Account for Spigot's messy extra event
    EntityExplodeEvent fake = new EntityExplodeEvent(null, event.getBlock().getLocation(), blocks, event.getYield());
    entityExplode(fake);

    // Copy the values over
    event.setCancelled(fake.isCancelled());
    event.blockList().clear();
    event.blockList().addAll(fake.blockList());
    event.setYield(fake.getYield());
}

Reproduction steps

  1. Place a bed in nether or place respawn anchor on overworld
  2. Explode them near an worldguard and/or LWC protected place (I tried that without any permission)
  3. It just explode them when these block are procected by LWC and/or Worldguard.

Details

MobArena version: 0.106 LWC Version: 2.2.7-ad0f824 WorldGuard version: 7.0.5+3827266 Server version: Paper 1.16.5-649

Additional info

I just replace the HIGHEST to LOWEST and then it is not exploded. If you want to see them, I can send you videos of it.

Nesseley commented 3 years ago

Just linking to this previous issue in case its of any usage on this issue. #697

garbagemule commented 3 years ago

We recently had #697 conclude with a "cannot reproduce" conclusion from the person reporting the issue, so it's nice to see another set of reproduction steps that might bring about some sort of clear solution.

That solution is not to lower the priority, however. That would break so many other things.

I can see that my last comment on the other issue mentioned the cancel state from the input event not being copied over. Could you try that instead of changing the priority to see if that also fixes the problem? Just add fake.setCancelled(event.isCancelled()); between these two lines:

EntityExplodeEvent fake = new EntityExplodeEvent(null, event.getBlock().getLocation(), blocks, event.getYield());
entityExplode(fake);
lackooka commented 3 years ago

I added it, and it works at the moment. I hope it could be stay in this option.

garbagemule commented 3 years ago

I think we should get this fix implemented and tested before closing the issue :)

Nesseley commented 2 years ago

@lackooka Hey I tried replicating your bug on a clean setup with ONLY WorldEdit and WorldGuard. And I cannot get a region to block explosions made by respawn anchors. I'm not sure this is 100% a MobArena problem, as I didn't even have MobArena on my server and the explosion still destroyed blocks inside of my regions. TNT did not remove blocks inside the region, only respawn anchors. I did not test beds in the nether.

Are you able to make a test server and let me know if you experience the same thing I did with only WorldGuard and WorldEdit on the server? Or am I missing some flags for the regions here?

lackooka commented 2 years ago

I just added 1 line for the mobarena code which is in this commit or idk what is the name for it, and the problem was solved and it works really fine. The problem was the LWC protected blocks got exploded. The TNT and the respawn anchor/bed explosion are totally different in the java codes.

lackooka commented 2 years ago

And the worldguard has "other-explosion" flag for it. You can add it for the protections or just in the config globally.