package com.xfestudio.xfeservermanager.core.governance.claim;
import java.util.Locale;
public record ChunkKey(String dimensionId, int x, int z) {
public ChunkKey {
if (dimensionId == null || dimensionId.isBlank()) {
throw new IllegalArgumentException("dimensionId must be a namespaced identifier");
}
dimensionId = dimensionId.trim().toLowerCase(Locale.ROOT);
if (!dimensionId.matches("[a-z0-9_.-]+:[a-z0-9_./-]+")) {
throw new IllegalArgumentException("dimensionId must be a namespaced identifier");
}
}
public boolean cardinallyAdjacent(ChunkKey other) {
return dimensionId.equals(other.dimensionId)
&& Math.abs((long) x - other.x) + Math.abs((long) z - other.z) == 1;
}
}
package com.xfestudio.xfeservermanager.core.governance.claim;
import java.util.Locale;
public record ChunkKey(String dimensionId, int x, int z) {
public ChunkKey {
if (dimensionId == null || dimensionId.isBlank()) {
throw new IllegalArgumentException("dimensionId must be a namespaced identifier");
}
dimensionId = dimensionId.trim().toLowerCase(Locale.ROOT);
if (!dimensionId.matches("[a-z0-9_.-]+:[a-z0-9_./-]+")) {
throw new IllegalArgumentException("dimensionId must be a namespaced identifier");
}
}
public boolean cardinallyAdjacent(ChunkKey other) {
return dimensionId.equals(other.dimensionId)
&& Math.abs((long) x - other.x) + Math.abs((long) z - other.z) == 1;
}
}