mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-12-03 15:43:24 +01:00
Merge pull request #904 from markhughes/1.6.x
Allow using FLocation object in canClaimForFactionAtLocation
This commit is contained in:
commit
c30137c34d
@ -1,5 +1,6 @@
|
||||
package com.massivecraft.factions.integration;
|
||||
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
@ -91,14 +92,26 @@ public class Worldguard {
|
||||
// Returns:
|
||||
// True: Regions found within chunk
|
||||
// False: No regions found within chunk
|
||||
|
||||
public static boolean checkForRegionsInChunk(FLocation floc) {
|
||||
Chunk chunk = floc.getWorld().getChunkAt((int) floc.getX(), (int) floc.getZ());
|
||||
|
||||
return checkForRegionsInChunk(chunk);
|
||||
}
|
||||
|
||||
public static boolean checkForRegionsInChunk(Location loc) {
|
||||
Chunk chunk = loc.getWorld().getChunkAt(loc);
|
||||
|
||||
return checkForRegionsInChunk(chunk);
|
||||
}
|
||||
|
||||
public static boolean checkForRegionsInChunk(Chunk chunk) {
|
||||
if (!enabled) {
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = loc.getWorld();
|
||||
Chunk chunk = world.getChunkAt(loc);
|
||||
World world = chunk.getWorld();
|
||||
int minChunkX = chunk.getX() << 4;
|
||||
int minChunkZ = chunk.getZ() << 4;
|
||||
int maxChunkX = minChunkX + 15;
|
||||
|
@ -686,17 +686,21 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
public boolean canClaimForFaction(Faction forFaction) {
|
||||
return this.isAdminBypassing() || !forFaction.isWilderness() && (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR)) || (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) || (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()));
|
||||
}
|
||||
|
||||
public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure) {
|
||||
String error = null;
|
||||
FLocation flocation = new FLocation(location);
|
||||
|
||||
return canClaimForFactionAtLocation(forFaction, flocation, notifyFailure);
|
||||
}
|
||||
|
||||
public boolean canClaimForFactionAtLocation(Faction forFaction, FLocation flocation, boolean notifyFailure) {
|
||||
String error = null;
|
||||
Faction myFaction = getFaction();
|
||||
Faction currentFaction = Board.getInstance().getFactionAt(flocation);
|
||||
int ownedLand = forFaction.getLandRounded();
|
||||
int factionBuffer = P.p.getConfig().getInt("hcf.buffer-zone", 0);
|
||||
int worldBuffer = P.p.getConfig().getInt("world-border.buffer", 0);
|
||||
|
||||
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) {
|
||||
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(flocation)) {
|
||||
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||
error = P.p.txt.parse(TL.CLAIM_PROTECTED.toString());
|
||||
} else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
|
||||
|
Loading…
Reference in New Issue
Block a user