9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-22 08:29:28 +00:00
Files
Leaf/leaf-server/paper-patches/features/0034-PaperPR-Fix-unnecessary-map-data-saves.patch
Taiyou cc98f4982e backport 1.21.8 async mob spawn (#479)
* backport: 1.21.8 async mob spawn

* Move into patch

* fix

* fix build

---------

Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Co-authored-by: hayanesuru <hayanesuru@outlook.jp>
2025-08-27 20:00:46 +02:00

52 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dqu1J <mcpeytwot5@gmail.com>
Date: Tue, 29 Apr 2025 01:35:45 -0400
Subject: [PATCH] PaperPR: Fix unnecessary map data saves
Original license: GPLv3
Original project: https://github.com/PaperMC/Paper
Paper pull request: https://github.com/PaperMC/Paper/pull/12296
Fixes Paper#12295
Currently, MapCanvas API unnecessarily causes map data file to save.
The API calls this.mapView.worldMap.setColorsDirty() to mark colors dirty for players, however this has the side-effect of saving the map .dat files as well:
```
public void setColorsDirty(int x, int z) {
this.setDirty(); // This saves the data file!
for (MapItemSavedData.HoldingPlayer holdingPlayer : this.carriedBy) {
holdingPlayer.markColorsDirty(x, z); // This is what the API wants to do!
}
}
```
This causes unnecessary lag during world saves, which scales with the amount of maps handled with API since last save. On servers that heavily rely on imageonmap-like plugins, it can cause lag spikes of dozens of seconds.
This PR changes this method to add a boolean argument to the method that determines whether the file is saved or not, which is used by the API. An overload is added for compatibility, and for vanilla.
diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java
index 94c0e6d748cec58ffbefd4b7eeb784beedfa6fb3..7cdab2d347eee0af2abe9b1deddce6ce6521f401 100644
--- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java
+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java
@@ -64,7 +64,7 @@ public class CraftMapCanvas implements MapCanvas {
return;
if (this.buffer[y * 128 + x] != color) {
this.buffer[y * 128 + x] = color;
- this.mapView.worldMap.setColorsDirty(x, y);
+ this.mapView.worldMap.setColorsDirty(x, y, false); // Paper - Fix unnecessary map data saves
}
}
@@ -141,8 +141,8 @@ public class CraftMapCanvas implements MapCanvas {
}
// Mark all colors within the image as dirty
- this.mapView.worldMap.setColorsDirty(destX, destY);
- this.mapView.worldMap.setColorsDirty(destX + effectiveWidth - 1, destY + effectiveHeight - 1);
+ this.mapView.worldMap.setColorsDirty(destX, destY, false); // Paper - Fix unnecessary map data saves
+ this.mapView.worldMap.setColorsDirty(destX + effectiveWidth - 1, destY + effectiveHeight - 1, false); // Paper - Fix unnecessary map data saves
// Paper end
}