Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 19:10:07 +01:00
API Breaking
Removed LoggingChangeSet since it wasn't functional and the majority of it was commented out. Migrated a lot of RunnableVal implementations to Suppliers for improved readability and a very small speed improvement.
Dieser Commit ist enthalten in:
Ursprung
6dd85e48ba
Commit
ceec0ec0b9
@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import java.util.function.Supplier;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.World;
|
||||
@ -71,23 +72,16 @@ public class AsyncChunk implements Chunk {
|
||||
if (Fawe.isMainThread()) {
|
||||
return world.getChunkAt(x, z).getChunkSnapshot(includeMaxblocky, includeBiome, includeBiomeTempRain);
|
||||
}
|
||||
return whenLoaded(new RunnableVal<ChunkSnapshot>() {
|
||||
@Override
|
||||
public void run(ChunkSnapshot value) {
|
||||
this.value = world.getChunkAt(x, z).getChunkSnapshot(includeBiome, includeBiome, includeBiomeTempRain);
|
||||
}
|
||||
});
|
||||
return whenLoaded(() -> world.getChunkAt(x, z).getChunkSnapshot(includeBiome, includeBiome, includeBiomeTempRain));
|
||||
}
|
||||
|
||||
private <T> T whenLoaded(RunnableVal<T> task) {
|
||||
private <T> T whenLoaded(Supplier<T> task) {
|
||||
if (Fawe.isMainThread()) {
|
||||
task.run();
|
||||
return task.value;
|
||||
return task.get();
|
||||
}
|
||||
if (world.isWorld()) {
|
||||
if (world.isChunkLoaded(x, z)) {
|
||||
task.run();
|
||||
return task.value;
|
||||
return task.get();
|
||||
}
|
||||
}
|
||||
return TaskManager.IMP.sync(task);
|
||||
@ -98,12 +92,7 @@ public class AsyncChunk implements Chunk {
|
||||
if (!isLoaded()) {
|
||||
return new Entity[0];
|
||||
}
|
||||
return whenLoaded(new RunnableVal<Entity[]>() {
|
||||
@Override
|
||||
public void run(Entity[] value) {
|
||||
world.getChunkAt(x, z).getEntities();
|
||||
}
|
||||
});
|
||||
return whenLoaded(() -> world.getChunkAt(x, z).getEntities());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,12 +100,7 @@ public class AsyncChunk implements Chunk {
|
||||
if (!isLoaded()) {
|
||||
return new BlockState[0];
|
||||
}
|
||||
return TaskManager.IMP.sync(new RunnableVal<BlockState[]>() {
|
||||
@Override
|
||||
public void run(BlockState[] value) {
|
||||
this.value = world.getChunkAt(x, z).getTileEntities();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> world.getChunkAt(x, z).getTileEntities());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,12 +108,7 @@ public class AsyncChunk implements Chunk {
|
||||
if (!isLoaded()) {
|
||||
return new BlockState[0];
|
||||
}
|
||||
return TaskManager.IMP.sync(new RunnableVal<BlockState[]>() {
|
||||
@Override
|
||||
public void run(BlockState[] value) {
|
||||
this.value = world.getChunkAt(x, z).getTileEntities(useSnapshot);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> world.getChunkAt(x, z).getTileEntities(useSnapshot));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -139,12 +118,7 @@ public class AsyncChunk implements Chunk {
|
||||
|
||||
@Override
|
||||
public boolean load(final boolean generate) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = world.loadChunk(x, z, generate);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> world.loadChunk(x, z, generate));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,6 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -156,12 +155,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public WorldBorder getWorldBorder() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<WorldBorder>() {
|
||||
@Override
|
||||
public void run(WorldBorder value) {
|
||||
this.value = parent.getWorldBorder();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getWorldBorder());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -340,12 +334,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
@Override
|
||||
public boolean loadChunk(final int x, final int z, final boolean generate) {
|
||||
if (!isChunkLoaded(x, z)) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.loadChunk(x, z, generate);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.loadChunk(x, z, generate));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -353,12 +342,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
@Override
|
||||
public boolean unloadChunk(final Chunk chunk) {
|
||||
if (chunk.isLoaded()) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.unloadChunk(chunk);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.unloadChunk(chunk));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -371,12 +355,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
@Override
|
||||
public boolean unloadChunk(int x, int z, boolean save) {
|
||||
if (isChunkLoaded(x, z)) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.unloadChunk(x, z, save);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.unloadChunk(x, z, save));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -384,24 +363,14 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
@Override
|
||||
public boolean unloadChunkRequest(int x, int z) {
|
||||
if (isChunkLoaded(x, z)) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.unloadChunkRequest(x, z);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.unloadChunkRequest(x, z));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(final int x, final int z) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.regenerateChunk(x, z);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.regenerateChunk(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -412,32 +381,17 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public Item dropItem(final Location location, final ItemStack item) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Item>() {
|
||||
@Override
|
||||
public void run(Item value) {
|
||||
this.value = parent.dropItem(location, item);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.dropItem(location, item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item dropItemNaturally(final Location location, final ItemStack item) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Item>() {
|
||||
@Override
|
||||
public void run(Item value) {
|
||||
this.value = parent.dropItemNaturally(location, item);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.dropItemNaturally(location, item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow spawnArrow(final Location location, final Vector direction, final float speed, final float spread) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Arrow>() {
|
||||
@Override
|
||||
public void run(Arrow value) {
|
||||
this.value = parent.spawnArrow(location, direction, speed, spread);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawnArrow(location, direction, speed, spread));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -447,22 +401,12 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public boolean generateTree(final Location location, final TreeType type) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.generateTree(location, type);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.generateTree(location, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(final Location loc, final TreeType type, final BlockChangeDelegate delegate) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.generateTree(loc, type, delegate);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.generateTree(loc, type, delegate));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -472,93 +416,48 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public LightningStrike strikeLightning(final Location loc) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<LightningStrike>() {
|
||||
@Override
|
||||
public void run(LightningStrike value) {
|
||||
this.value = parent.strikeLightning(loc);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.strikeLightning(loc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LightningStrike strikeLightningEffect(final Location loc) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<LightningStrike>() {
|
||||
@Override
|
||||
public void run(LightningStrike value) {
|
||||
this.value = parent.strikeLightningEffect(loc);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.strikeLightningEffect(loc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getEntities() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<List<Entity>>() {
|
||||
@Override
|
||||
public void run(List<Entity> value) {
|
||||
this.value = parent.getEntities();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getEntities());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LivingEntity> getLivingEntities() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<List<LivingEntity>>() {
|
||||
@Override
|
||||
public void run(List<LivingEntity> value) {
|
||||
this.value = parent.getLivingEntities();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getLivingEntities());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <T extends Entity> Collection<T> getEntitiesByClass(final Class<T>... classes) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
|
||||
@Override
|
||||
public void run(Collection<T> value) {
|
||||
this.value = parent.getEntitiesByClass(classes);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(classes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> Collection<T> getEntitiesByClass(final Class<T> cls) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
|
||||
@Override
|
||||
public void run(Collection<T> value) {
|
||||
this.value = parent.getEntitiesByClass(cls);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClass(cls));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getEntitiesByClasses(final Class<?>... classes) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<Entity>>() {
|
||||
@Override
|
||||
public void run(Collection<Entity> value) {
|
||||
this.value = parent.getEntitiesByClasses(classes);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getEntitiesByClasses(classes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getPlayers() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<List<Player>>() {
|
||||
@Override
|
||||
public void run(List<Player> value) {
|
||||
this.value = parent.getPlayers();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getPlayers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getNearbyEntities(final Location location, final double x, final double y, final double z) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<Entity>>() {
|
||||
@Override
|
||||
public void run(Collection<Entity> value) {
|
||||
this.value = parent.getNearbyEntities(location, x, y, z);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getNearbyEntities(location, x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -578,12 +477,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public boolean setSpawnLocation(final int x, final int y, final int z) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.setSpawnLocation(x, y, z);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.setSpawnLocation(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -658,23 +552,16 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(final double x, final double y, final double z, final float power, final boolean setFire, final boolean breakBlocks) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.createExplosion(x, y, z, power, setFire, breakBlocks);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(
|
||||
() ->
|
||||
parent.createExplosion(x, y, z, power, setFire, breakBlocks));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(double x, double y, double z, float power, boolean setFire,
|
||||
boolean breakBlocks, @Nullable Entity source) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = parent.createExplosion(x, y, z, power, setFire, breakBlocks, source);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(
|
||||
() -> parent.createExplosion(x, y, z, power, setFire, breakBlocks, source));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -730,32 +617,17 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public <T extends Entity> T spawn(final Location location, final Class<T> clazz) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(new RunnableVal<T>() {
|
||||
@Override
|
||||
public void run(T value) {
|
||||
this.value = parent.spawn(location, clazz);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(new RunnableVal<T>() {
|
||||
@Override
|
||||
public void run(T value) {
|
||||
this.value = parent.spawn(location, clazz, function);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawn(location, clazz, function));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(new RunnableVal<FallingBlock>() {
|
||||
@Override
|
||||
public void run(FallingBlock value) {
|
||||
this.value = parent.spawnFallingBlock(location, data);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, data));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -801,12 +673,8 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public ChunkSnapshot getEmptyChunkSnapshot(final int x, final int z, final boolean includeBiome, final boolean includeBiomeTempRain) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<ChunkSnapshot>() {
|
||||
@Override
|
||||
public void run(ChunkSnapshot value) {
|
||||
this.value = parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(
|
||||
() -> parent.getEmptyChunkSnapshot(x, z, includeBiome, includeBiomeTempRain));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1254,52 +1122,27 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
||||
|
||||
@Override
|
||||
public int getEntityCount() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
|
||||
@Override
|
||||
public void run(Integer value) {
|
||||
this.value = parent.getEntityCount();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getEntityCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityCount() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
|
||||
@Override
|
||||
public void run(Integer value) {
|
||||
this.value = parent.getTileEntityCount();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getTileEntityCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickableTileEntityCount() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
|
||||
@Override
|
||||
public void run(Integer value) {
|
||||
this.value = parent.getTickableTileEntityCount();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getTickableTileEntityCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChunkCount() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
|
||||
@Override
|
||||
public void run(Integer value) {
|
||||
this.value = parent.getChunkCount();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getChunkCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerCount() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
|
||||
@Override
|
||||
public void run(Integer value) {
|
||||
this.value = parent.getPlayerCount();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getPlayerCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,66 +0,0 @@
|
||||
package com.boydti.fawe.logging;
|
||||
|
||||
import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet;
|
||||
import com.boydti.fawe.object.changeset.AbstractChangeSet;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
//import org.primesoft.blockshub.IBlocksHubApi;
|
||||
//import org.primesoft.blockshub.api.IPlayer;
|
||||
//import org.primesoft.blockshub.api.IWorld;
|
||||
|
||||
public class LoggingChangeSet extends AbstractDelegateChangeSet {
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static AbstractChangeSet wrap(Player player, AbstractChangeSet parent) {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
// api = (IBlocksHubApi) Fawe.imp().getBlocksHubApi();
|
||||
}
|
||||
// if (api == null) {
|
||||
return parent;
|
||||
// }
|
||||
// return new LoggingChangeSet(player, parent);
|
||||
}
|
||||
|
||||
// public static IBlocksHubApi api;
|
||||
//
|
||||
// private final MutableVector3 loc;
|
||||
// private final IPlayer player;
|
||||
// private IWorld world;
|
||||
// private final MutableBlockData oldBlock;
|
||||
// private final MutableBlockData newBlock;
|
||||
|
||||
private LoggingChangeSet(Player player, AbstractChangeSet parent) {
|
||||
super(parent);
|
||||
// String world = player.getLocation().world;
|
||||
// try {
|
||||
// Class<?> classBukkitWorld = Class.forName("org.primesoft.blockshub.platform.bukkit.BukkitWorld");
|
||||
// Class<?> classAsyncWorld = Class.forName("com.boydti.fawe.bukkit.wrapper.AsyncWorld");
|
||||
// Object asyncWorld = classAsyncWorld.getConstructor(String.class, boolean.class).newInstance(world, false);
|
||||
// Constructor<?> constructor = classBukkitWorld.getDeclaredConstructors()[0];
|
||||
// constructor.setAccessible(true);
|
||||
// this.world = (IWorld) constructor.newInstance(asyncWorld);
|
||||
// } catch (Throwable ignore) {
|
||||
// this.world = api.getWorld(world);
|
||||
// }
|
||||
// this.loc = new MutableVector3();
|
||||
// this.oldBlock = new MutableBlockData();
|
||||
// this.newBlock = new MutableBlockData();
|
||||
// this.player = api.getPlayer(player.getUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int x, int y, int z, int combinedId4DataFrom, int combinedId4DataTo) {
|
||||
// Mutable (avoids object creation)
|
||||
// loc.x = x;
|
||||
// loc.y = y;
|
||||
// loc.z = z;
|
||||
// oldBlock.id = FaweCache.IMP.getId(combinedId4DataFrom);
|
||||
// oldBlock.data = FaweCache.IMP.getData(combinedId4DataFrom);
|
||||
// newBlock.id = FaweCache.IMP.getId(combinedId4DataTo);
|
||||
// newBlock.data = FaweCache.IMP.getData(combinedId4DataTo);
|
||||
// // Log to BlocksHub and parent
|
||||
// api.logBlock(loc, player, world, oldBlock, newBlock);
|
||||
parent.add(x, y, z, combinedId4DataFrom, combinedId4DataTo);
|
||||
}
|
||||
}
|
@ -4,9 +4,10 @@ import com.sk89q.worldedit.entity.MapMetadatable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class Metadatable implements MapMetadatable {
|
||||
private final ConcurrentHashMap<String, Object> meta = new ConcurrentHashMap<>();
|
||||
private final ConcurrentMap<String, Object> meta = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRawMeta() {
|
||||
|
@ -13,7 +13,6 @@ import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
|
||||
import com.sk89q.worldedit.util.Identifiable;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.logging.LoggingChangeSet;
|
||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.HistoryExtent;
|
||||
@ -80,7 +79,7 @@ public class EditSessionBuilder {
|
||||
public EditSessionBuilder(@Nonnull World world) {
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
this.worldName = Fawe.imp().getWorldName(world);
|
||||
this.worldName = world.getName();
|
||||
}
|
||||
|
||||
public EditSessionBuilder(World world, String worldName) {
|
||||
@ -389,13 +388,7 @@ public class EditSessionBuilder {
|
||||
if (command != null && changeSet instanceof RollbackOptimizedHistory) {
|
||||
((RollbackOptimizedHistory) changeSet).setCommand(this.command);
|
||||
}
|
||||
if (changeSet instanceof NullChangeSet && Fawe.imp().getBlocksHubApi() != null && player != null) {
|
||||
changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||
}
|
||||
if (!(changeSet instanceof NullChangeSet)) {
|
||||
if (!(changeSet instanceof LoggingChangeSet) && player != null && Fawe.imp().getBlocksHubApi() != null) {
|
||||
changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||
}
|
||||
if (this.blockBag != null) {
|
||||
System.out.println("TODO implement block bag as IBatchProcessor");
|
||||
changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
|
||||
|
@ -89,6 +89,7 @@ import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
import net.jpountz.lz4.LZ4InputStream;
|
||||
import net.jpountz.lz4.LZ4Utils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MainUtil {
|
||||
|
||||
@ -371,15 +372,11 @@ public class MainUtil {
|
||||
return new FaweInputStream(new FastBufferedInputStream(is));
|
||||
}
|
||||
|
||||
public static URL upload(UUID uuid, String file, String extension, final RunnableVal<OutputStream> writeTask) {
|
||||
public static URL upload(UUID uuid, String file, String extension, @NotNull final RunnableVal<OutputStream> writeTask) {
|
||||
return upload(Settings.IMP.WEB.URL, uuid != null, uuid != null ? uuid.toString() : null, file, extension, writeTask);
|
||||
}
|
||||
|
||||
public static URL upload(String urlStr, boolean save, String uuid, String file, String extension, final RunnableVal<OutputStream> writeTask) {
|
||||
if (writeTask == null) {
|
||||
getLogger(MainUtil.class).debug("Write task cannot be null");
|
||||
return null;
|
||||
}
|
||||
public static URL upload(String urlStr, boolean save, String uuid, String file, String extension, @NotNull final RunnableVal<OutputStream> writeTask) {
|
||||
String filename = (file == null ? "plot" : file) + (extension != null ? "." + extension : "");
|
||||
uuid = uuid == null ? UUID.randomUUID().toString() : uuid;
|
||||
final String website;
|
||||
|
@ -22,7 +22,7 @@ public abstract class TaskManager {
|
||||
|
||||
public static TaskManager IMP;
|
||||
|
||||
private ForkJoinPool pool = new ForkJoinPool();
|
||||
private final ForkJoinPool pool = new ForkJoinPool();
|
||||
|
||||
/**
|
||||
* Run a repeating task on the main thread
|
||||
@ -307,6 +307,22 @@ public abstract class TaskManager {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish:<br>
|
||||
* - Useful if you need to access something from the Bukkit API from another thread<br>
|
||||
* - Usually wait time is around 25ms<br>
|
||||
*/
|
||||
public <T> T syncWhenFree(@NotNull final Supplier<T> supplier) {
|
||||
if (Fawe.isMainThread()) {
|
||||
return supplier.get();
|
||||
}
|
||||
try {
|
||||
return Fawe.get().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:<br>
|
||||
|
@ -66,22 +66,12 @@ public class AsyncPlayer extends PlayerProxy {
|
||||
|
||||
@Override
|
||||
public boolean ascendLevel() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = getBasePlayer().ascendLevel();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> getBasePlayer().ascendLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean descendLevel() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
this.value = getBasePlayer().descendLevel();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> getBasePlayer().descendLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -175,34 +165,25 @@ public class AsyncPlayer extends PlayerProxy {
|
||||
|
||||
@Override
|
||||
public Location getBlockTrace(int range, boolean useLastBlock) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Location>() {
|
||||
@Override
|
||||
public void run(Location value) {
|
||||
return TaskManager.IMP.sync(() -> {
|
||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||
this.value = useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock();
|
||||
}
|
||||
});
|
||||
return useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBlockTraceFace(int range, boolean useLastBlock) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Location>() {
|
||||
@Override
|
||||
public void run(Location value) {
|
||||
return TaskManager.IMP.sync(() -> {
|
||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||
this.value = useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace();
|
||||
}
|
||||
});
|
||||
return useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSolidBlockTrace(int range) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<Location>() {
|
||||
@Override
|
||||
public void run(Location value) {
|
||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||
this.value = tb.getSolidTargetBlock();
|
||||
}
|
||||
return TaskManager.IMP.sync(() -> {
|
||||
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
|
||||
return tb.getSolidTargetBlock();
|
||||
});
|
||||
}
|
||||
|
||||
@ -256,4 +237,4 @@ public class AsyncPlayer extends PlayerProxy {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,22 +243,12 @@ public class WorldWrapper extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<List<? extends Entity>>() {
|
||||
@Override
|
||||
public void run(List<? extends Entity> value) {
|
||||
this.value = parent.getEntities(region);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.getEntities(region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<List<? extends Entity>>() {
|
||||
@Override
|
||||
public void run(List<? extends Entity> value) {
|
||||
this.value = parent.getEntities();
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(parent::getEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,7 +3,6 @@ package com.sk89q.worldedit.extension.platform.binding;
|
||||
import com.boydti.fawe.config.Caption;
|
||||
import com.boydti.fawe.database.DBHandler;
|
||||
import com.boydti.fawe.database.RollbackDatabase;
|
||||
import com.boydti.fawe.logging.LoggingChangeSet;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren