Java Code Examples for com.sk89q.worldguard.protection.flags.StateFlag#State

The following examples show how to use com.sk89q.worldguard.protection.flags.StateFlag#State . 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: WorldGuardApi.java    From ClaimChunk with MIT License 5 votes vote down vote up
static boolean _isAllowedClaim(ClaimChunk claimChunk, Chunk chunk) {
    try {
        // Generate a region in the given chunk to get all intersecting regions
        int bx = chunk.getX() << 4;
        int bz = chunk.getZ() << 4;
        BlockVector3 pt1 = BlockVector3.at(bx, 0, bz);
        BlockVector3 pt2 = BlockVector3.at(bx + 15, 256, bz + 15);
        ProtectedCuboidRegion region = new ProtectedCuboidRegion("_", pt1, pt2);
        RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(chunk.getWorld()));

        // No regions in this world, claiming should be determined by the config
        if (regionManager == null) {
            return claimChunk.chConfig().getBool("worldguard", "allowClaimingInNonGuardedWorlds");
        }

        // If any regions in the given chunk deny chunk claiming, false is returned
        for (ProtectedRegion regionIn : regionManager.getApplicableRegions(region)) {
            StateFlag.State flag = regionIn.getFlag(FLAG_CHUNK_CLAIM);
            if (flag == StateFlag.State.DENY) return false;
        }

        // No objections
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }

    // An error occurred, better to be on the safe side so false is returned
    return false;
}
 
Example 2
Source File: HookWorldGuard_V7_0.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
public static boolean allowsPVP(Location location) {
    WorldGuard api = getAPI();
    WorldGuardPlatform platform = api.getPlatform();
    RegionContainer container = platform.getRegionContainer();
    RegionQuery query = container.createQuery();

    com.sk89q.worldedit.util.Location weLocation = BukkitAdapter.adapt(location);
    StateFlag.State state = query.queryState(weLocation, null, Flags.PVP);
    return (state != StateFlag.State.DENY);
}
 
Example 3
Source File: HookWorldGuard_V6_2.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsPVP(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    StateFlag.State state = regions.queryState(null, DefaultFlag.PVP);
    return (state != StateFlag.State.DENY);
}
 
Example 4
Source File: HookWorldGuard_V6_2.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsMobCombat(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    StateFlag.State state = regions.queryState(null, mobCombatFlag);
    return (state != StateFlag.State.DENY);
}
 
Example 5
Source File: HookWorldGuard_V6_1.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsPVP(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    StateFlag.State state = regions.queryState(null, DefaultFlag.PVP);
    return (state != StateFlag.State.DENY);
}
 
Example 6
Source File: HookWorldGuard_V6_1.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsMobCombat(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    StateFlag.State state = regions.queryState(null, mobCombatFlag);
    return (state != StateFlag.State.DENY);
}