Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-27 03:12:37 +01:00
Fix some folia incompatibilities
Dieser Commit ist enthalten in:
Ursprung
17b7a2cf11
Commit
d64b0d9edf
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -400,7 +400,6 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
if (config != null) {
|
||||
config.unload();
|
||||
}
|
||||
this.getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren