Optional disabling of WG checks
This commit is contained in:
parent
8be43164d2
commit
445d10afb7
@ -63,6 +63,8 @@ public class Conf {
|
|||||||
|
|
||||||
public static double autoLeaveAfterDaysOfInactivity = 14.0;
|
public static double autoLeaveAfterDaysOfInactivity = 14.0;
|
||||||
|
|
||||||
|
public static boolean worldGuardChecking = true;
|
||||||
|
|
||||||
public static boolean homesEnabled = true;
|
public static boolean homesEnabled = true;
|
||||||
public static boolean homesMustBeInClaimedTerritory = true;
|
public static boolean homesMustBeInClaimedTerritory = true;
|
||||||
public static boolean homesTeleportToOnDeath = true;
|
public static boolean homesTeleportToOnDeath = true;
|
||||||
|
@ -151,6 +151,10 @@ public class Factions extends JavaPlugin {
|
|||||||
Econ.setup(this);
|
Econ.setup(this);
|
||||||
Econ.monitorPlugins();
|
Econ.monitorPlugins();
|
||||||
|
|
||||||
|
if(Conf.worldGuardChecking) {
|
||||||
|
Worldguard.init(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
PluginManager pm = this.getServer().getPluginManager();
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest, this);
|
||||||
|
@ -35,11 +35,11 @@ public class Worldguard {
|
|||||||
enabled = false;
|
enabled = false;
|
||||||
wg = null;
|
wg = null;
|
||||||
System.out.println("[Factions] Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
System.out.println("[Factions] 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.");
|
System.out.println("[Factions] Successfully hooked to WorldGuard.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnabled() {
|
public static boolean isEnabled() {
|
||||||
@ -70,40 +70,44 @@ 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) {
|
||||||
int plocX = loc.getBlockX();
|
if(isEnabled()) {
|
||||||
int plocZ = loc.getBlockZ();
|
int plocX = loc.getBlockX();
|
||||||
World world = loc.getWorld();
|
int plocZ = loc.getBlockZ();
|
||||||
|
World world = loc.getWorld();
|
||||||
|
|
||||||
Chunk chunk = world.getChunkAt(plocX, plocZ);
|
Chunk chunk = world.getChunkAt(plocX, plocZ);
|
||||||
int chunkX = chunk.getX();
|
int chunkX = chunk.getX();
|
||||||
int chunkZ = chunk.getZ();
|
int chunkZ = chunk.getZ();
|
||||||
|
|
||||||
BlockVector minChunk = new BlockVector(chunkX, 0, chunkZ);
|
BlockVector minChunk = new BlockVector(chunkX, 0, chunkZ);
|
||||||
BlockVector maxChunk = new BlockVector(chunkX+15, 128, chunkZ+15);
|
BlockVector maxChunk = new BlockVector(chunkX+15, 128, chunkZ+15);
|
||||||
|
|
||||||
RegionManager regionManager = wg.getRegionManager(world);
|
RegionManager regionManager = wg.getRegionManager(world);
|
||||||
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
||||||
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
||||||
|
|
||||||
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
|
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
|
||||||
List<ProtectedRegion> overlaps;
|
List<ProtectedRegion> overlaps;
|
||||||
boolean foundregions = false;
|
boolean foundregions = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
overlaps = region.getIntersectingRegions(allregionslist);
|
overlaps = region.getIntersectingRegions(allregionslist);
|
||||||
if(overlaps.isEmpty() || overlaps == null) {
|
if(overlaps.isEmpty() || overlaps == null) {
|
||||||
foundregions = false;
|
foundregions = false;
|
||||||
} else {
|
} else {
|
||||||
foundregions = true;
|
foundregions = true;
|
||||||
|
}
|
||||||
|
} catch (UnsupportedIntersectionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (UnsupportedIntersectionException e) {
|
|
||||||
e.printStackTrace();
|
region = null;
|
||||||
|
allregionslist = null;
|
||||||
|
overlaps = null;
|
||||||
|
|
||||||
|
return foundregions;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
region = null;
|
|
||||||
allregionslist = null;
|
|
||||||
overlaps = null;
|
|
||||||
|
|
||||||
return foundregions;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user