package in.twizmwaz.cardinal.module.modules.appliedRegion.type;

import in.twizmwaz.cardinal.module.modules.appliedRegion.AppliedRegion;
import in.twizmwaz.cardinal.module.modules.filter.FilterModule;
import in.twizmwaz.cardinal.module.modules.filter.FilterState;
import in.twizmwaz.cardinal.module.modules.regions.RegionModule;
import in.twizmwaz.cardinal.module.modules.regions.type.BlockRegion;
import in.twizmwaz.cardinal.util.ChatUtil;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

public class UseRegion extends AppliedRegion {

    public UseRegion(RegionModule region, FilterModule filter, String message) {
        super(region, filter, message);
    }

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        if (event.getClickedBlock() == null || (event.getItem() != null && event.getItem().getType().isBlock())) return;
        if (region.contains(new BlockRegion(null, event.getClickedBlock().getLocation().toVector())) && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) && filter.evaluate(event.getPlayer(), event.getClickedBlock(), event).equals(FilterState.DENY)) {
            event.setCancelled(true);
            ChatUtil.sendWarningMessage(event.getPlayer(), message);
        }
    }
}

@@ -506,24 +506,118 @@
 ock.Action;%0A
+import org.bukkit.event.block.BlockBreakEvent;%0Aimport org.bukkit.event.block.BlockPlaceEvent;%0A
 import org.b
@@ -1453,11 +1453,799 @@
  %7D%0A    %7D
+%0A%0A    @EventHandler%0A    public void onPlayerBreakBlock(BlockBreakEvent event) %7B%0A        if (region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector())) && filter.evaluate(event.getPlayer(), event.getBlock(), event).equals(FilterState.DENY)) %7B%0A            event.setCancelled(true);%0A            ChatUtil.sendWarningMessage(event.getPlayer(), message);%0A        %7D%0A    %7D%0A%0A    @EventHandler%0A    public void onPlayerPlaceBlock(BlockPlaceEvent event) %7B%0A        if (region.contains(new BlockRegion(null, event.getBlockAgainst().getLocation().toVector())) && filter.evaluate(event.getPlayer(), event.getBlockAgainst(), event).equals(FilterState.DENY)) %7B%0A            event.setCancelled(true);%0A            ChatUtil.sendWarningMessage(event.getPlayer(), message);%0A        %7D%0A    %7D
 %0A%7D%0A

Use regions also deny block break and block place events