Java Code Examples for com.sk89q.worldguard.bukkit.WorldGuardPlugin#getRegionManager()

The following examples show how to use com.sk89q.worldguard.bukkit.WorldGuardPlugin#getRegionManager() . 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: HookWorldGuard_V6_2.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private static ApplicableRegionSet getRegions(Location location) {
    World world = location.getWorld();

    WorldGuardPlugin api = getAPI();
    RegionManager manager = api.getRegionManager(world);
    return manager.getApplicableRegions(location);
}
 
Example 2
Source File: HookWorldGuard_V6_1.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private static ApplicableRegionSet getRegions(Location location) {
    World world = location.getWorld();

    WorldGuardPlugin api = getAPI();
    RegionManager manager = api.getRegionManager(world);
    return manager.getApplicableRegions(location);
}
 
Example 3
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 4
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;
}