Solved BlockBreakEvent, respect WorldGuard?

Discussion in 'Plugin Development' started by valon750, Jul 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    valon750

    Morning all, strange for me to be up at 9am 0.0

    Having a little issue with a plugin of mine, as it's dawned on me that since I've had to add a BlockBreakEvent to make sure the block broken drops a slightly different ItemStack, as well as make sure the Block broken is set to air, it does not in fact respect WorldGuard.

    This basically meaning that players can break the block regardless of the protection plugins in place.

    I saw a somewhat related thread from a while back that states changing the events priority, as well as the "ignoreCancelled" argument will resolve this? However I'm not currently able to get to a computer for a few hours.
     
  2. Offline

    stirante

    valon750
    I use
    Code:
    if (!WGBukkit.getRegionManager(event.getBlock().getWorld()).getApplicableRegions(BukkitUtil.toVector(event.getBlock().getLocation())).canBuild(WGBukkit.getPlugin().wrapPlayer(player))) return;
     
  3. just add at this at the beginning :p
    Code:
    if (event.isCancelled()) return;
     
  4. Offline

    RingOfStorms

    @EventHandler(ignoreCancelled = true)
    add the ignoreCancelled = true value to the EventHandler annotation
     
  5. Offline

    valon750

    FisheyLP

    Ah so WorldGuard's event priority is rightfully high, thank you for the swift answer :)

    stirante

    I see, so I'd hook in to WorldGuard for this and have it check the applicable regions, I like it :3
     
Thread Status:
Not open for further replies.

Share This Page