This commit is contained in:
drtshock
2014-07-01 15:10:18 -05:00
parent 5066934a95
commit 8a6a97cc90
110 changed files with 3131 additions and 1228 deletions

View File

@@ -33,9 +33,13 @@ public class Worldguard {
public static void init(Plugin plugin) {
Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
enabled = false; wg = null; P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
enabled = false;
wg = null;
P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
} else {
wg = (WorldGuardPlugin) wgplug; enabled = true; P.p.log("Successfully hooked to WorldGuard.");
wg = (WorldGuardPlugin) wgplug;
enabled = true;
P.p.log("Successfully hooked to WorldGuard.");
}
}
@@ -53,10 +57,13 @@ public class Worldguard {
return true;
}
Location loc = player.getLocation(); World world = loc.getWorld(); Vector pt = toVector(loc);
Location loc = player.getLocation();
World world = loc.getWorld();
Vector pt = toVector(loc);
RegionManager regionManager = wg.getRegionManager(world);
ApplicableRegionSet set = regionManager.getApplicableRegions(pt); return set.allows(DefaultFlag.PVP);
ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
return set.allows(DefaultFlag.PVP);
}
// Check if player can build at location by worldguards rules.
@@ -69,9 +76,12 @@ public class Worldguard {
return false;
}
World world = loc.getWorld(); Vector pt = toVector(loc);
World world = loc.getWorld();
Vector pt = toVector(loc);
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) { return wg.canBuild(player, loc); }
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) {
return wg.canBuild(player, loc);
}
return false;
}
@@ -85,8 +95,12 @@ public class Worldguard {
return false;
}
World world = loc.getWorld(); Chunk chunk = world.getChunkAt(loc); int minChunkX = chunk.getX() << 4;
int minChunkZ = chunk.getZ() << 4; int maxChunkX = minChunkX + 15; int maxChunkZ = minChunkZ + 15;
World world = loc.getWorld();
Chunk chunk = world.getChunkAt(loc);
int minChunkX = chunk.getX() << 4;
int minChunkZ = chunk.getZ() << 4;
int maxChunkX = minChunkX + 15;
int maxChunkZ = minChunkZ + 15;
int worldHeight = world.getMaxHeight(); // Allow for heights other than default
@@ -97,10 +111,12 @@ public class Worldguard {
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
List<ProtectedRegion> overlaps; boolean foundregions = false;
List<ProtectedRegion> overlaps;
boolean foundregions = false;
try {
overlaps = region.getIntersectingRegions(allregionslist); if (overlaps == null || overlaps.isEmpty()) {
overlaps = region.getIntersectingRegions(allregionslist);
if (overlaps == null || overlaps.isEmpty()) {
foundregions = false;
} else {
foundregions = true;