Search in sources :

Example 1 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project MyPet by xXKeyleXx.

the class WorldGuardCustomFlagsHook method canHurt.

@Override
public boolean canHurt(Player attacker, Player defender) {
    try {
        Location location = defender.getLocation();
        RegionManager mgr = wgPlugin.getRegionManager(location.getWorld());
        ApplicableRegionSet set = mgr.getApplicableRegions(location);
        StateFlag.State s;
        s = set.queryState(wgPlugin.wrapPlayer(defender), WorldGuardHook.DAMAGE_FLAG);
        return s == null || s == StateFlag.State.ALLOW;
    } catch (Throwable ignored) {
    }
    return true;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) StateFlag(com.sk89q.worldguard.protection.flags.StateFlag) Location(org.bukkit.Location) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Example 2 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project MyPet by xXKeyleXx.

the class WorldGuardHook method canHurt.

@Override
public boolean canHurt(Player attacker, Player defender) {
    try {
        Location location = defender.getLocation();
        RegionManager mgr = wgp.getRegionManager(location.getWorld());
        ApplicableRegionSet set = mgr.getApplicableRegions(location);
        StateFlag.State s;
        if (customFlags) {
            s = set.queryState(wgp.wrapPlayer(defender), DefaultFlag.PVP, DAMAGE_FLAG);
        } else {
            s = set.queryState(wgp.wrapPlayer(defender), DefaultFlag.PVP);
        }
        return s == null || s == StateFlag.State.ALLOW;
    } catch (Throwable ignored) {
    }
    return true;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) StateFlag(com.sk89q.worldguard.protection.flags.StateFlag) Location(org.bukkit.Location) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Example 3 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project MyPet by xXKeyleXx.

the class WorldGuardHook method isPetAllowed.

@Override
public boolean isPetAllowed(MyPetPlayer player) {
    if (customFlags) {
        Player p = player.getPlayer();
        RegionManager mgr = wgp.getRegionManager(p.getWorld());
        ApplicableRegionSet regions = mgr.getApplicableRegions(p.getLocation());
        StateFlag.State s = regions.queryState(null, DENY_FLAG);
        return s == null || s == StateFlag.State.ALLOW;
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) StateFlag(com.sk89q.worldguard.protection.flags.StateFlag) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Example 4 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project MagicPlugin by elBukkit.

the class WorldGuardAPI method getDestructible.

@Nullable
public String getDestructible(Player player, Location location) {
    if (location != null && worldGuard != null && customFlags != null) {
        RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
        if (regionManager == null) {
            return null;
        }
        ApplicableRegionSet checkSet = regionManager.getApplicableRegions(location);
        if (checkSet == null) {
            return null;
        }
        return customFlags.getDestructible(getAssociable(player), checkSet);
    }
    return null;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet) Nullable(javax.annotation.Nullable)

Example 5 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project MagicPlugin by elBukkit.

the class WorldGuardAPI method getReflective.

@Nullable
public String getReflective(Player player, Location location) {
    if (location != null && worldGuard != null && customFlags != null) {
        RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
        if (regionManager == null) {
            return null;
        }
        ApplicableRegionSet checkSet = regionManager.getApplicableRegions(location);
        if (checkSet == null) {
            return null;
        }
        return customFlags.getReflective(getAssociable(player), checkSet);
    }
    return null;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet) Nullable(javax.annotation.Nullable)

Aggregations

RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)26 ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)12 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)11 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)6 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)6 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)6 StateFlag (com.sk89q.worldguard.protection.flags.StateFlag)5 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 Nullable (javax.annotation.Nullable)5 Location (org.bukkit.Location)5 ProtectedCuboidRegion (com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion)4 BlockVector (com.sk89q.worldedit.BlockVector)3 DefaultDomain (com.sk89q.worldguard.domains.DefaultDomain)3 BuyRegion (me.wiefferink.areashop.regions.BuyRegion)3 RentRegion (me.wiefferink.areashop.regions.RentRegion)3 World (org.bukkit.World)3 Player (org.bukkit.entity.Player)3 OwnedLand (biz.princeps.landlord.util.OwnedLand)2 ArrayList (java.util.ArrayList)2 GeneralRegion (me.wiefferink.areashop.regions.GeneralRegion)2