Java Code Examples for com.sk89q.worldguard.protection.ApplicableRegionSet#size()

The following examples show how to use com.sk89q.worldguard.protection.ApplicableRegionSet#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldUtil.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static boolean allowRegion(Location location) {
    if (EchoPet.getPlugin().getWorldGuardProvider().isHooked()) {
        WorldGuardPlugin wg = EchoPet.getPlugin().getWorldGuardProvider().getDependency();
        if (wg == null) {
            return true;
        }
        RegionManager regionManager = wg.getRegionManager(location.getWorld());

        if (regionManager == null) {
            return true;
        }

        ApplicableRegionSet set = regionManager.getApplicableRegions(location);

        if (set.size() <= 0) {
            return true;
        }

        boolean result = true;
        boolean hasSet = false;
        boolean def = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions.allowByDefault", true);

        ConfigurationSection cs = EchoPet.getPlugin().getMainConfig().getConfigurationSection("worldguard.regions");
        for (ProtectedRegion region : set) {
            for (String key : cs.getKeys(false)) {
                if (!key.equalsIgnoreCase("allowByDefault") && !key.equalsIgnoreCase("regionEnterCheck")) {
                    if (region.getId().equals(key)) {
                        if (!hasSet) {
                            result = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions." + key, true);
                            hasSet = true;
                        }
                    }
                }
            }
        }

        return hasSet ? result : def;
    }
    return true;
}
 
Example 2
Source File: WorldGuardFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean containsChunk(int chunkX, int chunkZ) {
    if (!large) return super.containsChunk(chunkX, chunkZ);
    BlockVector pos1 = new BlockVector(chunkX << 4, 0, chunkZ << 4);
    BlockVector pos2 = new BlockVector(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
    ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
    ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion);
    return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
 
Example 3
Source File: WorldGuardFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean containsRegion(int mcaX, int mcaZ) {
    if (!large) return super.containsRegion(mcaX, mcaZ);
    BlockVector pos1 = new BlockVector(mcaX << 9, 0, mcaZ << 9);
    BlockVector pos2 = new BlockVector(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
    ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
    ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
    return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
 
Example 4
Source File: WorldGuardHook.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
public static boolean isInRegion(Location location) {
    ApplicableRegionSet regionSet = getRegionSet(location);
    if (regionSet == null) {
        return false;
    }

    return regionSet.size() != 0;
}
 
Example 5
Source File: WorldUtil.java    From EchoPet with GNU General Public License v3.0 5 votes vote down vote up
public static boolean allowRegion(Location location) {
    if (EchoPet.getPlugin().getWorldGuardProvider().isHooked()) {
        WorldGuardPlugin wg = EchoPet.getPlugin().getWorldGuardProvider().getDependency();
        if (wg == null) {
            return true;
        }
        RegionManager regionManager = wg.getRegionManager(location.getWorld());

        if (regionManager == null) {
            return true;
        }

        ApplicableRegionSet set = regionManager.getApplicableRegions(location);

        if (set.size() <= 0) {
            return true;
        }

        boolean result = true;
        boolean hasSet = false;
        boolean def = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions.allowByDefault", true);

        ConfigurationSection cs = EchoPet.getPlugin().getMainConfig().getConfigurationSection("worldguard.regions");
        for (ProtectedRegion region : set) {
            for (String key : cs.getKeys(false)) {
                if (!key.equalsIgnoreCase("allowByDefault") && !key.equalsIgnoreCase("regionEnterCheck")) {
                    if (region.getId().equals(key)) {
                        if (!hasSet) {
                            result = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions." + key, true);
                            hasSet = true;
                        }
                    }
                }
            }
        }

        return hasSet ? result : def;
    }
    return true;
}