Search in sources :

Example 1 with ApplicableRegionSet

use of com.sk89q.worldguard.protection.ApplicableRegionSet 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 ApplicableRegionSet

use of com.sk89q.worldguard.protection.ApplicableRegionSet 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 ApplicableRegionSet

use of com.sk89q.worldguard.protection.ApplicableRegionSet 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 ApplicableRegionSet

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

the class WorldGuardCustomFlagsHook method canHurt.

@Override
public boolean canHurt(Player attacker, Entity defender) {
    try {
        Location location = defender.getLocation();
        RegionManager mgr = wgPlugin.getRegionManager(location.getWorld());
        ApplicableRegionSet set = mgr.getApplicableRegions(location);
        StateFlag.State s = set.queryState(null, 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 5 with ApplicableRegionSet

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

the class WorldGuardHook method canHurt.

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

Aggregations

ApplicableRegionSet (com.sk89q.worldguard.protection.ApplicableRegionSet)5 StateFlag (com.sk89q.worldguard.protection.flags.StateFlag)5 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)5 Location (org.bukkit.Location)4 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)1 Animals (org.bukkit.entity.Animals)1 Player (org.bukkit.entity.Player)1