minor cleanup and tweaks to WorldGuard code

added/updated libs
This commit is contained in:
Brettflan 2011-09-08 06:24:55 -05:00
parent f9cb5014dc
commit 120039b07f
7 changed files with 57 additions and 51 deletions

Binary file not shown.

BIN
lib/WorldEdit.jar Normal file

Binary file not shown.

BIN
lib/WorldGuard.jar Normal file

Binary file not shown.

View File

@ -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;

View File

@ -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;

View File

@ -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<String, ProtectedRegion> allregions = regionManager.getRegions();
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
List<ProtectedRegion> 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<String, ProtectedRegion> allregions = regionManager.getRegions();
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
List<ProtectedRegion> 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;
}
}

View File

@ -9,9 +9,12 @@ softdepend:
- iChat
- LocalAreaChat
- nChat
- ChatManager
- AuthMe
- iConomy
- Spout
- WorldEdit
- WorldGuard
commands:
f:
description: All of the Factions commands