Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-17 00:20:09 +01:00
tmp
Dieser Commit ist enthalten in:
Ursprung
54a96bcaea
Commit
fca4ab42ef
@ -250,7 +250,8 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TaskManager.taskManager().async(() -> TaskManager.taskManager().sync(runnableVal));
|
// TODO ???
|
||||||
|
// TaskManager.taskManager().async(() -> TaskManager.taskManager().sync(runnableVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -269,7 +270,8 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
|
|||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
runnableVal.run();
|
runnableVal.run();
|
||||||
} else {
|
} else {
|
||||||
TaskManager.taskManager().sync(runnableVal);
|
// TODO
|
||||||
|
// TaskManager.taskManager().sync(runnableVal);
|
||||||
}
|
}
|
||||||
cachedChanges.clear();
|
cachedChanges.clear();
|
||||||
cachedChunksToSend.clear();
|
cachedChunksToSend.clear();
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.util.MathMan;
|
|||||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
||||||
@ -283,7 +284,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
String world = serverLevel.getWorld().getName();
|
String world = serverLevel.getWorld().getName();
|
||||||
// We've already taken 10 seconds we can afford to wait a little here.
|
// We've already taken 10 seconds we can afford to wait a little here.
|
||||||
boolean loaded = TaskManager.taskManager().sync(() -> Bukkit.getWorld(world) != null);
|
boolean loaded = false; // TODO TaskManager.taskManager().sync(() -> Bukkit.getWorld(world) != null);
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
LOGGER.warn("Chunk {},{} failed to load in 10 seconds in world {}. Retrying...", chunkX, chunkZ, world);
|
LOGGER.warn("Chunk {},{} failed to load in 10 seconds in world {}. Retrying...", chunkX, chunkZ, world);
|
||||||
// Retry chunk load
|
// Retry chunk load
|
||||||
@ -298,7 +299,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TaskManager.taskManager().sync(() -> serverLevel.getChunk(chunkX, chunkZ));
|
return TaskManager.taskManager().syncAt(
|
||||||
|
() -> serverLevel.getChunk(chunkX, chunkZ),
|
||||||
|
BukkitAdapter.adapt(serverLevel.getWorld()),
|
||||||
|
chunkX,
|
||||||
|
chunkZ
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addTicket(ServerLevel serverLevel, int chunkX, int chunkZ) {
|
private static void addTicket(ServerLevel serverLevel, int chunkX, int chunkZ) {
|
||||||
@ -361,7 +367,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
|
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
|
||||||
});
|
}, BukkitAdapter.adapt(nmsWorld.getWorld()), chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ServerPlayer> nearbyPlayers(ServerLevel serverLevel, ChunkPos coordIntPair) {
|
private static List<ServerPlayer> nearbyPlayers(ServerLevel serverLevel, ChunkPos coordIntPair) {
|
||||||
|
@ -252,7 +252,8 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TaskManager.taskManager().async(() -> TaskManager.taskManager().sync(runnableVal));
|
// TODO ???
|
||||||
|
// TaskManager.taskManager().async(() -> TaskManager.taskManager().sync(runnableVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -271,7 +272,8 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
|
|||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
runnableVal.run();
|
runnableVal.run();
|
||||||
} else {
|
} else {
|
||||||
TaskManager.taskManager().sync(runnableVal);
|
// TODO
|
||||||
|
// TaskManager.taskManager().sync(runnableVal);
|
||||||
}
|
}
|
||||||
cachedChanges.clear();
|
cachedChanges.clear();
|
||||||
cachedChunksToSend.clear();
|
cachedChunksToSend.clear();
|
||||||
|
@ -311,7 +311,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
String world = serverLevel.getWorld().getName();
|
String world = serverLevel.getWorld().getName();
|
||||||
// We've already taken 10 seconds we can afford to wait a little here.
|
// We've already taken 10 seconds we can afford to wait a little here.
|
||||||
boolean loaded = TaskManager.taskManager().sync(() -> Bukkit.getWorld(world) != null);
|
boolean loaded = false; // TODO TaskManager.taskManager().sync(() -> Bukkit.getWorld(world) != null);
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
LOGGER.warn("Chunk {},{} failed to load in 10 seconds in world {}. Retrying...", chunkX, chunkZ, world);
|
LOGGER.warn("Chunk {},{} failed to load in 10 seconds in world {}. Retrying...", chunkX, chunkZ, world);
|
||||||
// Retry chunk load
|
// Retry chunk load
|
||||||
@ -326,7 +326,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TaskManager.taskManager().sync(() -> serverLevel.getChunk(chunkX, chunkZ));
|
return TaskManager.taskManager().syncAt(
|
||||||
|
() -> serverLevel.getChunk(chunkX, chunkZ),
|
||||||
|
BukkitAdapter.adapt(serverLevel.getWorld()),
|
||||||
|
chunkX,
|
||||||
|
chunkZ
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addTicket(ServerLevel serverLevel, int chunkX, int chunkZ) {
|
private static void addTicket(ServerLevel serverLevel, int chunkX, int chunkZ) {
|
||||||
|
@ -389,7 +389,9 @@ public interface IBukkitAdapter {
|
|||||||
* @return list of {@link org.bukkit.entity.Entity}
|
* @return list of {@link org.bukkit.entity.Entity}
|
||||||
*/
|
*/
|
||||||
default List<org.bukkit.entity.Entity> getEntities(org.bukkit.World world) {
|
default List<org.bukkit.entity.Entity> getEntities(org.bukkit.World world) {
|
||||||
return TaskManager.taskManager().sync(world::getEntities);
|
// TODO
|
||||||
|
// return TaskManager.taskManager().sync(world::getEntities);
|
||||||
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public abstract class ChunkListener implements Listener {
|
|||||||
PluginManager plm = Bukkit.getPluginManager();
|
PluginManager plm = Bukkit.getPluginManager();
|
||||||
Plugin plugin = Fawe.<FaweBukkit>platform().getPlugin();
|
Plugin plugin = Fawe.<FaweBukkit>platform().getPlugin();
|
||||||
plm.registerEvents(this, plugin);
|
plm.registerEvents(this, plugin);
|
||||||
TaskManager.taskManager().repeat(() -> {
|
/*TaskManager.taskManager().repeat(() -> {
|
||||||
Location tmpLoc = lastCancelPos;
|
Location tmpLoc = lastCancelPos;
|
||||||
if (tmpLoc != null) {
|
if (tmpLoc != null) {
|
||||||
LOGGER.info("[FAWE Tick Limiter] Detected and cancelled physics lag source at {}", tmpLoc);
|
LOGGER.info("[FAWE Tick Limiter] Detected and cancelled physics lag source at {}", tmpLoc);
|
||||||
@ -89,7 +89,7 @@ public abstract class ChunkListener implements Listener {
|
|||||||
counter.put(key, badLimit);
|
counter.put(key, badLimit);
|
||||||
}
|
}
|
||||||
badChunks.clear();
|
badChunks.clear();
|
||||||
}, Settings.settings().TICK_LIMITER.INTERVAL);
|
}, Settings.settings().TICK_LIMITER.INTERVAL)*/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class RenderListener implements Listener {
|
|||||||
|
|
||||||
public RenderListener(Plugin plugin) {
|
public RenderListener(Plugin plugin) {
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
TaskManager.taskManager().repeat(new Runnable() {
|
/*TaskManager.taskManager().repeat(new Runnable() {
|
||||||
private long last = 0;
|
private long last = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,7 +76,7 @@ public class RenderListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1)*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setViewDistance(Player player, int value) {
|
private void setViewDistance(Player player, int value) {
|
||||||
|
@ -26,8 +26,10 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
|
|||||||
public boolean isAllowed(Player player, Claim claim, MaskType type) {
|
public boolean isAllowed(Player player, Claim claim, MaskType type) {
|
||||||
return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim
|
return claim != null && (claim.getOwnerName().equalsIgnoreCase(player.getName()) || claim
|
||||||
.getOwnerName()
|
.getOwnerName()
|
||||||
.equals(player.getUniqueId()) || TaskManager.taskManager().sync(() -> type == MaskType.MEMBER &&
|
.equals(player.getUniqueId()) || TaskManager.taskManager().syncAt(
|
||||||
claim.allowBuild(player, Material.AIR) == null));
|
() -> type == MaskType.MEMBER && claim.allowBuild(player, Material.AIR) == null,
|
||||||
|
BukkitAdapter.adapt(claim.getLesserBoundaryCorner())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,9 +27,9 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
|||||||
return residence != null &&
|
return residence != null &&
|
||||||
(residence.getOwner().equals(player.getName()) ||
|
(residence.getOwner().equals(player.getName()) ||
|
||||||
residence.getOwner().equals(player.getUniqueId().toString()) ||
|
residence.getOwner().equals(player.getUniqueId().toString()) ||
|
||||||
type == MaskType.MEMBER && TaskManager.taskManager().sync(() -> residence
|
type == MaskType.MEMBER && TaskManager.taskManager().syncWith(() -> residence
|
||||||
.getPermissions()
|
.getPermissions()
|
||||||
.playerHas(player, "build", false)));
|
.playerHas(player, "build", false), BukkitAdapter.adapt(player)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,7 +76,8 @@ public class FaweDelegateRegionManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
TaskManager.taskManager().task(whenDone);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(whenDone, new com.sk89q.worldedit.util.Location(world, ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +204,8 @@ public class FaweDelegateRegionManager {
|
|||||||
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE)
|
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE)
|
||||||
);
|
);
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
TaskManager.taskManager().task(whenDone);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(whenDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -272,7 +274,8 @@ public class FaweDelegateRegionManager {
|
|||||||
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE)
|
RelightMode.valueOf(com.fastasyncworldedit.core.configuration.Settings.settings().LIGHTING.MODE)
|
||||||
);
|
);
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
TaskManager.taskManager().task(whenDone);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(whenDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -301,7 +304,8 @@ public class FaweDelegateRegionManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
TaskManager.taskManager().task(whenDone);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(whenDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -354,7 +358,8 @@ public class FaweDelegateRegionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
TaskManager.taskManager().task(whenDone);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(whenDone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@ -378,7 +383,8 @@ public class FaweDelegateRegionManager {
|
|||||||
editSession.flushQueue();
|
editSession.flushQueue();
|
||||||
}
|
}
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
TaskManager.taskManager().task(whenDone);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(whenDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package com.fastasyncworldedit.bukkit.util;
|
package com.fastasyncworldedit.bukkit.util;
|
||||||
|
|
||||||
|
import com.fastasyncworldedit.core.Fawe;
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BukkitTaskManager extends TaskManager {
|
public class BukkitTaskManager extends TaskManager {
|
||||||
@ -18,11 +21,6 @@ public class BukkitTaskManager extends TaskManager {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int repeat(@Nonnull final Runnable runnable, final int interval) {
|
|
||||||
return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, runnable, interval, interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int repeatAsync(@Nonnull final Runnable runnable, final int interval) {
|
public int repeatAsync(@Nonnull final Runnable runnable, final int interval) {
|
||||||
return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, runnable, interval, interval);
|
return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, runnable, interval, interval);
|
||||||
@ -34,18 +32,13 @@ public class BukkitTaskManager extends TaskManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void task(@Nonnull final Runnable runnable) {
|
public void task(@NotNull final Runnable runnable, @NotNull final Location location) {
|
||||||
this.plugin.getServer().getScheduler().runTask(this.plugin, runnable).getTaskId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void task(@NotNull final Runnable runnable, @NotNull final Location context) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void later(@Nonnull final Runnable runnable, final int delay) {
|
public void task(@NotNull final Runnable runnable, @NotNull final World world, final int chunkX, final int chunkZ) {
|
||||||
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, runnable, delay).getTaskId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,7 +61,7 @@ public class BukkitTaskManager extends TaskManager {
|
|||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T syncAt(final Supplier<T> supplier, final Location context) {
|
public <T> T syncAt(final Supplier<T> supplier, final World world, final int chunkX, final int chunkZ) {
|
||||||
return sync(supplier);
|
return sync(supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,4 +70,16 @@ public class BukkitTaskManager extends TaskManager {
|
|||||||
return sync(supplier);
|
return sync(supplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T> T sync(final Supplier<T> supplier) {
|
||||||
|
if (Fawe.isTickThread()) {
|
||||||
|
return supplier.get();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// TODO
|
||||||
|
return Fawe.instance().getQueueHandler().sync(supplier).get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -14,63 +15,66 @@ import java.lang.invoke.MethodHandles;
|
|||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static java.lang.invoke.MethodHandles.dropReturn;
|
|
||||||
import static java.lang.invoke.MethodHandles.explicitCastArguments;
|
|
||||||
import static java.lang.invoke.MethodHandles.filterArguments;
|
|
||||||
import static java.lang.invoke.MethodHandles.insertArguments;
|
import static java.lang.invoke.MethodHandles.insertArguments;
|
||||||
import static java.lang.invoke.MethodType.methodType;
|
import static java.lang.invoke.MethodType.methodType;
|
||||||
|
|
||||||
public class FoliaTaskManager extends TaskManager {
|
public class FoliaTaskManager extends TaskManager {
|
||||||
|
|
||||||
private final ScheduledExecutorService backgroundExecutor = Executors.newSingleThreadScheduledExecutor();
|
|
||||||
private final AtomicInteger idCounter = new AtomicInteger();
|
private final AtomicInteger idCounter = new AtomicInteger();
|
||||||
|
|
||||||
@Override
|
|
||||||
public int repeat(@NotNull final Runnable runnable, final int interval) {
|
|
||||||
return fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int repeatAsync(@NotNull final Runnable runnable, final int interval) {
|
public int repeatAsync(@NotNull final Runnable runnable, final int interval) {
|
||||||
backgroundExecutor.scheduleAtFixedRate(runnable, 0, ticksToMs(interval), TimeUnit.MILLISECONDS);
|
// TODO return some kind of own ScheduledTask instead of int
|
||||||
|
Bukkit.getAsyncScheduler().runAtFixedRate(
|
||||||
|
WorldEditPlugin.getInstance(),
|
||||||
|
asConsumer(runnable),
|
||||||
|
0,
|
||||||
|
ticksToMs(interval),
|
||||||
|
TimeUnit.MILLISECONDS
|
||||||
|
);
|
||||||
return idCounter.getAndIncrement();
|
return idCounter.getAndIncrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void async(@NotNull final Runnable runnable) {
|
public void async(@NotNull final Runnable runnable) {
|
||||||
backgroundExecutor.submit(runnable);
|
Bukkit.getAsyncScheduler().runNow(WorldEditPlugin.getInstance(), asConsumer(runnable));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void task(@NotNull final Runnable runnable) {
|
public void task(@NotNull final Runnable runnable, @NotNull final World world, final int chunkX, final int chunkZ) {
|
||||||
fail();
|
Bukkit.getRegionScheduler().run(
|
||||||
}
|
WorldEditPlugin.getInstance(),
|
||||||
|
BukkitAdapter.adapt(world),
|
||||||
@Override
|
chunkX,
|
||||||
public void task(@NotNull final Runnable runnable, @NotNull final Location context) {
|
chunkZ,
|
||||||
SchedulerAdapter.executeForLocation(context, runnable);
|
asConsumer(runnable)
|
||||||
}
|
);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void later(@NotNull final Runnable runnable, final int delay) {
|
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void later(@NotNull final Runnable runnable, final Location location, final int delay) {
|
public void later(@NotNull final Runnable runnable, final Location location, final int delay) {
|
||||||
fail("Not implemented");
|
Bukkit.getRegionScheduler().runDelayed(
|
||||||
|
WorldEditPlugin.getInstance(),
|
||||||
|
BukkitAdapter.adapt(location),
|
||||||
|
asConsumer(runnable),
|
||||||
|
delay
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void laterAsync(@NotNull final Runnable runnable, final int delay) {
|
public void laterAsync(@NotNull final Runnable runnable, final int delay) {
|
||||||
backgroundExecutor.schedule(runnable, ticksToMs(delay), TimeUnit.MILLISECONDS);
|
Bukkit.getAsyncScheduler().runDelayed(
|
||||||
|
WorldEditPlugin.getInstance(),
|
||||||
|
asConsumer(runnable),
|
||||||
|
ticksToMs(delay),
|
||||||
|
TimeUnit.MILLISECONDS
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,9 +83,15 @@ public class FoliaTaskManager extends TaskManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T syncAt(final Supplier<T> supplier, final Location context) {
|
public <T> T syncAt(final Supplier<T> supplier, final World world, final int chunkX, final int chunkZ) {
|
||||||
FutureTask<T> task = new FutureTask<>(supplier::get);
|
FutureTask<T> task = new FutureTask<>(supplier::get);
|
||||||
SchedulerAdapter.executeForLocation(context, task);
|
Bukkit.getRegionScheduler().run(
|
||||||
|
WorldEditPlugin.getInstance(),
|
||||||
|
BukkitAdapter.adapt(world),
|
||||||
|
chunkX,
|
||||||
|
chunkZ,
|
||||||
|
asConsumer(task)
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
return task.get();
|
return task.get();
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
@ -89,10 +99,16 @@ public class FoliaTaskManager extends TaskManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <R> Consumer<R> asConsumer(Runnable runnable) {
|
||||||
|
return __ -> runnable.run();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T syncWith(final Supplier<T> supplier, final Player context) {
|
public <T> T syncWith(final Supplier<T> supplier, final Player context) {
|
||||||
FutureTask<T> task = new FutureTask<>(supplier::get);
|
FutureTask<T> task = new FutureTask<>(supplier::get);
|
||||||
SchedulerAdapter.executeForEntity(context, task);
|
BukkitAdapter.adapt(context)
|
||||||
|
.getScheduler()
|
||||||
|
.execute(WorldEditPlugin.getInstance(), task, null, 0);
|
||||||
try {
|
try {
|
||||||
return task.get();
|
return task.get();
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
@ -105,105 +121,9 @@ public class FoliaTaskManager extends TaskManager {
|
|||||||
return ticks * 50;
|
return ticks * 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T fail() {
|
|
||||||
return fail("No main thread present");
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T fail(String message) {
|
private <T> T fail(String message) {
|
||||||
throw new UnsupportedOperationException(message);
|
throw new UnsupportedOperationException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SchedulerAdapter {
|
|
||||||
|
|
||||||
private static final MethodHandle EXECUTE_FOR_LOCATION;
|
|
||||||
private static final MethodHandle EXECUTE_FOR_PLAYER;
|
|
||||||
private static final Runnable THROW_IF_RETIRED = () -> throwRetired();
|
|
||||||
|
|
||||||
private static final MethodType LOCATION_EXECUTE_TYPE = methodType(
|
|
||||||
void.class,
|
|
||||||
Plugin.class,
|
|
||||||
org.bukkit.Location.class,
|
|
||||||
Runnable.class
|
|
||||||
);
|
|
||||||
|
|
||||||
private static final MethodType ENTITY_EXECUTE_TYPE = methodType(
|
|
||||||
boolean.class,
|
|
||||||
Plugin.class,
|
|
||||||
Runnable.class,
|
|
||||||
Runnable.class,
|
|
||||||
long.class
|
|
||||||
);
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Plugin pluginInstance = WorldEditPlugin.getInstance();
|
|
||||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
|
||||||
|
|
||||||
MethodHandle executeForLocation;
|
|
||||||
|
|
||||||
MethodHandle executeForPlayer;
|
|
||||||
try {
|
|
||||||
Class<?> regionisedSchedulerClass = Class.forName("io.papermc.paper.threadedregions.scheduler.RegionisedScheduler");
|
|
||||||
final Method method = Bukkit.class.getDeclaredMethod("getRegionScheduler");
|
|
||||||
executeForLocation = lookup.findVirtual(
|
|
||||||
regionisedSchedulerClass,
|
|
||||||
"execute",
|
|
||||||
LOCATION_EXECUTE_TYPE
|
|
||||||
);
|
|
||||||
executeForLocation = executeForLocation.bindTo(method.invoke(null));
|
|
||||||
executeForLocation = executeForLocation.bindTo(pluginInstance);
|
|
||||||
|
|
||||||
Class<?> entitySchedulerClass = Class.forName("io.papermc.paper.threadedregions.scheduler.EntityScheduler");
|
|
||||||
executeForPlayer = lookup.findVirtual(
|
|
||||||
entitySchedulerClass,
|
|
||||||
"execute",
|
|
||||||
ENTITY_EXECUTE_TYPE
|
|
||||||
);
|
|
||||||
// (ES, P, R, R, L)Z (ES, R, R, L)Z
|
|
||||||
executeForPlayer = insertArguments(executeForPlayer, 1, pluginInstance);
|
|
||||||
// (ES, R1, R2, L)Z -> (ES, R1)Z
|
|
||||||
executeForPlayer = insertArguments(executeForPlayer, 2, THROW_IF_RETIRED, 0);
|
|
||||||
// (ES, R1)Z -> (ES, R1)V
|
|
||||||
executeForPlayer = dropReturn(executeForPlayer);
|
|
||||||
MethodHandle getScheduler = lookup.findVirtual(
|
|
||||||
org.bukkit.entity.Entity.class,
|
|
||||||
"getScheduler",
|
|
||||||
methodType(entitySchedulerClass)
|
|
||||||
);
|
|
||||||
// (ES, R1)V -> (E, R1)V
|
|
||||||
executeForPlayer = filterArguments(executeForPlayer, 0, getScheduler);
|
|
||||||
MethodType finalType = methodType(void.class, org.bukkit.entity.Player.class, Runnable.class);
|
|
||||||
// (ES, R1)V -> (P, R1)V
|
|
||||||
executeForPlayer = explicitCastArguments(executeForPlayer, finalType);
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
throw new AssertionError(throwable);
|
|
||||||
}
|
|
||||||
EXECUTE_FOR_LOCATION = executeForLocation;
|
|
||||||
EXECUTE_FOR_PLAYER = executeForPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void executeForLocation(Location location, Runnable task) {
|
|
||||||
try {
|
|
||||||
EXECUTE_FOR_LOCATION.invokeExact(BukkitAdapter.adapt(location), task);
|
|
||||||
} catch (Error | RuntimeException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Throwable other) {
|
|
||||||
throw new RuntimeException(other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void executeForEntity(Player player, Runnable task) {
|
|
||||||
try {
|
|
||||||
EXECUTE_FOR_PLAYER.invokeExact(BukkitAdapter.adapt(player), task);
|
|
||||||
} catch (Error | RuntimeException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Throwable other) {
|
|
||||||
throw new RuntimeException(other);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void throwRetired() {
|
|
||||||
throw new RuntimeException("Player retired");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.fastasyncworldedit.core.util.TaskManager;
|
|||||||
import com.fastasyncworldedit.core.util.image.Drawable;
|
import com.fastasyncworldedit.core.util.image.Drawable;
|
||||||
import com.fastasyncworldedit.core.util.image.ImageUtil;
|
import com.fastasyncworldedit.core.util.image.ImageUtil;
|
||||||
import com.fastasyncworldedit.core.util.image.ImageViewer;
|
import com.fastasyncworldedit.core.util.image.ImageViewer;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -164,7 +165,7 @@ public class BukkitImageViewer implements ImageViewer {
|
|||||||
controller.showInFrames(player, frames, true);
|
controller.showInFrames(player, frames, true);
|
||||||
} else {
|
} else {
|
||||||
int slot = getMapSlot(player);
|
int slot = getMapSlot(player);
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncWith(() -> {
|
||||||
if (slot == -1) {
|
if (slot == -1) {
|
||||||
if (initializing) {
|
if (initializing) {
|
||||||
player.getInventory().setItemInMainHand(new ItemStack(Material.MAP));
|
player.getInventory().setItemInMainHand(new ItemStack(Material.MAP));
|
||||||
@ -175,7 +176,7 @@ public class BukkitImageViewer implements ImageViewer {
|
|||||||
player.getInventory().setHeldItemSlot(slot);
|
player.getInventory().setHeldItemSlot(slot);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
}, BukkitAdapter.adapt(player));
|
||||||
if (image == null && drawable != null) {
|
if (image == null && drawable != null) {
|
||||||
image = drawable.draw();
|
image = drawable.draw();
|
||||||
}
|
}
|
||||||
|
@ -66,12 +66,12 @@ public class BukkitBlockCommandSender extends AbstractCommandBlockActor {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void printRaw(String msg) {
|
public void printRaw(String msg) {
|
||||||
//FAWE start - ensure executed on main thread
|
//FAWE start - ensure executed on main thread
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncAt(() -> {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
sender.sendMessage(part);
|
sender.sendMessage(part);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
}, getLocation());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +79,12 @@ public class BukkitBlockCommandSender extends AbstractCommandBlockActor {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void print(String msg) {
|
public void print(String msg) {
|
||||||
//FAWE start - ensure executed on main thread
|
//FAWE start - ensure executed on main thread
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncAt(() -> {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
print(TextComponent.of(part, TextColor.LIGHT_PURPLE));
|
print(TextComponent.of(part, TextColor.LIGHT_PURPLE));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
}, getLocation());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,12 +92,12 @@ public class BukkitBlockCommandSender extends AbstractCommandBlockActor {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void printDebug(String msg) {
|
public void printDebug(String msg) {
|
||||||
//FAWE start - ensure executed on main thread
|
//FAWE start - ensure executed on main thread
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncAt(() -> {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
print(TextComponent.of(part, TextColor.GRAY));
|
print(TextComponent.of(part, TextColor.GRAY));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
}, getLocation());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,22 +105,22 @@ public class BukkitBlockCommandSender extends AbstractCommandBlockActor {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void printError(String msg) {
|
public void printError(String msg) {
|
||||||
//FAWE start - ensure executed on main thread
|
//FAWE start - ensure executed on main thread
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncAt(() -> {
|
||||||
for (String part : msg.split("\n")) {
|
for (String part : msg.split("\n")) {
|
||||||
print(TextComponent.of(part, TextColor.RED));
|
print(TextComponent.of(part, TextColor.RED));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
}, getLocation());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void print(Component component) {
|
public void print(Component component) {
|
||||||
//FAWE start - ensure executed on main thread
|
//FAWE start - ensure executed on main thread
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncAt(() -> {
|
||||||
TextAdapter.sendMessage(sender, WorldEditText.format(component, getLocale()));
|
TextAdapter.sendMessage(sender, WorldEditText.format(component, getLocale()));
|
||||||
return null;
|
return null;
|
||||||
});
|
}, getLocation());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,10 +172,10 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
|||||||
@Override
|
@Override
|
||||||
public void flushChanges() {
|
public void flushChanges() {
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncWith(() -> {
|
||||||
player.getInventory().setContents(items);
|
player.getInventory().setContents(items);
|
||||||
return null;
|
return null;
|
||||||
});
|
}, BukkitAdapter.adapt(player));
|
||||||
items = null;
|
items = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.SideEffect;
|
import com.sk89q.worldedit.util.SideEffect;
|
||||||
import com.sk89q.worldedit.util.SideEffectSet;
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
@ -146,7 +147,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
|
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
|
|
||||||
List<Entity> ents = TaskManager.taskManager().sync(world::getEntities);
|
List<Entity> ents = List.of(); // TODO TaskManager.taskManager().sync(world::getEntities);
|
||||||
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
|
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
|
||||||
@ -160,7 +161,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
|
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
|
||||||
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
|
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
|
||||||
|
|
||||||
List<Entity> ents = TaskManager.taskManager().sync(getWorld()::getEntities);
|
List<Entity> ents = List.of(); // TaskManager.taskManager().sync(getWorld()::getEntities);
|
||||||
for (Entity entity : ents) {
|
for (Entity entity : ents) {
|
||||||
list.add(BukkitAdapter.adapt(entity));
|
list.add(BukkitAdapter.adapt(entity));
|
||||||
}
|
}
|
||||||
@ -290,7 +291,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().syncAt(() -> {
|
||||||
InventoryHolder chest = (InventoryHolder) state;
|
InventoryHolder chest = (InventoryHolder) state;
|
||||||
Inventory inven = chest.getInventory();
|
Inventory inven = chest.getInventory();
|
||||||
if (chest instanceof Chest) {
|
if (chest instanceof Chest) {
|
||||||
@ -298,7 +299,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
inven.clear();
|
inven.clear();
|
||||||
return null;
|
return null;
|
||||||
});
|
}, new Location(this, pt.toVector3()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public class Fawe {
|
|||||||
}, 0);*/
|
}, 0);*/
|
||||||
|
|
||||||
if (!FoliaSupport.isFolia()) {
|
if (!FoliaSupport.isFolia()) {
|
||||||
TaskManager.taskManager().repeat(timer, 1);
|
// TODO TaskManager.taskManager().repeat(timer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
clipboardExecutor = new KeyQueuedExecutorService<>(new ThreadPoolExecutor(
|
clipboardExecutor = new KeyQueuedExecutorService<>(new ThreadPoolExecutor(
|
||||||
|
@ -27,7 +27,8 @@ public class LazyBaseEntity extends BaseEntity {
|
|||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
setNbt(tmp.get());
|
setNbt(tmp.get());
|
||||||
} else {
|
} else {
|
||||||
setNbt(TaskManager.taskManager().sync(tmp));
|
// TODO
|
||||||
|
// setNbt(TaskManager.taskManager().sync(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.getNbt();
|
return super.getNbt();
|
||||||
|
@ -914,13 +914,13 @@ public class NMSRelighter implements Relighter {
|
|||||||
queue.flush();
|
queue.flush();
|
||||||
finished.set(true);
|
finished.set(true);
|
||||||
} else {
|
} else {
|
||||||
TaskManager.taskManager().sync(new RunnableVal<>() {
|
TaskManager.taskManager().syncAt(new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
queue.flush();
|
queue.flush();
|
||||||
finished.set(true);
|
finished.set(true);
|
||||||
}
|
}
|
||||||
});
|
}, null); // TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,7 +951,8 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (Settings.settings().LIGHTING.ASYNC) {
|
if (Settings.settings().LIGHTING.ASYNC) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
} else {
|
} else {
|
||||||
TaskManager.taskManager().sync(runnable);
|
// TODO
|
||||||
|
// TaskManager.taskManager().sync(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.sk89q.worldedit.entity.Entity;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -49,15 +50,6 @@ public abstract class TaskManager {
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a repeating task on the main thread.
|
|
||||||
*
|
|
||||||
* @param runnable the task to run
|
|
||||||
* @param interval in ticks
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract int repeat(@Nonnull final Runnable runnable, final int interval);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a repeating task asynchronously.
|
* Run a repeating task asynchronously.
|
||||||
*
|
*
|
||||||
@ -79,14 +71,11 @@ public abstract class TaskManager {
|
|||||||
*
|
*
|
||||||
* @param runnable the task to run
|
* @param runnable the task to run
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public void task(@Nonnull final Runnable runnable, @Nonnull Location location) {
|
||||||
public abstract void task(@Nonnull final Runnable runnable);
|
task(runnable, (World) location.getExtent(), location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||||
/**
|
}
|
||||||
* Run a task on the main thread.
|
|
||||||
*
|
public abstract void task(@Nonnull final Runnable runnable, @Nonnull World world, int chunkX, int chunkZ);
|
||||||
* @param runnable the task to run
|
|
||||||
*/
|
|
||||||
public abstract void task(@Nonnull final Runnable runnable, @Nonnull Location contextLocation);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the public ForkJoinPool.
|
* Get the public ForkJoinPool.
|
||||||
@ -182,70 +171,13 @@ public abstract class TaskManager {
|
|||||||
queue.endUnsafe(Fawe.isMainThread());
|
queue.endUnsafe(Fawe.isMainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a task on the current thread or asynchronously.
|
|
||||||
* - If it's already the main thread, it will just call run()
|
|
||||||
*
|
|
||||||
* @param runnable the task to run
|
|
||||||
* @param async whether the task should run on the main thread
|
|
||||||
*/
|
|
||||||
public void taskNow(@Nonnull final Runnable runnable, boolean async) {
|
|
||||||
if (async) {
|
|
||||||
async(runnable);
|
|
||||||
} else {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a task as soon as possible on the main thread.
|
|
||||||
* - Non blocking if not calling from the main thread
|
|
||||||
*
|
|
||||||
* @param runnable the task to run
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void taskNowMain(@Nonnull final Runnable runnable) {
|
|
||||||
if (Fawe.isMainThread()) {
|
|
||||||
runnable.run();
|
|
||||||
} else {
|
|
||||||
task(runnable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a task as soon as possible not on the main thread.
|
|
||||||
*
|
|
||||||
* @param runnable the task to run
|
|
||||||
* @see Fawe#isMainThread()
|
|
||||||
*/
|
|
||||||
public void taskNowAsync(@Nonnull final Runnable runnable) {
|
|
||||||
taskNow(runnable, Fawe.isMainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a task on the main thread at the next tick or now async.
|
|
||||||
*
|
|
||||||
* @param runnable the task to run.
|
|
||||||
* @param async whether the task should run on the main thread
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void taskSoonMain(@Nonnull final Runnable runnable, boolean async) {
|
|
||||||
if (async) {
|
|
||||||
async(runnable);
|
|
||||||
} else {
|
|
||||||
task(runnable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a task later on the main thread.
|
* Run a task later on the main thread.
|
||||||
*
|
*
|
||||||
* @param runnable the task to run
|
* @param runnable the task to run
|
||||||
|
* @param location the location context to run at
|
||||||
* @param delay in ticks
|
* @param delay in ticks
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public abstract void later(@Nonnull final Runnable runnable, final int delay);
|
|
||||||
public abstract void later(@Nonnull final Runnable runnable, Location location, final int delay);
|
public abstract void later(@Nonnull final Runnable runnable, Location location, final int delay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,35 +195,6 @@ public abstract class TaskManager {
|
|||||||
*/
|
*/
|
||||||
public abstract void cancel(final int task);
|
public abstract void cancel(final int task);
|
||||||
|
|
||||||
/**
|
|
||||||
* Break up a task and run it in fragments of 5ms.<br>
|
|
||||||
* - Each task will run on the main thread.<br>
|
|
||||||
*
|
|
||||||
* @param objects the list of objects to run the task for
|
|
||||||
* @param task the task to run on each object
|
|
||||||
* @param whenDone when the object task completes
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public <T> void objectTask(Collection<T> objects, final RunnableVal<T> task, final Runnable whenDone) {
|
|
||||||
final Iterator<T> iterator = objects.iterator();
|
|
||||||
task(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
boolean hasNext;
|
|
||||||
while ((hasNext = iterator.hasNext()) && System.currentTimeMillis() - start < 5) {
|
|
||||||
task.value = iterator.next();
|
|
||||||
task.run();
|
|
||||||
}
|
|
||||||
if (!hasNext) {
|
|
||||||
later(whenDone, 1);
|
|
||||||
} else {
|
|
||||||
later(this, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.
|
* @deprecated Deprecated without replacement as unused internally, and poor implementation of what it's designed to do.
|
||||||
*/
|
*/
|
||||||
@ -333,69 +236,11 @@ public abstract class TaskManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public <T> T syncAt(Supplier<T> supplier, Location context) {
|
||||||
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish.
|
return syncAt(supplier, (World) context.getExtent(), context.getBlockX() >> 4, context.getBlockZ() >> 4);
|
||||||
* - Useful if you need to access something from the Bukkit API from another thread<br>
|
|
||||||
* - Usually wait time is around 25ms<br>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public <T> T syncWhenFree(@Nonnull final RunnableVal<T> function) {
|
|
||||||
if (Fawe.isMainThread()) {
|
|
||||||
function.run();
|
|
||||||
return function.value;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Fawe.instance().getQueueHandler().sync((Supplier<T>) function).get();
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public abstract <T> T syncAt(Supplier<T> supplier, World world, int chunkX, int chunkZ);
|
||||||
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish.
|
|
||||||
* - Useful if you need to access something from the Bukkit API from another thread<br>
|
|
||||||
* - Usually wait time is around 25ms<br>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public <T> T syncWhenFree(@Nonnull final Supplier<T> supplier) {
|
|
||||||
if (Fawe.isMainThread()) {
|
|
||||||
return supplier.get();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Fawe.instance().getQueueHandler().sync(supplier).get();
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Quickly run a task on the main thread, and wait for execution to finish.
|
|
||||||
* - Useful if you need to access something from the Bukkit API from another thread<br>
|
|
||||||
* - Usually wait time is around 25ms
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public <T> T sync(@Nonnull final RunnableVal<T> function) {
|
|
||||||
return sync((Supplier<T>) function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Quickly run a task on the main thread, and wait for execution to finish.
|
|
||||||
* - Useful if you need to access something from the Bukkit API from another thread<br>
|
|
||||||
* - Usually wait time is around 25ms<br>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public <T> T sync(final Supplier<T> function) {
|
|
||||||
if (Fawe.isMainThread()) {
|
|
||||||
return function.get();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Fawe.instance().getQueueHandler().sync(function).get();
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract <T> T syncAt(Supplier<T> supplier, Location context);
|
|
||||||
|
|
||||||
public abstract <T> T syncWith(Supplier<T> supplier, Player context);
|
public abstract <T> T syncWith(Supplier<T> supplier, Player context);
|
||||||
|
|
||||||
|
@ -93,14 +93,16 @@ public class DefaultProgressTracker implements BiConsumer<DefaultProgressTracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void done() {
|
private void done() {
|
||||||
TaskManager.taskManager().task(this::doneTask);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(this::doneTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long lastTick = 0;
|
private long lastTick = 0;
|
||||||
|
|
||||||
private void send() {
|
private void send() {
|
||||||
// Run on main thread
|
// Run on main thread
|
||||||
TaskManager.taskManager().task(this::sendTask);
|
// TODO
|
||||||
|
// TaskManager.taskManager().task(this::sendTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doneTask() {
|
public void doneTask() {
|
||||||
|
@ -40,22 +40,22 @@ public class AsyncPlayer extends PlayerProxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void findFreePosition(Location searchPos) {
|
public void findFreePosition(Location searchPos) {
|
||||||
TaskManager.taskManager().sync(new RunnableVal<Boolean>() {
|
TaskManager.taskManager().syncAt(new RunnableVal<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Boolean value) {
|
public void run(Boolean value) {
|
||||||
getBasePlayer().findFreePosition(searchPos);
|
getBasePlayer().findFreePosition(searchPos);
|
||||||
}
|
}
|
||||||
});
|
}, searchPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOnGround(Location searchPos) {
|
public void setOnGround(Location searchPos) {
|
||||||
TaskManager.taskManager().sync(new RunnableVal<Boolean>() {
|
TaskManager.taskManager().syncAt(new RunnableVal<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Boolean value) {
|
public void run(Boolean value) {
|
||||||
getBasePlayer().setOnGround(searchPos);
|
getBasePlayer().setOnGround(searchPos);
|
||||||
}
|
}
|
||||||
});
|
}, searchPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,12 +70,12 @@ public class AsyncPlayer extends PlayerProxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean ascendLevel() {
|
public boolean ascendLevel() {
|
||||||
return TaskManager.taskManager().sync(() -> getBasePlayer().ascendLevel());
|
return TaskManager.taskManager().syncWith(() -> getBasePlayer().ascendLevel(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean descendLevel() {
|
public boolean descendLevel() {
|
||||||
return TaskManager.taskManager().sync(() -> getBasePlayer().descendLevel());
|
return TaskManager.taskManager().syncWith(() -> getBasePlayer().descendLevel(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -185,15 +185,15 @@ public class AsyncPlayer extends PlayerProxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getBlockTraceFace(final int range, final boolean useLastBlock, @Nullable final Mask stopMask) {
|
public Location getBlockTraceFace(final int range, final boolean useLastBlock, @Nullable final Mask stopMask) {
|
||||||
return TaskManager.taskManager().syncAt(() -> super.getBlockTraceFace(range, useLastBlock, stopMask), getLocation());
|
return TaskManager.taskManager().syncWith(() -> super.getBlockTraceFace(range, useLastBlock, stopMask), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getSolidBlockTrace(int range) {
|
public Location getSolidBlockTrace(int range) {
|
||||||
return TaskManager.taskManager().sync(() -> {
|
return TaskManager.taskManager().syncWith(() -> {
|
||||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||||
return tb.getSolidTargetBlock();
|
return tb.getSolidTargetBlock();
|
||||||
});
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -203,7 +203,7 @@ public class AsyncPlayer extends PlayerProxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean passThroughForwardWall(int range) {
|
public boolean passThroughForwardWall(int range) {
|
||||||
return TaskManager.taskManager().sync(() -> {
|
return TaskManager.taskManager().syncWith(() -> {
|
||||||
int searchDist = 0;
|
int searchDist = 0;
|
||||||
TargetBlock hitBlox = new TargetBlock(AsyncPlayer.this, range, 0.2);
|
TargetBlock hitBlox = new TargetBlock(AsyncPlayer.this, range, 0.2);
|
||||||
Extent world = getLocation().getExtent();
|
Extent world = getLocation().getExtent();
|
||||||
@ -248,7 +248,7 @@ public class AsyncPlayer extends PlayerProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -253,18 +253,20 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulateBlockMine(BlockVector3 pt) {
|
public void simulateBlockMine(BlockVector3 pt) {
|
||||||
TaskManager.taskManager().sync(new RunnableVal<Object>() {
|
TaskManager.taskManager().syncAt(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
parent.simulateBlockMine(pt);
|
parent.simulateBlockMine(pt);
|
||||||
}
|
}
|
||||||
});
|
}, new Location(this, pt.toVector3()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
@Override
|
@Override
|
||||||
public Collection<BaseItemStack> getBlockDrops(final BlockVector3 position) {
|
public Collection<BaseItemStack> getBlockDrops(final BlockVector3 position) {
|
||||||
return TaskManager.taskManager().sync(() -> parent.getBlockDrops(position));
|
return TaskManager.taskManager().syncAt(
|
||||||
|
() -> parent.getBlockDrops(position),
|
||||||
|
new Location(this, position.toVector3()));
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
|
@ -3819,12 +3819,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
if (containsAny) {
|
if (containsAny) {
|
||||||
changes++;
|
changes++;
|
||||||
TaskManager.taskManager().sync(new RunnableVal<Object>() {
|
// TODO this seems to be broken?
|
||||||
|
/* TaskManager.taskManager().sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
regenerateChunk(cx, cz, biome, seed);
|
regenerateChunk(cx, cz, biome, seed);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changes != 0) {
|
if (changes != 0) {
|
||||||
|
@ -709,7 +709,16 @@ public class UtilityCommands {
|
|||||||
|
|
||||||
//FAWE start - run this sync
|
//FAWE start - run this sync
|
||||||
int finalRadius = radius;
|
int finalRadius = radius;
|
||||||
int killed = TaskManager.taskManager().sync(() -> killMatchingEntities(finalRadius, actor, flags::createFunction));
|
int killed;
|
||||||
|
// TODO location context might be somewhere else actually
|
||||||
|
if (actor instanceof Player player) {
|
||||||
|
killed = TaskManager.taskManager().syncWith(
|
||||||
|
() -> killMatchingEntities(finalRadius, actor, flags::createFunction),
|
||||||
|
player
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
killed = 0;
|
||||||
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
actor.print(Caption.of(
|
actor.print(Caption.of(
|
||||||
@ -741,7 +750,9 @@ public class UtilityCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start - run this sync
|
//FAWE start - run this sync
|
||||||
int removed = TaskManager.taskManager().sync(() -> killMatchingEntities(radius, actor, remover::createFunction));
|
int removed = 0;
|
||||||
|
// TODO location context might be somewhere else actually
|
||||||
|
// removed = TaskManager.taskManager().sync(() -> killMatchingEntities(radius, actor, remover::createFunction));
|
||||||
//FAWE end
|
//FAWE end
|
||||||
actor.print(Caption.of("worldedit.remove.removed", TextComponent.of(removed)));
|
actor.print(Caption.of("worldedit.remove.removed", TextComponent.of(removed)));
|
||||||
return removed;
|
return removed;
|
||||||
|
@ -148,7 +148,7 @@ public class EntityRemover {
|
|||||||
if (registryType != null) {
|
if (registryType != null) {
|
||||||
if (type.matches(registryType)) {
|
if (type.matches(registryType)) {
|
||||||
//FAWE start - Calling this async violates thread safety
|
//FAWE start - Calling this async violates thread safety
|
||||||
TaskManager.taskManager().sync(entity::remove);
|
TaskManager.taskManager().syncAt(entity::remove, entity.getLocation());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,8 @@ public abstract class AbstractNonPlayerActor implements Actor {
|
|||||||
if (async) {
|
if (async) {
|
||||||
asyncNotifyQueue.run(wrapped);
|
asyncNotifyQueue.run(wrapped);
|
||||||
} else {
|
} else {
|
||||||
TaskManager.taskManager().taskNow(wrapped, false);
|
// TODO
|
||||||
|
// TaskManager.taskManager().taskNow(wrapped, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +677,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
if (async) {
|
if (async) {
|
||||||
asyncNotifyQueue.run(wrapped);
|
asyncNotifyQueue.run(wrapped);
|
||||||
} else {
|
} else {
|
||||||
TaskManager.taskManager().taskNow(wrapped, false);
|
// TODO
|
||||||
|
// TaskManager.taskManager().taskNow(wrapped, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -687,7 +687,8 @@ public final class PlatformCommandManager {
|
|||||||
Command cmd = optional.get();
|
Command cmd = optional.get();
|
||||||
PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null);
|
PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null);
|
||||||
if (queued != null && !queued.isQueued()) {
|
if (queued != null && !queued.isQueued()) {
|
||||||
TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isMainThread());
|
// TODO?
|
||||||
|
// TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isMainThread());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
actor.decline();
|
actor.decline();
|
||||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
|
|||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
|
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
@ -99,14 +101,15 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
|||||||
Collection<BaseItemStack> drops = world.getBlockDrops(location);
|
Collection<BaseItemStack> drops = world.getBlockDrops(location);
|
||||||
boolean canSet = super.setBlock(location, block);
|
boolean canSet = super.setBlock(location, block);
|
||||||
if (canSet) {
|
if (canSet) {
|
||||||
TaskManager.taskManager().sync(new RunnableVal<>() {
|
final Vector3 position = location.toVector3();
|
||||||
|
TaskManager.taskManager().syncAt(new RunnableVal<>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
for (BaseItemStack stack : drops) {
|
for (BaseItemStack stack : drops) {
|
||||||
world.dropItem(location.toVector3(), stack);
|
world.dropItem(position, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, new Location(world, position));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -170,7 +170,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
uuid
|
uuid
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
TaskManager.taskManager().sync(entity::remove);
|
TaskManager.taskManager().syncAt(entity::remove, entity.getLocation());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren