diff --git a/lib/SpoutAPI.jar b/lib/SpoutAPI.jar index ffa25c34..0c07893d 100644 Binary files a/lib/SpoutAPI.jar and b/lib/SpoutAPI.jar differ diff --git a/lib/WorldEdit.jar b/lib/WorldEdit.jar new file mode 100644 index 00000000..7a976aae Binary files /dev/null and b/lib/WorldEdit.jar differ diff --git a/lib/WorldGuard.jar b/lib/WorldGuard.jar new file mode 100644 index 00000000..fb4bea33 Binary files /dev/null and b/lib/WorldGuard.jar differ diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index 6c75eda9..ff0664ce 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -63,7 +63,7 @@ public class Conf { public static double autoLeaveAfterDaysOfInactivity = 14.0; - public static boolean worldGuardChecking = true; + public static boolean worldGuardChecking = false; public static boolean homesEnabled = true; public static boolean homesMustBeInClaimedTerritory = true; diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index ccb5382c..8e1ac0b3 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -7,6 +7,7 @@ import java.util.logging.Level; import java.util.Map.Entry; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.entity.Player; import com.google.gson.reflect.TypeToken; @@ -505,10 +506,11 @@ public class FPlayer { // return value is false on failure, true on success Faction myFaction = getFaction(); - FLocation flocation = new FLocation(this); + Location loc = this.getPlayer().getLocation(); + FLocation flocation = new FLocation(loc); Faction otherFaction = Board.getFactionAt(flocation); - if (Worldguard.checkForRegionsInChunk(this.getPlayer().getLocation())) { + if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(loc)) { // Checks for WorldGuard regions in the chunk attempting to be claimed sendMessage("This land is protected"); return false; diff --git a/src/com/massivecraft/factions/Worldguard.java b/src/com/massivecraft/factions/Worldguard.java index 00750983..adb79b91 100644 --- a/src/com/massivecraft/factions/Worldguard.java +++ b/src/com/massivecraft/factions/Worldguard.java @@ -36,11 +36,11 @@ public class Worldguard { if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) { enabled = false; wg = null; - System.out.println("[Factions] Could not hook to WorldGuard. WorldGuard checks are disabled."); + Factions.log("Could not hook to WorldGuard. WorldGuard checks are disabled."); } else { wg = (WorldGuardPlugin) wgplug; enabled = true; - System.out.println("[Factions] Successfully hooked to WorldGuard."); + Factions.log("Successfully hooked to WorldGuard."); } } @@ -53,18 +53,18 @@ public class Worldguard { // True: PVP is allowed // False: PVP is disallowed public static boolean isPVP(Player player) { - if(isEnabled()) { - 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); - } else { + if(!enabled) { // No WG hooks so we'll always bypass this check. return true; } + + 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); } // Check for Regions in chunk the chunk @@ -72,44 +72,45 @@ public class Worldguard { // True: Regions found within chunk // False: No regions found within chunk public static boolean checkForRegionsInChunk(Location loc) { - if(isEnabled()) { - World world = loc.getWorld(); - Chunk chunk = world.getChunkAt(loc); - int minChunkX = chunk.getX() * 16; - int minChunkZ = chunk.getZ() * 16; - int maxChunkX = minChunkX + 15; - int maxChunkZ = minChunkZ + 15; - - int worldHeight = world.getMaxHeight(); // Allow for heights other than default - - BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ); - BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ); - - RegionManager regionManager = wg.getRegionManager(world); - ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk); - Map allregions = regionManager.getRegions(); - List allregionslist = new ArrayList(allregions.values()); - List overlaps; - boolean foundregions = false; - - try { - overlaps = region.getIntersectingRegions(allregionslist); - if(overlaps.isEmpty() || overlaps == null) { - foundregions = false; - } else { - foundregions = true; - } - } catch (UnsupportedIntersectionException e) { - e.printStackTrace(); - } - - region = null; - allregionslist = null; - overlaps = null; - - return foundregions; - } else { + if(!enabled) { + // No WG hooks so we'll always bypass this check. 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; + + int worldHeight = world.getMaxHeight(); // Allow for heights other than default + + BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ); + BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ); + + RegionManager regionManager = wg.getRegionManager(world); + ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk); + Map allregions = regionManager.getRegions(); + List allregionslist = new ArrayList(allregions.values()); + List overlaps; + boolean foundregions = false; + + try { + overlaps = region.getIntersectingRegions(allregionslist); + if(overlaps == null || overlaps.isEmpty()) { + foundregions = false; + } else { + foundregions = true; + } + } catch (UnsupportedIntersectionException e) { + e.printStackTrace(); + } + + region = null; + allregionslist = null; + overlaps = null; + + return foundregions; } } \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 3116ae99..a6eed97c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -9,9 +9,12 @@ softdepend: - iChat - LocalAreaChat - nChat + - ChatManager - AuthMe - iConomy - Spout + - WorldEdit + - WorldGuard commands: f: description: All of the Factions commands