Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public <T> T syncWith(final Supplier<T> supplier, final Player context) {

@Override
public <T> T syncGlobal(final Supplier<T> supplier) {
if (Bukkit.isPrimaryThread()) {
if (FoliaSupport.isTickThread()) {
return supplier.get();
}
final FutureTask<T> task = new FutureTask<>(supplier::get);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fastasyncworldedit.core.history.changeset;

import com.fastasyncworldedit.core.util.FoliaSupport;
import com.sk89q.worldedit.history.change.Change;
import org.jetbrains.annotations.ApiStatus;

Expand Down Expand Up @@ -30,12 +31,18 @@ public Change[] take(Change[] consumed) {
if (!this.started) {
this.started = true;
final int length = consumed.length;
this.runner = UNDO_VIRTUAL_THREAD_BUILDER
.start(() -> this.runnerTask.accept(this.exchanger, new Change[length]));
if (FoliaSupport.isFolia()) {
this.runner = new Thread(() -> this.runnerTask.accept(this.exchanger, new Change[length]), "FAWE undo");
this.runner.setDaemon(true);
this.runner.start();
} else {
this.runner = UNDO_VIRTUAL_THREAD_BUILDER
.start(() -> this.runnerTask.accept(this.exchanger, new Change[length]));
}
}
try {
// Allow a reasonable timeout in case of weirdness
return exchanger.exchange(consumed, 30, TimeUnit.SECONDS);
long timeoutSeconds = FoliaSupport.isFolia() ? 60 : 30;
return exchanger.exchange(consumed, timeoutSeconds, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException e) {
this.runner.interrupt();
Thread.currentThread().interrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.locks.ReentrantLock;
import com.fastasyncworldedit.core.util.FoliaSupport;

/**
* Single threaded implementation for IQueueExtent (still abstract) - Does not implement creation of
Expand Down Expand Up @@ -254,7 +255,7 @@ private <V extends Future<V>> V submitUnchecked(IQueueChunk chunk) {
}
}

if (Fawe.isTickThread()) {
if (Fawe.isTickThread() && !FoliaSupport.isFolia()) {
V result = (V) chunk.call();
if (result == null) {
return (V) (Future) Futures.immediateFuture(null);
Expand Down
Loading