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,7 +53,11 @@ public class Worldguard {
// True: PVP is allowed
// False: PVP is disallowed
public static boolean isPVP(Player player) {
if(isEnabled()) {
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);
@ -61,10 +65,6 @@ public class Worldguard {
RegionManager regionManager = wg.getRegionManager(world);
ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
return set.allows(DefaultFlag.PVP);
} else {
// No WG hooks so we'll always bypass this check.
return true;
}
}
// Check for Regions in chunk the chunk
@ -72,11 +72,15 @@ public class Worldguard {
// True: Regions found within chunk
// False: No regions found within chunk
public static boolean checkForRegionsInChunk(Location loc) {
if(isEnabled()) {
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() * 16;
int minChunkZ = chunk.getZ() * 16;
int minChunkX = chunk.getX() << 4;
int minChunkZ = chunk.getZ() << 4;
int maxChunkX = minChunkX + 15;
int maxChunkZ = minChunkZ + 15;
@ -94,7 +98,7 @@ public class Worldguard {
try {
overlaps = region.getIntersectingRegions(allregionslist);
if(overlaps.isEmpty() || overlaps == null) {
if(overlaps == null || overlaps.isEmpty()) {
foundregions = false;
} else {
foundregions = true;
@ -108,8 +112,5 @@ public class Worldguard {
overlaps = null;
return foundregions;
} else {
return false;
}
}
}

View File

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