Bypass WorldGuard protection for specified block?

Discussion in 'Spigot Plugin Development' started by Bars, May 16, 2016.

  1. I want to make my lucky block can be broken in WorldGuard protected regions. I tried:

    Code (Java):
        @EventHandler(ignoreCancelled = true)
        private void onBlockBreak(BlockBreakEvent e) {
            if (e.isCancelled()) {
                if (e.getBlock().getType().toString().equalsIgnoreCase("OAGP_LUCKYBLOCK")) e.setCancelled(false);
                else e.setCancelled(true);
    But ignoreCancelled do not helped me. I want to make my event work even if it cancelled by all another plugins
  2. There is not a block type named OAGP_LUCKYBLOCK, instead of that do something like adding it in a collection, check if the block is in the collection, if so dont cancel. The type is the material, such as Bedrock, Bed, Grass, Dirt etc.. There's no type named OAGP_LUCKYBLOCK.
  3. I have this block on my server, I can check it thousand millions раз.
    setCancelled(false) not work
  4. You are setting ignoreCancelled to true, which results in your listener not getting called for each cancelled event. Additionally, you check whether the event was cancelled, though you declared to not listen to cancelled events. Where is the logic?
    • Agree Agree x 1
  5. I thinked about ignoreCancelled will wgnore cancellings of other events and will execute my event properly. Okay, if I will set event cancellation to false, and then WorldGuard set it to true, event will be cancelled...
  6. I'm guessing that you need to set your event priority higher, because worldguard checks higher (if I'm right). Also remove the ignoreCancelled, because your code won't get executed once worldguard cancelled the event.
    • Informative Informative x 1