From 84e4ada2103fbd6c1ea870cb87bb6b81388ff920 Mon Sep 17 00:00:00 2001 From: James-P-Bennett Date: Wed, 12 Nov 2025 20:57:40 -0600 Subject: [PATCH 1/3] Squaremap Support --- src/main/java/fr/xyness/SCS/ClaimMain.java | 10 +- .../java/fr/xyness/SCS/SimpleClaimSystem.java | 38 ++- .../fr/xyness/SCS/Support/ClaimSquaremap.java | 318 ++++++++++++++++++ src/main/resources/config.yml | 7 + 4 files changed, 367 insertions(+), 6 deletions(-) create mode 100644 src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java diff --git a/src/main/java/fr/xyness/SCS/ClaimMain.java b/src/main/java/fr/xyness/SCS/ClaimMain.java index a26bcb2..306a983 100644 --- a/src/main/java/fr/xyness/SCS/ClaimMain.java +++ b/src/main/java/fr/xyness/SCS/ClaimMain.java @@ -1681,7 +1681,7 @@ public void transferClaims() { } boolean check = false; - boolean check2 = false; + boolean check2 = false; HikariConfig localConfig = new HikariConfig(); localConfig.setJdbcUrl("jdbc:sqlite:plugins/SimpleClaimSystem/storage.db"); localConfig.setDriverClassName("org.sqlite.JDBC"); @@ -2200,6 +2200,7 @@ public CompletableFuture createClaim(Player player, Chunk chunk) { if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().createClaimZone(newClaim); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().createClaimZone(newClaim); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().createClaimZone(newClaim); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().createClaimZone(newClaim); if (instance.getSettings().getBooleanSetting("keep-chunks-loaded")) { if(instance.isFolia()) { Bukkit.getRegionScheduler().execute(instance, chunk.getWorld(), chunk.getX(), chunk.getZ(), () -> chunk.setForceLoaded(true)); @@ -2282,6 +2283,7 @@ public CompletableFuture createAdminClaim(Player player, Chunk chunk) { if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().createClaimZone(newClaim); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().createClaimZone(newClaim); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().createClaimZone(newClaim); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().createClaimZone(newClaim); if (instance.getSettings().getBooleanSetting("keep-chunks-loaded")) { if(instance.isFolia()) { Bukkit.getRegionScheduler().execute(instance, chunk.getWorld(), chunk.getX(), chunk.getZ(), () -> chunk.setForceLoaded(true)); @@ -3213,7 +3215,8 @@ public CompletableFuture setClaimName(Claim claim, String name) { if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().updateName(claim); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().updateName(claim); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().updateName(claim); - + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().updateName(claim); + // Update database try (Connection connection = instance.getDataSource().getConnection()) { String updateQuery = "UPDATE scs_claims_1 SET claim_name = ? WHERE owner_uuid = ? AND claim_name = ?"; @@ -3291,6 +3294,7 @@ public CompletableFuture deleteClaim(Claim claim) { if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().deleteMarker(chunks); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().deleteMarker(chunks); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().deleteMarker(chunks); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().deleteMarker(claim); chunks.stream().forEach(c -> listClaims.remove(c)); resetWeatherChunk(claim); resetFlyChunk(claim); @@ -3361,6 +3365,7 @@ public CompletableFuture deleteAllClaims(String owner) { if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().deleteMarker(chunks); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().deleteMarker(chunks); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().deleteMarker(chunks); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().deleteMarker(claim); chunks.stream().forEach(c -> listClaims.remove(c)); updateWeatherChunk(claim); updateFlyChunk(claim); @@ -4109,6 +4114,7 @@ public CompletableFuture addClaimChunk(Claim claim, Chunk chunk){ if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().createClaimZone(claim); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().createClaimZone(claim); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().createClaimZone(claim); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().createClaimZone(claim); instance.executeSync(() -> instance.getBossBars().activateBossBar(Set.of(chunk))); updateWeatherChunk(claim); updateFlyChunk(claim); diff --git a/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java b/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java index 8e19d69..0cc1b99 100644 --- a/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java +++ b/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java @@ -80,7 +80,10 @@ public class SimpleClaimSystem extends JavaPlugin { /** Instance of ClaimPl3xMap for Pl3xmap integration */ private ClaimPl3xMap pl3xmapInstance; - + + /** Instance of ClaimSquaremap for Squaremap integration */ + private ClaimSquaremap squaremapInstance; + /** Instance of ClaimWorldguard for WorldGuard integration */ private ClaimWorldGuard claimWorldguardInstance; @@ -329,6 +332,13 @@ public boolean loadConfig(boolean reload, CommandSender sender) { claimSettingsInstance.addSetting("pl3xmap", "false"); } + Plugin squaremap = Bukkit.getPluginManager().getPlugin("squaremap"); + if (squaremap != null) { + claimSettingsInstance.addSetting("squaremap", "true"); + } else { + claimSettingsInstance.addSetting("squaremap", "false"); + } + // Check "langs" folder File dossier = new File(getDataFolder(), "langs"); if (!dossier.exists()) { @@ -635,7 +645,18 @@ public boolean loadConfig(boolean reload, CommandSender sender) { claimSettingsInstance.addSetting("pl3xmap-claim-border-color", getConfig().getString("pl3xmap-settings.claim-border-color")); claimSettingsInstance.addSetting("pl3xmap-claim-fill-color", getConfig().getString("pl3xmap-settings.claim-fill-color")); claimSettingsInstance.addSetting("pl3xmap-claim-hover-text", getConfig().getString("pl3xmap-settings.claim-hover-text")); - + + // Add Squaremap settings + configC = getConfig().getString("squaremap"); + if(configC.equalsIgnoreCase("true") && claimSettingsInstance.getBooleanSetting("squaremap")) { + if (!reload) squaremapInstance = new ClaimSquaremap(this); + } else { + claimSettingsInstance.addSetting("squaremap", "false"); + } + claimSettingsInstance.addSetting("squaremap-claim-border-color", getConfig().getString("squaremap-settings.claim-border-color")); + claimSettingsInstance.addSetting("squaremap-claim-fill-color", getConfig().getString("squaremap-settings.claim-fill-color")); + claimSettingsInstance.addSetting("squaremap-claim-hover-text", getConfig().getString("squaremap-settings.claim-hover-text")); + // Add the message type for protection configC = getConfig().getString("protection-message"); if (configC.equalsIgnoreCase("action_bar") || @@ -2122,13 +2143,22 @@ public ClaimBluemap getBluemap() { /** * Returns the ClaimPl3xMap instance. - * + * * @return The ClaimPl3xMap instance */ public ClaimPl3xMap getPl3xMap() { return pl3xmapInstance; } - + + /** + * Returns the ClaimSquaremap instance. + * + * @return The ClaimSquaremap instance + */ + public ClaimSquaremap getSquaremap() { + return squaremapInstance; + } + /** * Returns the ClaimPurge instance. * diff --git a/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java b/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java new file mode 100644 index 0000000..d131e6f --- /dev/null +++ b/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java @@ -0,0 +1,318 @@ +package fr.xyness.SCS.Support; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.World; + +import fr.xyness.SCS.SimpleClaimSystem; +import fr.xyness.SCS.Types.Claim; +import xyz.jpenilla.squaremap.api.BukkitAdapter; +import xyz.jpenilla.squaremap.api.Key; +import xyz.jpenilla.squaremap.api.Point; +import xyz.jpenilla.squaremap.api.SimpleLayerProvider; +import xyz.jpenilla.squaremap.api.Squaremap; +import xyz.jpenilla.squaremap.api.SquaremapProvider; +import xyz.jpenilla.squaremap.api.WorldIdentifier; +import xyz.jpenilla.squaremap.api.marker.Marker; +import xyz.jpenilla.squaremap.api.marker.MarkerOptions; +import xyz.jpenilla.squaremap.api.marker.Polygon; +import java.awt.Color; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.stream.Collectors; + +/** + * This class integrates claims with the Squaremap plugin, allowing claims to be displayed as markers on the Squaremap. + */ +public class ClaimSquaremap { + + + // *************** + // * Variables * + // *************** + + + // Store layer providers for each world + private final Map layerProviders = new HashMap<>(); + + /** Instance of SimpleClaimSystem */ + private final SimpleClaimSystem instance; + + /** Instance of Squaremap API */ + private final Squaremap squaremapApi; + + + // ****************** + // * Constructors * + // ****************** + + + /** + * Constructor for the ClaimSquaremap class. + * Initializes the layers for each world. + */ + public ClaimSquaremap(SimpleClaimSystem instance) { + this.instance = instance; + this.squaremapApi = SquaremapProvider.get(); + initialize(); + } + + + // ******************** + // * Other Methods * + // ******************** + + + /** + * Initializes the layers for each world and creates markers for all existing claims. + */ + private void initialize() { + instance.executeAsync(() -> { + Set claims = instance.getMain().getAllClaims(); + for (World world : Bukkit.getWorlds()) { + WorldIdentifier worldId = BukkitAdapter.worldIdentifier(world); + xyz.jpenilla.squaremap.api.MapWorld mapWorld = squaremapApi.getWorldIfEnabled(worldId).orElse(null); + + if (mapWorld != null) { + Key layerKey = Key.of("simpleclaimsystem_claims"); + SimpleLayerProvider provider = SimpleLayerProvider.builder("Claims") + .showControls(true) + .defaultHidden(false) + .layerPriority(1) + .zIndex(1) + .build(); + + mapWorld.layerRegistry().register(layerKey, provider); + layerProviders.put(world, provider); + + // Add existing claims to the map + for (Claim claim : claims) { + if (claim.getLocation().getWorld().equals(world)) { + createClaimZone(claim); + } + } + } + } + instance.getLogger().info("Claims added to Squaremap."); + }); + } + + + /** + * Creates a marker on the Squaremap for the specified claim. + * Uses rectangles without borders to avoid grid pattern. + * + * @param claim The claim to create the marker for. + */ + public void createClaimZone(Claim claim) { + if (claim.getChunks().isEmpty()) return; + + String hoverText = instance.getSettings().getSetting("squaremap-claim-hover-text") + .replace("%claim-name%", claim.getName()) + .replace("%owner%", claim.getOwner()); + + String fillColorHex = instance.getSettings().getSetting("squaremap-claim-fill-color"); + String strokeColorHex = instance.getSettings().getSetting("squaremap-claim-border-color"); + + // Parse hex colors to RGB integers + int fillColor = Integer.parseInt(fillColorHex, 16); + int strokeColor = Integer.parseInt(strokeColorHex, 16); + + // Get world from first chunk + World world = claim.getChunks().iterator().next().getWorld(); + SimpleLayerProvider layerProvider = layerProviders.get(world); + + if (layerProvider == null) { + // Create layer if it doesn't exist + WorldIdentifier worldId = BukkitAdapter.worldIdentifier(world); + xyz.jpenilla.squaremap.api.MapWorld mapWorld = squaremapApi.getWorldIfEnabled(worldId).orElse(null); + + if (mapWorld != null) { + Key layerKey = Key.of("simpleclaimsystem_claims"); + SimpleLayerProvider newProvider = SimpleLayerProvider.builder("Claims") + .showControls(true) + .defaultHidden(false) + .layerPriority(1) + .zIndex(1) + .build(); + + mapWorld.layerRegistry().register(layerKey, newProvider); + layerProviders.put(world, newProvider); + layerProvider = newProvider; + } + } + + if (layerProvider == null) return; + + final SimpleLayerProvider provider = layerProvider; + + // Remove old markers for this claim first + String claimMarkerId = "claim_" + claim.getId(); + provider.removeMarker(Key.of(claimMarkerId)); + + // Also remove old chunk-based markers for backwards compatibility + claim.getChunks().forEach(chunk -> { + String oldMarkerId = "chunk_" + chunk.getX() + "_" + chunk.getZ(); + provider.removeMarker(Key.of(oldMarkerId)); + String oldClaimChunkId = "claim_" + claim.getId() + "_chunk_" + chunk.getX() + "_" + chunk.getZ(); + provider.removeMarker(Key.of(oldClaimChunkId)); + }); + + // Create a merged polygon for all chunks with single outer border + List outerBoundary = calculateOuterBoundary(claim.getChunks()); + + if (!outerBoundary.isEmpty()) { + Marker marker = Polygon.polygon(outerBoundary) + .markerOptions( + MarkerOptions.builder() + .strokeColor(new Color(strokeColor)) + .strokeWeight(3) + .fillColor(new Color(fillColor)) + .fillOpacity(0.35) + .clickTooltip(hoverText) + .build() + ); + + provider.addMarker(Key.of(claimMarkerId), marker); + } + } + + /** + * Calculates the outer boundary of a set of chunks as a polygon. + * This creates a single outline around all connected chunks. + */ + private List calculateOuterBoundary(Set chunks) { + if (chunks.isEmpty()) return new ArrayList<>(); + + // Convert chunks to a set of coordinate pairs for easy lookup + java.util.Set chunkCoords = chunks.stream() + .map(c -> c.getX() + "," + c.getZ()) + .collect(Collectors.toSet()); + + // Collect all outer edges (edges that don't have an adjacent chunk) + List outerEdges = new ArrayList<>(); + + for (Chunk chunk : chunks) { + int cx = chunk.getX(); + int cz = chunk.getZ(); + int minX = cx * 16; + int minZ = cz * 16; + int maxX = minX + 16; + int maxZ = minZ + 16; + + // Check each of the 4 edges + // North edge (top) + if (!chunkCoords.contains((cx) + "," + (cz - 1))) { + outerEdges.add(new Edge(minX, minZ, maxX, minZ)); + } + // South edge (bottom) + if (!chunkCoords.contains((cx) + "," + (cz + 1))) { + outerEdges.add(new Edge(minX, maxZ, maxX, maxZ)); + } + // West edge (left) + if (!chunkCoords.contains((cx - 1) + "," + (cz))) { + outerEdges.add(new Edge(minX, minZ, minX, maxZ)); + } + // East edge (right) + if (!chunkCoords.contains((cx + 1) + "," + (cz))) { + outerEdges.add(new Edge(maxX, minZ, maxX, maxZ)); + } + } + + // Convert edges to points in order (trace the outline) + return traceOutline(outerEdges); + } + + /** + * Traces the outline from a collection of edges. + */ + private List traceOutline(List edges) { + if (edges.isEmpty()) return new ArrayList<>(); + + List points = new ArrayList<>(); + java.util.Set usedEdges = new HashSet<>(); + + // Start with the first edge + Edge currentEdge = edges.getFirst(); + points.add(Point.of(currentEdge.x1, currentEdge.z1)); + points.add(Point.of(currentEdge.x2, currentEdge.z2)); + usedEdges.add(currentEdge); + + // Find connected edges + while (usedEdges.size() < edges.size()) { + Point lastPoint = points.getLast(); + boolean found = false; + + for (Edge edge : edges) { + if (usedEdges.contains(edge)) continue; + + // Check if this edge connects to our current point + if (edge.x1 == lastPoint.x() && edge.z1 == lastPoint.z()) { + points.add(Point.of(edge.x2, edge.z2)); + usedEdges.add(edge); + found = true; + break; + } else if (edge.x2 == lastPoint.x() && edge.z2 == lastPoint.z()) { + points.add(Point.of(edge.x1, edge.z1)); + usedEdges.add(edge); + found = true; + break; + } + } + + if (!found) break; // Can't find more connected edges + } + + return points; + } + + /** + * Helper class to represent an edge. + */ + private record Edge(int x1, int z1, int x2, int z2) { + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Edge edge)) return false; + return x1 == edge.x1 && z1 == edge.z1 && x2 == edge.x2 && z2 == edge.z2; + } + + } + + /** + * Updates the tooltip name of the specified claim on the Squaremap. + * + * @param claim the claim to update the name for + */ + public void updateName(Claim claim) { + // Simply recreate the claim zone with updated information + createClaimZone(claim); + } + + /** + * Deletes the marker for the specified claim from the Squaremap. + * + * @param claim The claim to delete the marker for. + */ + public void deleteMarker(Claim claim) { + if (claim.getChunks().isEmpty()) return; + + World world = claim.getChunks().iterator().next().getWorld(); + SimpleLayerProvider provider = layerProviders.get(world); + + if (provider != null) { + // Remove all chunk markers for this claim + claim.getChunks().forEach(chunk -> { + String markerId = "claim_" + claim.getId() + "_chunk_" + chunk.getX() + "_" + chunk.getZ(); + provider.removeMarker(Key.of(markerId)); + }); + } + } + +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4a3b95c..d8d1ccd 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -203,6 +203,13 @@ pl3xmap-settings: claim-fill-color: A5A5A5 claim-hover-text: "%claim-name% - Owner: %owner%" +# Squaremap support +squaremap: true +squaremap-settings: + claim-border-color: FFFFFF + claim-fill-color: A5A5A5 + claim-hover-text: "%claim-name% - Owner: %owner%" + # ************************** # * Permissions settings * From 9b051651aaae9a26c88f2f6ffdaf97651228f4f1 Mon Sep 17 00:00:00 2001 From: James-P-Bennett Date: Thu, 13 Nov 2025 08:15:14 -0600 Subject: [PATCH 2/3] Update ClaimSquaremap.java Close polygon loops for ext borders --- .../java/fr/xyness/SCS/Support/ClaimSquaremap.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java b/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java index d131e6f..13e8c80 100644 --- a/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java +++ b/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java @@ -119,7 +119,6 @@ public void createClaimZone(Claim claim) { String fillColorHex = instance.getSettings().getSetting("squaremap-claim-fill-color"); String strokeColorHex = instance.getSettings().getSetting("squaremap-claim-border-color"); - // Parse hex colors to RGB integers int fillColor = Integer.parseInt(fillColorHex, 16); int strokeColor = Integer.parseInt(strokeColorHex, 16); @@ -171,7 +170,7 @@ public void createClaimZone(Claim claim) { .markerOptions( MarkerOptions.builder() .strokeColor(new Color(strokeColor)) - .strokeWeight(3) + .strokeWeight(2) .fillColor(new Color(fillColor)) .fillOpacity(0.35) .clickTooltip(hoverText) @@ -243,7 +242,6 @@ private List traceOutline(List edges) { points.add(Point.of(currentEdge.x2, currentEdge.z2)); usedEdges.add(currentEdge); - // Find connected edges while (usedEdges.size() < edges.size()) { Point lastPoint = points.getLast(); boolean found = false; @@ -253,12 +251,18 @@ private List traceOutline(List edges) { // Check if this edge connects to our current point if (edge.x1 == lastPoint.x() && edge.z1 == lastPoint.z()) { - points.add(Point.of(edge.x2, edge.z2)); + // Only add the second point if it's not already the first point (closing the loop) + if (!(edge.x2 == points.getFirst().x() && edge.z2 == points.getFirst().z())) { + points.add(Point.of(edge.x2, edge.z2)); + } usedEdges.add(edge); found = true; break; } else if (edge.x2 == lastPoint.x() && edge.z2 == lastPoint.z()) { - points.add(Point.of(edge.x1, edge.z1)); + // Only add the first point if it's not already the first point (closing the loop) + if (!(edge.x1 == points.getFirst().x() && edge.z1 == points.getFirst().z())) { + points.add(Point.of(edge.x1, edge.z1)); + } usedEdges.add(edge); found = true; break; From e69115e019a39ec1ba25a95cd718cc2ea0d8ac95 Mon Sep 17 00:00:00 2001 From: James-P-Bennett Date: Sat, 15 Nov 2025 22:18:22 -0600 Subject: [PATCH 3/3] Fix Timing / Claims Update Issue Existing claims now appear on map startup Claims update correctly when chunks are removed (bug causing stale polygons) --- src/main/java/fr/xyness/SCS/ClaimMain.java | 3 +++ src/main/java/fr/xyness/SCS/SimpleClaimSystem.java | 7 ++++++- src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/xyness/SCS/ClaimMain.java b/src/main/java/fr/xyness/SCS/ClaimMain.java index 306a983..ee4cc83 100644 --- a/src/main/java/fr/xyness/SCS/ClaimMain.java +++ b/src/main/java/fr/xyness/SCS/ClaimMain.java @@ -3970,6 +3970,7 @@ public CompletableFuture removeClaimChunk(Claim claim, String chunk_def if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().deleteMarker(Set.of(chunk)); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().deleteMarker(Set.of(chunk)); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().deleteMarker(Set.of(chunk)); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().createClaimZone(claim); instance.executeSync(() -> instance.getBossBars().deactivateBossBar(Set.of(chunk))); updateWeatherChunk(claim); updateFlyChunk(claim); @@ -4009,6 +4010,7 @@ public CompletableFuture removeClaimChunk(Claim claim, String chunk_def if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().deleteMarker(Set.of(chunk)); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().deleteMarker(Set.of(chunk)); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().deleteMarker(Set.of(chunk)); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().createClaimZone(claim); instance.executeSync(() -> instance.getBossBars().deactivateBossBar(Set.of(chunk))); updateWeatherChunk(claim); updateFlyChunk(claim); @@ -4061,6 +4063,7 @@ public CompletableFuture removeClaimChunk(Claim claim, Chunk chunk){ if (instance.getSettings().getBooleanSetting("dynmap")) instance.getDynmap().deleteMarker(Set.of(chunk)); if (instance.getSettings().getBooleanSetting("bluemap")) instance.getBluemap().deleteMarker(Set.of(chunk)); if (instance.getSettings().getBooleanSetting("pl3xmap")) instance.getPl3xMap().deleteMarker(Set.of(chunk)); + if (instance.getSettings().getBooleanSetting("squaremap")) instance.getSquaremap().createClaimZone(claim); instance.executeSync(() -> instance.getBossBars().deactivateBossBar(Set.of(chunk))); updateWeatherChunk(claim); updateFlyChunk(claim); diff --git a/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java b/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java index 0cc1b99..41a1156 100644 --- a/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java +++ b/src/main/java/fr/xyness/SCS/SimpleClaimSystem.java @@ -945,7 +945,12 @@ public boolean loadConfig(boolean reload, CommandSender sender) { // Load claims system claimInstance.loadClaims(); - + + // Initialize map integrations after claims are loaded + if (claimSettingsInstance.getBooleanSetting("squaremap") && squaremapInstance != null) { + squaremapInstance.initializeLayers(); + } + // Load players cPlayerMainInstance.loadPlayers(); diff --git a/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java b/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java index 13e8c80..5cafa90 100644 --- a/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java +++ b/src/main/java/fr/xyness/SCS/Support/ClaimSquaremap.java @@ -54,12 +54,11 @@ public class ClaimSquaremap { /** * Constructor for the ClaimSquaremap class. - * Initializes the layers for each world. + * Note: Call initializeLayers() after claims are loaded to display existing claims. */ public ClaimSquaremap(SimpleClaimSystem instance) { this.instance = instance; this.squaremapApi = SquaremapProvider.get(); - initialize(); } @@ -70,8 +69,9 @@ public ClaimSquaremap(SimpleClaimSystem instance) { /** * Initializes the layers for each world and creates markers for all existing claims. + * Should be called after claims are loaded from the database. */ - private void initialize() { + public void initializeLayers() { instance.executeAsync(() -> { Set claims = instance.getMain().getAllClaims(); for (World world : Bukkit.getWorlds()) {