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