package me.lethunderhawk.clans.claim; import org.bukkit.Location; import java.util.Map; import java.util.UUID; public class Claim { private final UUID clanId; // or clan name if you don’t have IDs private final String world; private final int minX, maxX; private final int minZ, maxZ; public Claim(UUID clanId, String world, int x1, int x2, int z1, int z2) { this.clanId = clanId; this.world = world; this.minX = Math.min(x1, x2); this.maxX = Math.max(x1, x2); this.minZ = Math.min(z1, z2); this.maxZ = Math.max(z1, z2); } public static Claim fromMap(UUID clanId, Map map) { String world = (String) map.get("world"); if (world == null) return null; int minX = ((Number) map.get("minX")).intValue(); int maxX = ((Number) map.get("maxX")).intValue(); int minZ = ((Number) map.get("minZ")).intValue(); int maxZ = ((Number) map.get("maxZ")).intValue(); return new Claim(clanId, world, minX, maxX, minZ, maxZ); } public boolean contains(Location loc) { if (!loc.getWorld().getName().equals(world)) return false; int x = loc.getBlockX(); int z = loc.getBlockZ(); return x >= minX && x <= maxX && z >= minZ && z <= maxZ; } public int getVolume() { return (maxX - minX + 1) * (maxZ - minZ + 1); } public UUID getClanId(){ return clanId; } public String getWorld() { return world; } public int getMinX() { return minX; } public int getMinZ() { return minZ; } public int getMaxX() { return maxX; } public int getMaxZ() { return maxZ; } }