Solved WorldGuard API Block in region

Discussion in 'Spigot Plugin Development' started by Gobli989, Jul 29, 2018.

  1. Hey guys!
    I am trying to make a Regen Block plugin and I want to ask how can I check if the block is in a worldguard region what can be specified in the config.

    Thanks!
     
  2. What block are you talking about?
     
  3. Optic_Fusion1

    Resource Staff

    I assume the block that ends up broken
     
  4. Get the location of the broken block, compare it to the worldguard/edit selection and see if it's within the cuboid.
     
  5. Thank you for everyone who helped me. I found the solution, Here is the code If anyone needs it.

    Code (Java):
            RegionManager regionManager = getWorldGuard().getRegionManager(block.getWorld());
            ApplicableRegionSet applicableRegionSet = regionManager.getApplicableRegions(loc);

            for(ProtectedRegion region : applicableRegionSet) {
                if(p.getConfig().getStringList("settings.Allowed-WorldGuard-Regions").contains(region.getId())) {
                    block.setType(Material.BEDROCK);
                    player.sendMessage(ChatColor.RED + ":)");
                }
            }