9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-19 14:59:21 +00:00

Fix locked map data saving (#140)

This commit is contained in:
Rafael Romão
2023-06-21 10:45:17 +01:00
committed by GitHub
parent eb9e2491e5
commit bbcb091daf

View File

@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
@@ -55,8 +56,14 @@ public class BukkitMapHandler {
} }
// Get the map view from the map // Get the map view from the map
final MapView mapView = mapMeta.getMapView(); final MapView mapView;
if (mapView == null || !mapView.isLocked() || mapView.isVirtual()) { try {
mapView = Bukkit.getScheduler().callSyncMethod(plugin, mapMeta::getMapView).get();
if (mapView == null || !mapView.isLocked() || mapView.isVirtual()) {
return;
}
} catch (InterruptedException | ExecutionException e) {
plugin.getLogger().log(Level.WARNING, "Failed to save map data for a player", e);
return; return;
} }