Prevent claiming outside of the worldborder

This commit is contained in:
destro174 2022-04-15 09:37:58 +02:00
parent 35e82c7332
commit c82e5c586d
2 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
@ -767,4 +768,10 @@ public class Claim
}
return true;
}
public boolean isInsideBorder() {
WorldBorder worldBorder = this.getLesserBoundaryCorner().getWorld().getWorldBorder();
return worldBorder.isInside(this.lesserBoundaryCorner) && worldBorder.isInside(this.greaterBoundaryCorner);
}
}

View File

@ -965,6 +965,13 @@ public abstract class DataStore
return result;
}
if (creatingPlayer != null && newClaim.isInsideBorder()) {
result.succeeded = false;
result.claim = null;
creatingPlayer.sendMiniMessage("<red>You can't claim outside of the worldborder", null); // TODO MINIMESSAG + CONFIG
return result;
}
//if worldguard is installed, also prevent claims from overlapping any worldguard regions
if (GriefPrevention.instance.config_claims_respectWorldGuard && this.worldGuard != null && creatingPlayer != null)
{