55import dev .frankheijden .insights .api .addons .Region ;
66import dev .frankheijden .insights .api .objects .chunk .ChunkLocation ;
77import dev .frankheijden .insights .api .objects .chunk .ChunkPart ;
8+ import me .angeschossen .lands .api .LandsIntegration ;
89import me .angeschossen .lands .api .events .ChunkDeleteEvent ;
910import me .angeschossen .lands .api .events .ChunkPostClaimEvent ;
10- import me .angeschossen .lands .api .integration .LandsIntegration ;
1111import me .angeschossen .lands .api .land .ChunkCoordinate ;
12+ import me .angeschossen .lands .api .land .Container ;
1213import me .angeschossen .lands .api .land .Land ;
1314import org .bukkit .Location ;
1415import org .bukkit .World ;
@@ -26,19 +27,23 @@ public class LandsAddon implements InsightsAddon, Listener {
2627 private final LandsIntegration integration ;
2728
2829 public LandsAddon () {
29- this .integration = new LandsIntegration (InsightsPlugin .getInstance ());
30+ this .integration = LandsIntegration . of (InsightsPlugin .getInstance ());
3031 }
3132
3233 public String getKey (Land land , World world ) {
33- return land .getId () + "-" + world .getName ();
34+ return land .getULID (). toString () + "-" + world .getName ();
3435 }
3536
3637 public Optional <Region > adapt (Land land , World world ) {
3738 if (land == null ) return Optional .empty ();
3839
39- Collection <ChunkCoordinate > coordinates = land .getChunks (world );
40- if (coordinates == null || coordinates .isEmpty ()) return Optional .empty ();
41- return Optional .of (new LandsRegion (coordinates , getKey (land , world )));
40+ Container container = land .getContainer (world );
41+ if (container == null ) return Optional .empty ();
42+
43+ Collection <? extends ChunkCoordinate > coordinates = container .getChunks ();
44+ if (coordinates .isEmpty ()) return Optional .empty ();
45+
46+ return Optional .of (new LandsRegion (world , coordinates , getKey (land , world )));
4247 }
4348
4449 @ Override
@@ -58,7 +63,7 @@ public String getVersion() {
5863
5964 @ Override
6065 public Optional <Region > getRegion (Location location ) {
61- return adapt (integration .getLand (
66+ return adapt (integration .getLandByChunk (
6267 location .getWorld (),
6368 location .getBlockX () >> 4 ,
6469 location .getBlockZ () >> 4
@@ -81,10 +86,12 @@ private void clearLandCache(Land land, World world) {
8186
8287 public class LandsRegion implements Region {
8388
84- private final Collection <ChunkCoordinate > coordinates ;
89+ private final World world ;
90+ private final Collection <? extends ChunkCoordinate > coordinates ;
8591 private final String key ;
8692
87- public LandsRegion (Collection <ChunkCoordinate > coordinates , String key ) {
93+ public LandsRegion (World world , Collection <? extends ChunkCoordinate > coordinates , String key ) {
94+ this .world = world ;
8895 this .coordinates = coordinates ;
8996 this .key = key ;
9097 }
@@ -103,7 +110,7 @@ public String getKey() {
103110 public List <ChunkPart > toChunkParts () {
104111 List <ChunkPart > parts = new ArrayList <>(coordinates .size ());
105112 for (ChunkCoordinate coordinate : coordinates ) {
106- parts .add (new ChunkPart (new ChunkLocation (coordinate . getWorld () , coordinate .getX (), coordinate .getZ ())));
113+ parts .add (new ChunkPart (new ChunkLocation (world , coordinate .getX (), coordinate .getZ ())));
107114 }
108115 return parts ;
109116 }
0 commit comments