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;
}
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;
}
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;
}
}
}
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;
}
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);
}
Aggregations