package com.cjburkey.claimchunk.service.prereq.claim;

import org.jetbrains.annotations.NotNull;

import java.util.Optional;

public class NearChunkPrereq implements IClaimPrereq{
    @Override
    public int getWeight() {
        return 300;
    }

    @Override
    public boolean getPassed(@NotNull PrereqClaimData data) {
        System.out.println("Original " + data.chunk.getX());
        System.out.println("Original " + data.chunk.getZ());

        boolean safe = false;

        for(int x1 = -1; x1 < 1; x1++) {
            for(int z1 = -1; z1 < 1; z1++) {
                if(safe) break;
                safe = !data.claimChunk.getChunkHandler().isClaimed(data.chunk.getWorld().getChunkAt(x1 + data.chunk.getX(), z1 + data.chunk.getZ()));
                System.out.println("Chunk " + (x1 + data.chunk.getX()));
                System.out.println("Chunk " + (z1 + data.chunk.getZ()));
                System.out.println(safe);
            }
        }
        return safe;
    }

    @Override
    public Optional<String> getErrorMessage(@NotNull PrereqClaimData data) {
        return Optional.of("Too close to a chunk");
    }
}

@@ -458,20 +458,27 @@
 boolean 
-safe
+nearClaimed
  = false
@@ -585,20 +585,27 @@
      if(
-safe
+nearClaimed
 ) break;
@@ -625,16 +625,22 @@
     
-safe
+nearClaimed
  = 
-!
 data
@@ -943,20 +943,27 @@
 println(
-safe
+nearClaimed
 );%0A     
@@ -1000,12 +1000,20 @@
 urn 
-safe
+!nearClaimed
 ;%0A  

Update NearChunkPrereq.java