Skip to content

Commit e6aa4be

Browse files
authored
Merge pull request #3 from Angeschossen/master
Fix Lands Integration
2 parents b378689 + 72cf396 commit e6aa4be

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repositories {
1818
dependencies {
1919
compileOnly 'com.github.InsightsPlugin:Insights:feature~addons-SNAPSHOT'
2020
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
21-
compileOnly 'com.github.angeschossen:LandsAPI:5.1.13'
21+
compileOnly 'com.github.angeschossen:LandsAPI:7.1.12'
2222
}
2323

2424
blossom {

src/main/java/dev/frankheijden/insights/addons/lands/LandsAddon.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
import dev.frankheijden.insights.api.addons.Region;
66
import dev.frankheijden.insights.api.objects.chunk.ChunkLocation;
77
import dev.frankheijden.insights.api.objects.chunk.ChunkPart;
8+
import me.angeschossen.lands.api.LandsIntegration;
89
import me.angeschossen.lands.api.events.ChunkDeleteEvent;
910
import me.angeschossen.lands.api.events.ChunkPostClaimEvent;
10-
import me.angeschossen.lands.api.integration.LandsIntegration;
1111
import me.angeschossen.lands.api.land.ChunkCoordinate;
12+
import me.angeschossen.lands.api.land.Container;
1213
import me.angeschossen.lands.api.land.Land;
1314
import org.bukkit.Location;
1415
import 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

Comments
 (0)