Skip to content

Commit

Permalink
Fix: Fixed generate command duping zones
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyeRangerDelta committed Aug 15, 2024
1 parent 32f44a3 commit 8770ee1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ run/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
/.idea/
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'net.pldyn'
version = '1.0.0-beta.2'
version = '1.0.0-beta.3'

repositories {
mavenCentral()
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/net/pldyn/bluemapzones/BlueMap_Zones.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Objects;
import java.util.logging.Logger;

public final class BlueMap_Zones extends JavaPlugin implements ZoneGenerationCallback {
public final class BlueMap_Zones extends JavaPlugin {

private static final Logger Log = Logger.getLogger("BM Zones");
private java.util.UUID UUID;
Expand Down Expand Up @@ -70,25 +70,25 @@ private void doInit(BlueMapAPI blueMapAPI) {
Log.info("Plugin initialized!");
}

@Override
public void onZoneGenerationComplete(ArrayList<ZonedShape> zonedShapes) {
runningGeneration = false;
setZonedShapes(zonedShapes);
Log.info("Zone generation complete!");
Log.info("Generated " + zonedShapes.size() + " zones.");

movementHandler.setZonedShapes( zonedShapes );
}
// @Override
// public void onZoneGenerationComplete(ArrayList<ZonedShape> zonedShapes) {
// runningGeneration = false;
// setZonedShapes(zonedShapes);
// Log.info("Zone generation complete!");
// Log.info("Generated " + zonedShapes.size() + " zones.");
// }

public void generateZones() {
zonedShapes.clear();
runningGeneration = true;
new ZoneGenerator(bma, this, this).start();
new ZoneGenerator(bma, this).start();
Log.info("Zone generation started!");
}

public void setZonedShapes(ArrayList<ZonedShape> zonedShapes) {
this.zonedShapes.clear();
this.zonedShapes = zonedShapes;
movementHandler.setZonedShapes( zonedShapes );
}

public BlueMapAPI getBlueMapAPI() {
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/net/pldyn/bluemapzones/ZoneGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import de.bluecolored.bluemap.api.markers.MarkerSet;
import de.bluecolored.bluemap.api.markers.ShapeMarker;
import de.bluecolored.bluemap.api.math.Shape;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.*;
import java.util.logging.Logger;
Expand All @@ -19,12 +22,10 @@ public class ZoneGenerator extends Thread {
private static final ArrayList<ZonedShape> zonedShapes = new ArrayList<>();
private final BlueMapAPI blueMapAPI;
private final BlueMap_Zones plugin;
private final ZoneGenerationCallback callback;

public ZoneGenerator(BlueMapAPI blueMapApi, BlueMap_Zones plugin, ZoneGenerationCallback callback) {
public ZoneGenerator(BlueMapAPI blueMapApi, BlueMap_Zones plugin) {
this.blueMapAPI = blueMapApi;
this.plugin = plugin;
this.callback = callback;
}

private BlueMapMap findConfMaps(Collection<BlueMapMap> loadedWorlds) {
Expand Down Expand Up @@ -284,6 +285,8 @@ public void run() {
return;
}

zonedShapes.clear();

//Build shapes and their bounds
handleMarkerSet(objectiveSet);

Expand All @@ -303,6 +306,10 @@ public void run() {
Log.info("Generation includes " + zonedShapes.size() + " shapes with a total of "
+ chunkCount + " chunks.");

callback.onZoneGenerationComplete( zonedShapes );
Component message = Component.text("Generation done!").color( NamedTextColor.GREEN );
Bukkit.getServer().sendMessage( message );

plugin.setGenerating( false );
plugin.setZonedShapes( zonedShapes );
}
}

0 comments on commit 8770ee1

Please sign in to comment.