Skip to content

Commit 1368f86

Browse files
committed
Also reset texture-gallery on map-purge
1 parent 0fc1424 commit 1368f86

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapPurgeTask.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import de.bluecolored.bluemap.core.storage.Storage;
3030
import de.bluecolored.bluemap.core.storage.file.FileStorage;
3131
import de.bluecolored.bluemap.core.util.DeletingPathVisitor;
32+
import org.jetbrains.annotations.Nullable;
3233

3334
import java.io.IOException;
3435
import java.nio.file.Files;
@@ -56,7 +57,7 @@ public static MapPurgeTask create(Path mapDirectory) throws IOException {
5657
@DebugDump
5758
private static class MapFilePurgeTask extends MapPurgeTask {
5859

59-
private final BmMap map;
60+
@Nullable private final BmMap map;
6061
private final Path directory;
6162
private final int subFilesCount;
6263
private final LinkedList<Path> subFiles;
@@ -72,7 +73,7 @@ public MapFilePurgeTask(BmMap map, FileStorage fileStorage) throws IOException {
7273
this(map, fileStorage.getFilePath(map.getId()));
7374
}
7475

75-
private MapFilePurgeTask(BmMap map, Path directory) throws IOException {
76+
private MapFilePurgeTask(@Nullable BmMap map, Path directory) throws IOException {
7677
this.map = map;
7778
this.directory = directory;
7879
try (Stream<Path> pathStream = Files.walk(directory, 3)) {
@@ -92,7 +93,7 @@ public void doWork() throws Exception {
9293

9394
try {
9495
// save lowres-tile-manager to clear/flush any buffered data
95-
this.map.getLowresTileManager().save();
96+
if (this.map != null) this.map.getLowresTileManager().save();
9697

9798
// delete subFiles first to be able to track the progress and cancel
9899
while (!subFiles.isEmpty()) {
@@ -106,6 +107,10 @@ public void doWork() throws Exception {
106107
if (Files.exists(directory)) {
107108
Files.walkFileTree(directory, DeletingPathVisitor.INSTANCE);
108109
}
110+
111+
// reset texture-gallery
112+
if (this.map != null) this.map.resetTextureGallery();
113+
109114
} finally {
110115
// reset map render state
111116
if (this.map != null) {

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/BmMap.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ private void saveTextureGallery() {
181181
}
182182
}
183183

184+
public synchronized void resetTextureGallery() {
185+
this.textureGallery.clear();
186+
this.textureGallery.put(this.resourcePack);
187+
}
188+
184189
private void saveMapSettings() {
185190
try (
186191
OutputStream out = storage.writeMeta(id, MetaType.SETTINGS);

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public TextureGallery() {
2424
this.nextId = 0;
2525
}
2626

27+
public void clear() {
28+
this.ordinalMap.clear();
29+
this.nextId = 0;
30+
}
31+
2732
public int get(@Nullable ResourcePath<Texture> textureResourcePath) {
2833
if (textureResourcePath == null) textureResourcePath = ResourcePack.MISSING_TEXTURE;
2934
Integer ordinal = ordinalMap.get(textureResourcePath);

0 commit comments

Comments
 (0)