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

import com.cjburkey.claimchunk.Utils;
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) {
        boolean nearClaimed = false;

        for(int x1 = -1; x1 < 2; x1++) {
            for(int z1 = -1; z1 < 2; z1++) {
                if(nearClaimed) break;
                System.out.println(data.claimChunk.getChunkHandler().getOwner(data.player.getWorld(), x1 + data.chunk.getX(), z1 + data.chunk.getZ()) == data.player.getUniqueId());
                System.out.println(data.claimChunk.getChunkHandler().getOwner(data.player.getWorld(), x1 + data.chunk.getX(), z1 + data.chunk.getZ()));
                System.out.println(data.player.getUniqueId());
                
                if(data.claimChunk.getChunkHandler().getOwner(data.player.getWorld(), x1 + data.chunk.getX(), z1 + data.chunk.getZ()) == data.player.getUniqueId()) continue;
                nearClaimed = data.claimChunk.getChunkHandler().isClaimed(data.chunk.getWorld().getChunkAt(x1 + data.chunk.getX(), z1 + data.chunk.getZ()));
            }
        }

        return !nearClaimed;
    }

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

@@ -86,16 +86,41 @@
 .Utils;%0A
+import org.bukkit.Chunk;%0A
 import o
@@ -153,16 +153,16 @@
 otNull;%0A
-
 %0Aimport 
@@ -545,16 +545,17 @@
  break;%0A
+%0A
         
@@ -566,46 +566,36 @@
     
-System.out.println(
+Chunk chunk = 
 data.c
-laimC
 hunk.get
 Chun
@@ -594,56 +594,27 @@
 .get
-ChunkHandler().getOwner(data.player.getWorld(), 
+World().getChunkAt(
 x1 +
@@ -660,38 +660,8 @@
 Z())
- == data.player.getUniqueId())
 ;%0A  
@@ -731,170 +731,38 @@
 r().
-get
+is
 Owner(
-data.player.getWorld(), x1 + data.chunk.getX(), z1 + data.chunk.getZ()));%0A                System.out.println(data.player.getUniqueId());%0A                
+chunk, data.player));%0A
 %0A   
@@ -815,17 +815,23 @@
 r().
-get
+is
 Owner(
+chunk, 
 data
@@ -841,96 +841,8 @@
 ayer
-.getWorld(), x1 + data.chunk.getX(), z1 + data.chunk.getZ()) == data.player.getUniqueId(
 )) c

Update NearChunkPrereq.java