Update FaWe #7

Zusammengeführt
Lixfel hat 467 Commits von update nach main 2024-11-28 22:27:32 +01:00 zusammengeführt
Nur Änderungen aus Commit 50cc9bc528 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -33,6 +33,7 @@ import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.util.BrushCache;
import com.fastasyncworldedit.core.util.MainUtil;
import com.fastasyncworldedit.core.util.StringMan;
import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.TextureHolder;
import com.fastasyncworldedit.core.util.TextureUtil;
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
@ -143,7 +144,7 @@ public class LocalSession implements TextureHolder {
}
});
private transient volatile Integer historyNegativeIndex;
private transient final Lock historyWriteLock = new ReentrantLock(true);
private transient final ReentrantLock historyWriteLock = new ReentrantLock(true);
private final transient Int2ObjectOpenHashMap<Tool> tools = new Int2ObjectOpenHashMap<>(0);
private transient Mask sourceMask;
private transient TextureUtil texture;
@ -405,6 +406,19 @@ public class LocalSession implements TextureHolder {
*/
public void clearHistory() {
//FAWE start
if (Fawe.isMainThread() && !historyWriteLock.tryLock()) {
// Do not make main thread wait if we cannot immediately clear history (on player logout usually)
TaskManager.taskManager().async(this::clearHistoryTask);
return;
}
try {
clearHistoryTask();
} finally {
historyWriteLock.unlock();
}
}
private void clearHistoryTask() {
historyWriteLock.lock();
try {
// Ensure that changesets are properly removed
@ -420,8 +434,8 @@ public class LocalSession implements TextureHolder {
save();
historySize = 0;
currentWorld = null;
//FAWE end
}
//FAWE end
/**
* Remember an edit session for the undo history. If the history maximum