Handle buffers
This commit is contained in:
parent
5a9112ad37
commit
d69f9e5688
@ -46,7 +46,7 @@ public abstract class Board {
|
|||||||
public abstract boolean isConnectedLocation(FLocation flocation, Faction faction);
|
public abstract boolean isConnectedLocation(FLocation flocation, Faction faction);
|
||||||
|
|
||||||
// Is this location outside the world border?
|
// Is this location outside the world border?
|
||||||
public abstract boolean isOutsideWorldBorder(FLocation flocation);
|
public abstract boolean isOutsideWorldBorder(FLocation flocation, int buffer);
|
||||||
|
|
||||||
public abstract boolean hasFactionWithin(FLocation flocation, Faction faction, int radius);
|
public abstract boolean hasFactionWithin(FLocation flocation, Faction faction, int radius);
|
||||||
|
|
||||||
|
@ -134,14 +134,14 @@ public abstract class MemoryBoard extends Board {
|
|||||||
* @param flocation claim chunk
|
* @param flocation claim chunk
|
||||||
* @return if claim chunk is outside world border
|
* @return if claim chunk is outside world border
|
||||||
*/
|
*/
|
||||||
public boolean isOutsideWorldBorder(FLocation flocation) {
|
public boolean isOutsideWorldBorder(FLocation flocation, int buffer) {
|
||||||
World world = flocation.getWorld();
|
World world = flocation.getWorld();
|
||||||
WorldBorder border = world.getWorldBorder();
|
WorldBorder border = world.getWorldBorder();
|
||||||
Chunk chunk = border.getCenter().getChunk();
|
Chunk chunk = border.getCenter().getChunk();
|
||||||
int lim = FLocation.blockToChunk((int) border.getSize());
|
int lim = FLocation.chunkToRegion((int) border.getSize()) - buffer;
|
||||||
int diffX = (int) Math.abs(chunk.getX() - flocation.getX());
|
int diffX = (int) Math.abs(chunk.getX() - flocation.getX());
|
||||||
int diffZ = (int) Math.abs(chunk.getZ() - flocation.getZ());
|
int diffZ = (int) Math.abs(chunk.getZ() - flocation.getZ());
|
||||||
return diffX + diffZ > lim;
|
return diffX > lim || diffZ > lim;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -658,7 +658,8 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
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 buffer = 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);
|
||||||
|
|
||||||
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) {
|
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) {
|
||||||
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||||
@ -695,10 +696,14 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
} else {
|
} else {
|
||||||
error = P.p.txt.parse(TL.CLAIM_FACTIONCONTIGUOUS.toString());
|
error = P.p.txt.parse(TL.CLAIM_FACTIONCONTIGUOUS.toString());
|
||||||
}
|
}
|
||||||
} else if (buffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, buffer)) {
|
} else if (factionBuffer > 0 && Board.getInstance().hasFactionWithin(flocation, myFaction, factionBuffer)) {
|
||||||
error = P.p.txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(buffer));
|
error = P.p.txt.parse(TL.CLAIM_TOOCLOSETOOTHERFACTION.format(factionBuffer));
|
||||||
} else if (Board.getInstance().isOutsideWorldBorder(flocation)) {
|
} else if (Board.getInstance().isOutsideWorldBorder(flocation, worldBuffer)) {
|
||||||
|
if(worldBuffer > 0) {
|
||||||
|
error = P.p.txt.parse(TL.CLAIM_OUTSIDEBORDERBUFFER.format(worldBuffer));
|
||||||
|
} else {
|
||||||
error = P.p.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
|
error = P.p.txt.parse(TL.CLAIM_OUTSIDEWORLDBORDER.toString());
|
||||||
|
}
|
||||||
} else if (currentFaction.isNormal()) {
|
} else if (currentFaction.isNormal()) {
|
||||||
if (myFaction.isPeaceful()) {
|
if (myFaction.isPeaceful()) {
|
||||||
error = P.p.txt.parse(TL.CLAIM_PEACEFUL.toString(), currentFaction.getTag(this));
|
error = P.p.txt.parse(TL.CLAIM_PEACEFUL.toString(), currentFaction.getTag(this));
|
||||||
|
@ -538,8 +538,8 @@ public enum TL {
|
|||||||
CLAIM_CLAIMEDLOG("%s claimed land at (%s) for the faction: %s"),
|
CLAIM_CLAIMEDLOG("%s claimed land at (%s) for the faction: %s"),
|
||||||
CLAIM_OVERCLAIM_DISABLED("<i>Over claiming is disabled on this server."),
|
CLAIM_OVERCLAIM_DISABLED("<i>Over claiming is disabled on this server."),
|
||||||
CLAIM_TOOCLOSETOOTHERFACTION("<i>Your claim is too close to another Faction. Buffer required is %d"),
|
CLAIM_TOOCLOSETOOTHERFACTION("<i>Your claim is too close to another Faction. Buffer required is %d"),
|
||||||
CLAIM_OUTSIDEWORLDBORDER("<i>Your claim is outside the border. Buffer is %d chunks from world edge."),
|
CLAIM_OUTSIDEWORLDBORDER("<i>Your claim is outside the border."),
|
||||||
|
CLAIM_OUTSIDEBORDERBUFFER("<i>Your claim is outside the border. %d chunks away world edge required."),
|
||||||
/**
|
/**
|
||||||
* More generic, or less easily categorisable translations, which may apply to more than one class
|
* More generic, or less easily categorisable translations, which may apply to more than one class
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user