minor cleanup and tweaks to WorldGuard code
added/updated libs
This commit is contained in:
parent
f9cb5014dc
commit
120039b07f
BIN
lib/SpoutAPI.jar
BIN
lib/SpoutAPI.jar
Binary file not shown.
BIN
lib/WorldEdit.jar
Normal file
BIN
lib/WorldEdit.jar
Normal file
Binary file not shown.
BIN
lib/WorldGuard.jar
Normal file
BIN
lib/WorldGuard.jar
Normal file
Binary file not shown.
@ -63,7 +63,7 @@ public class Conf {
|
|||||||
|
|
||||||
public static double autoLeaveAfterDaysOfInactivity = 14.0;
|
public static double autoLeaveAfterDaysOfInactivity = 14.0;
|
||||||
|
|
||||||
public static boolean worldGuardChecking = true;
|
public static boolean worldGuardChecking = false;
|
||||||
|
|
||||||
public static boolean homesEnabled = true;
|
public static boolean homesEnabled = true;
|
||||||
public static boolean homesMustBeInClaimedTerritory = true;
|
public static boolean homesMustBeInClaimedTerritory = true;
|
||||||
|
@ -7,6 +7,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@ -505,10 +506,11 @@ public class FPlayer {
|
|||||||
// return value is false on failure, true on success
|
// return value is false on failure, true on success
|
||||||
|
|
||||||
Faction myFaction = getFaction();
|
Faction myFaction = getFaction();
|
||||||
FLocation flocation = new FLocation(this);
|
Location loc = this.getPlayer().getLocation();
|
||||||
|
FLocation flocation = new FLocation(loc);
|
||||||
Faction otherFaction = Board.getFactionAt(flocation);
|
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
|
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||||
sendMessage("This land is protected");
|
sendMessage("This land is protected");
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,11 +36,11 @@ public class Worldguard {
|
|||||||
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
|
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
wg = null;
|
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 {
|
} else {
|
||||||
wg = (WorldGuardPlugin) wgplug;
|
wg = (WorldGuardPlugin) wgplug;
|
||||||
enabled = true;
|
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
|
// True: PVP is allowed
|
||||||
// False: PVP is disallowed
|
// False: PVP is disallowed
|
||||||
public static boolean isPVP(Player player) {
|
public static boolean isPVP(Player player) {
|
||||||
if(isEnabled()) {
|
if(!enabled) {
|
||||||
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 {
|
|
||||||
// No WG hooks so we'll always bypass this check.
|
// No WG hooks so we'll always bypass this check.
|
||||||
return true;
|
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
|
// Check for Regions in chunk the chunk
|
||||||
@ -72,44 +72,45 @@ public class Worldguard {
|
|||||||
// True: Regions found within chunk
|
// True: Regions found within chunk
|
||||||
// False: No regions found within chunk
|
// False: No regions found within chunk
|
||||||
public static boolean checkForRegionsInChunk(Location loc) {
|
public static boolean checkForRegionsInChunk(Location loc) {
|
||||||
if(isEnabled()) {
|
if(!enabled) {
|
||||||
World world = loc.getWorld();
|
// No WG hooks so we'll always bypass this check.
|
||||||
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 {
|
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,9 +9,12 @@ softdepend:
|
|||||||
- iChat
|
- iChat
|
||||||
- LocalAreaChat
|
- LocalAreaChat
|
||||||
- nChat
|
- nChat
|
||||||
|
- ChatManager
|
||||||
- AuthMe
|
- AuthMe
|
||||||
- iConomy
|
- iConomy
|
||||||
- Spout
|
- Spout
|
||||||
|
- WorldEdit
|
||||||
|
- WorldGuard
|
||||||
commands:
|
commands:
|
||||||
f:
|
f:
|
||||||
description: All of the Factions commands
|
description: All of the Factions commands
|
||||||
|
Loading…
Reference in New Issue
Block a user