mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-19 14:59:21 +00:00
fix(paper): locked maps losing data on restart, close #498
This commit is contained in:
@@ -259,22 +259,25 @@ public interface BukkitMapHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine map ID
|
||||
// Determine map ID and set it
|
||||
final String originServerName = mapData.getString(MAP_ORIGIN_KEY);
|
||||
final String currentServerName = getPlugin().getServerName();
|
||||
final boolean isOnOrigin = currentServerName.equals(originServerName);
|
||||
final int originalMapId = mapData.getInteger(MAP_ID_KEY);
|
||||
int newId = currentServerName.equals(originServerName)
|
||||
? originalMapId : getBoundMapId(originServerName, originalMapId, currentServerName);
|
||||
int newId = isOnOrigin ? originalMapId : getBoundMapId(originServerName, originalMapId, currentServerName);
|
||||
if (newId != -1) {
|
||||
final MapView view = Bukkit.getMap(newId);
|
||||
if (view != null) {
|
||||
meta.setMapView(view);
|
||||
meta.setMapId(newId);
|
||||
map.setItemMeta(meta);
|
||||
if (isOnOrigin) {
|
||||
meta.setMapView(Bukkit.getMap(newId));
|
||||
getPlugin().debug(String.format("Map ID set to original ID #%s", newId));
|
||||
return;
|
||||
}
|
||||
final Optional<MapView> view = getMapView(newId);
|
||||
if (view.isPresent()) {
|
||||
meta.setMapView(view.get());
|
||||
getPlugin().debug(String.format("Map ID set to #%s", newId));
|
||||
return;
|
||||
}
|
||||
getPlugin().debug(String.format("Map ID #%s not saved on this server, creating...", newId));
|
||||
}
|
||||
|
||||
// Read the pixel data from the ItemStack and generate a map view otherwise
|
||||
|
||||
Reference in New Issue
Block a user