use of com.wasteofplastic.acidisland.util.Pair in project acidisland by tastybento.
the class SafeSpotTeleport method getChunksToScan.
/**
* Gets a set of chunk coords that will be scanned.
* @param entity
* @param location
* @return
*/
private List<Pair<Integer, Integer>> getChunksToScan() {
List<Pair<Integer, Integer>> result = new ArrayList<>();
// Get island if available
Island island = plugin.getGrid().getIslandAt(location);
int maxRadius = island == null ? Settings.islandProtectionRange / 2 : island.getProtectionSize() / 2;
maxRadius = maxRadius > MAX_RADIUS ? MAX_RADIUS : maxRadius;
int x = location.getBlockX();
int z = location.getBlockZ();
// Create ever increasing squares around the target location
int radius = 0;
do {
for (int i = x - radius; i <= x + radius; i += 16) {
for (int j = z - radius; j <= z + radius; j += 16) {
addChunk(result, island, new Pair<>(i, j), new Pair<>(i / 16, j / 16));
}
}
radius++;
} while (radius < maxRadius);
return result;
}