3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-16 16:10:07 +01:00

Fix some folia incompatibilities

Dieser Commit ist enthalten in:
SirYwell 2023-10-29 12:10:19 +01:00
Ursprung 17b7a2cf11
Commit d64b0d9edf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
4 geänderte Dateien mit 21 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -64,7 +64,6 @@ import net.minecraft.world.level.chunk.SingleValuePalette;
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import org.apache.logging.log4j.Logger;
import org.bukkit.craftbukkit.v1_20_R1.CraftChunk;
import sun.misc.Unsafe;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -335,9 +334,11 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static void addTicket(ServerLevel serverLevel, int chunkX, int chunkZ) {
// Ensure chunk is definitely loaded before applying a ticket
io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> serverLevel
.getChunkSource()
.addRegionTicket(TicketType.UNLOAD_COOLDOWN, new ChunkPos(chunkX, chunkZ), 0, Unit.INSTANCE));
task(() -> serverLevel
.getChunkSource()
.addRegionTicket(TicketType.UNLOAD_COOLDOWN, new ChunkPos(chunkX, chunkZ), 0, Unit.INSTANCE),
serverLevel, chunkX, chunkZ
);
}
public static ChunkHolder getPlayerChunk(ServerLevel nmsWorld, final int chunkX, final int chunkZ) {

Datei anzeigen

@ -76,10 +76,14 @@ public class FoliaTaskManager extends TaskManager {
@Override
public <T> T syncAt(final Supplier<T> supplier, final World world, final int chunkX, final int chunkZ) {
final org.bukkit.World adapt = BukkitAdapter.adapt(world);
if (Bukkit.isOwnedByCurrentRegion(adapt, chunkX, chunkZ)) {
return supplier.get();
}
FutureTask<T> task = new FutureTask<>(supplier::get);
Bukkit.getRegionScheduler().run(
WorldEditPlugin.getInstance(),
BukkitAdapter.adapt(world),
adapt,
chunkX,
chunkZ,
asConsumer(task)
@ -97,10 +101,12 @@ public class FoliaTaskManager extends TaskManager {
@Override
public <T> T syncWith(final Supplier<T> supplier, final Player context) {
final org.bukkit.entity.Player adapt = BukkitAdapter.adapt(context);
if (Bukkit.isOwnedByCurrentRegion(adapt)) {
return supplier.get();
}
FutureTask<T> task = new FutureTask<>(supplier::get);
BukkitAdapter.adapt(context)
.getScheduler()
.execute(WorldEditPlugin.getInstance(), task, null, 0);
adapt.getScheduler().execute(WorldEditPlugin.getInstance(), task, null, 0);
try {
return task.get();
} catch (InterruptedException | ExecutionException e) {
@ -110,6 +116,7 @@ public class FoliaTaskManager extends TaskManager {
@Override
public <T> T syncGlobal(final Supplier<T> supplier) {
// TODO avoid deadlocks (Bukkit.isGlobalTickThread not available at time of writing)
FutureTask<T> task = new FutureTask<>(supplier::get);
Bukkit.getGlobalRegionScheduler().run(WorldEditPlugin.getInstance(), asConsumer(task));
try {

Datei anzeigen

@ -400,7 +400,6 @@ public class WorldEditPlugin extends JavaPlugin {
if (config != null) {
config.unload();
}
this.getServer().getScheduler().cancelTasks(this);
}
/**

Datei anzeigen

@ -687,8 +687,11 @@ public final class PlatformCommandManager {
Command cmd = optional.get();
PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null);
if (queued != null && !queued.isQueued()) {
// TODO?
// TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isMainThread());
if (actor instanceof Player player) {
TaskManager.taskManager().task(() -> handleCommandOnCurrentThread(event), player.getLocation());
} else {
// TODO
}
return;
} else {
actor.decline();