Preload chunks up to the configured limit, cancel preloading on EditSession complete

This commit is contained in:
dordsor21 2021-08-17 12:07:48 +01:00
parent da7aca8ef8
commit 8c11ba7fea
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 9 additions and 1 deletions

View File

@ -1,9 +1,12 @@
package com.fastasyncworldedit.core.queue.implementation.preloader; package com.fastasyncworldedit.core.queue.implementation.preloader;
import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.util.FaweTimer; import com.fastasyncworldedit.core.util.FaweTimer;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.fastasyncworldedit.core.util.collection.MutablePair; import com.fastasyncworldedit.core.util.collection.MutablePair;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -72,7 +75,7 @@ public class AsyncPreloader implements Preloader, Runnable {
} }
synchronized (existing) { // Ensure key & value are mutated together synchronized (existing) { // Ensure key & value are mutated together
existing.setKey(world); existing.setKey(world);
existing.setValue(region.getChunks()); existing.setValue(ImmutableSet.copyOf(Iterables.limit(region.getChunks(), Settings.IMP.QUEUE.PRELOAD_CHUNK_COUNT)));
} }
synchronized (update) { synchronized (update) {
update.notify(); update.notify();

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit; package com.sk89q.worldedit;
import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.FaweCache; import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.configuration.Settings;
@ -1250,6 +1251,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
player.print(Caption.of("fawe.error.lighting")); player.print(Caption.of("fawe.error.lighting"));
e.printStackTrace(); e.printStackTrace();
} }
// Cancel any preloader associated with the actor if present
if (getPlayer() != null) {
Fawe.imp().getPreloader(false).cancel(getPlayer());
}
// Enqueue it // Enqueue it
if (getChangeSet() != null) { if (getChangeSet() != null) {
if (Settings.IMP.HISTORY.COMBINE_STAGES) { if (Settings.IMP.HISTORY.COMBINE_STAGES) {