Search in sources :

Example 21 with RegionManager

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

the class WorldGuardAPI method isPVPAllowed.

public boolean isPVPAllowed(Player player, Location location) {
    if (worldGuard == null || location == null)
        return true;
    RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
    if (regionManager == null)
        return true;
    ApplicableRegionSet checkSet = regionManager.getApplicableRegions(location);
    if (checkSet == null)
        return true;
    return checkSet.queryState(getAssociable(player), DefaultFlag.PVP) != StateFlag.State.DENY;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet)

Example 22 with RegionManager

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

the class WorldGuardAPI method getWandPermission.

@Nullable
public Boolean getWandPermission(Player player, Wand wand, 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.getWandPermission(getAssociable(player), checkSet, wand);
    }
    return null;
}
Also used : RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ApplicableRegionSet(com.sk89q.worldguard.protection.ApplicableRegionSet) Nullable(javax.annotation.Nullable)

Example 23 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project LandLord by SpatiumPrinceps.

the class Manage method onManage.

public void onManage(Player player, String[] args) {
    OwnedLand land = plugin.getWgHandler().getRegion(player.getLocation().getChunk());
    if (land == null) {
        player.sendMessage(lm.getString("Commands.Manage.notOwnFreeLand"));
        return;
    }
    if (!land.isOwner(player.getUniqueId()) && !player.hasPermission("landlord.admin.manage")) {
        player.sendMessage(lm.getString("Commands.Manage.notOwn").replace("%owner%", land.printOwners()));
        return;
    }
    // land manage
    if (args.length == 0) {
        ManageGUI gui = new ManageGUI(player, land);
        gui.display();
    } else if (args.length == 1) {
        // land manage <landid>
        World world;
        try {
            world = Bukkit.getWorld(args[0].split("_")[0]);
        } catch (IndexOutOfBoundsException e) {
            player.sendMessage(lm.getString("Commands.manage.invalidArguments"));
            return;
        }
        if (Bukkit.getWorlds().contains(world)) {
            RegionManager rm = plugin.getWgHandler().getWG().getRegionManager(world);
            if (rm != null) {
                ProtectedRegion target = rm.getRegion(args[0]);
                if (target != null) {
                    ManageGUI gui = new ManageGUI(player, plugin.getLand(target));
                    gui.display();
                }
            }
        }
    } else {
        // land manage <allCommands>
        switch(args[0]) {
            case "setgreetall":
                StringBuilder sb1 = new StringBuilder();
                for (int i = 1; i < args.length; i++) {
                    sb1.append(args[i]).append(" ");
                }
                String newmsg1 = sb1.toString();
                for (ProtectedRegion protectedRegion : plugin.getWgHandler().getRegions(player.getUniqueId())) {
                    protectedRegion.setFlag(DefaultFlag.GREET_MESSAGE, newmsg1);
                }
                player.sendMessage(lm.getString("Commands.Manage.SetGreet.successful").replace("%msg%", newmsg1));
                break;
            case "setfarewellall":
                StringBuilder sb = new StringBuilder();
                for (int i = 1; i < args.length; i++) {
                    sb.append(args[i]).append(" ");
                }
                String newmsg = sb.toString();
                for (ProtectedRegion protectedRegion : plugin.getWgHandler().getRegions(player.getUniqueId())) {
                    protectedRegion.setFlag(DefaultFlag.FAREWELL_MESSAGE, newmsg);
                }
                player.sendMessage(lm.getString("Commands.Manage.SetFarewell.successful").replace("%msg%", newmsg));
                break;
            case "setgreet":
                setGreet(player, args, plugin.getLand(player.getLocation()).getWGLand(), 1);
                break;
            case "setfarewell":
                setFarewell(player, args, plugin.getLand(player.getLocation()).getWGLand(), 1);
                break;
            default:
                try {
                    World world = Bukkit.getWorld(args[0].split("_")[0]);
                    if (Bukkit.getWorlds().contains(world)) {
                        RegionManager rm = plugin.getWgHandler().getWG().getRegionManager(world);
                        if (rm != null) {
                            ProtectedRegion target = rm.getRegion(args[0]);
                            switch(args[1]) {
                                case "setgreet":
                                    setGreet(player, args, target, 2);
                                    break;
                                case "setfarewell":
                                    setFarewell(player, args, target, 2);
                                    break;
                            }
                        }
                    }
                } catch (IndexOutOfBoundsException e) {
                    player.sendMessage(lm.getString("Commands.manage.invalidArguments"));
                }
                break;
        }
    }
}
Also used : ManageGUI(biz.princeps.landlord.guis.ManageGUI) OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) World(org.bukkit.World)

Example 24 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method canClaim.

public boolean canClaim(Player player, Chunk currChunk) {
    RegionManager regionManager = wg.getRegionManager(player.getWorld());
    if (regionManager != null) {
        ProtectedRegion check = new ProtectedCuboidRegion("check", toVector(currChunk.getBlock(0, 0, 0)), toVector(currChunk.getBlock(15, 127, 15)));
        List<ProtectedRegion> intersects = check.getIntersectingRegions(new ArrayList<>(regionManager.getRegions().values()));
        for (ProtectedRegion intersect : intersects) {
            if (!regionManager.getApplicableRegions(intersect).canBuild(wg.wrapPlayer(player))) {
                return false;
            }
        }
    }
    return true;
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) ProtectedCuboidRegion(com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion)

Example 25 with RegionManager

use of com.sk89q.worldguard.protection.managers.RegionManager in project LandLord by SpatiumPrinceps.

the class WorldGuardHandler method getRegion.

public OwnedLand getRegion(Chunk chunk) {
    RegionManager manager = wg.getRegionContainer().get(chunk.getWorld());
    ProtectedRegion pr = manager != null ? manager.getRegion(OwnedLand.getName(chunk)) : null;
    return (pr != null ? new OwnedLand(pr, chunk) : null);
}
Also used : OwnedLand(biz.princeps.landlord.util.OwnedLand) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager)

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