diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java
index 084778789..d90fc50c8 100644
--- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java
+++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java
@@ -10,6 +10,7 @@ import com.fastasyncworldedit.core.queue.IBatchProcessor;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
import com.fastasyncworldedit.core.util.NbtUtils;
+import com.fastasyncworldedit.core.util.TaskManager;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -561,27 +562,34 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
); // bukkit skips the feature gen which does this offset normally, so we have to add it back
}
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
- serverLevel.captureTreeGeneration = true;
- serverLevel.captureBlockStates = true;
- boolean grownTree = bukkitWorld.generateTree(BukkitAdapter.adapt(bukkitWorld, blockVector3), bukkitType);
- serverLevel.captureBlockStates = false;
- serverLevel.captureTreeGeneration = false;
- if (!grownTree) {
- serverLevel.capturedBlockStates.clear();
- return false;
- } else {
- for (CraftBlockState craftBlockState : serverLevel.capturedBlockStates.values()) {
- if (craftBlockState == null || craftBlockState.getType() == Material.AIR) {
- continue;
+ final BlockVector3 finalBlockVector = blockVector3;
+ // Sync to main thread to ensure no clashes occur
+ Map placed = TaskManager.taskManager().sync(() -> {
+ serverLevel.captureTreeGeneration = true;
+ serverLevel.captureBlockStates = true;
+ try {
+ if (!bukkitWorld.generateTree(BukkitAdapter.adapt(bukkitWorld, finalBlockVector), bukkitType)) {
+ return null;
}
- editSession.setBlock(craftBlockState.getX(), craftBlockState.getY(), craftBlockState.getZ(),
- BukkitAdapter.adapt(((org.bukkit.block.BlockState) craftBlockState).getBlockData())
- );
+ return ImmutableMap.copyOf(serverLevel.capturedBlockStates);
+ } finally {
+ serverLevel.captureBlockStates = false;
+ serverLevel.captureTreeGeneration = false;
+ serverLevel.capturedBlockStates.clear();
}
-
- serverLevel.capturedBlockStates.clear();
- return true;
+ });
+ if (placed == null || placed.isEmpty()) {
+ return false;
}
+ for (CraftBlockState craftBlockState : placed.values()) {
+ if (craftBlockState == null || craftBlockState.getType() == Material.AIR) {
+ continue;
+ }
+ editSession.setBlock(craftBlockState.getX(), craftBlockState.getY(), craftBlockState.getZ(),
+ BukkitAdapter.adapt(((org.bukkit.block.BlockState) craftBlockState).getBlockData())
+ );
+ }
+ return true;
}
@Override
diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweAdapter.java
index f8b9b5752..31d087ff0 100644
--- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweAdapter.java
+++ b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweAdapter.java
@@ -10,6 +10,7 @@ import com.fastasyncworldedit.core.queue.IBatchProcessor;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
import com.fastasyncworldedit.core.util.NbtUtils;
+import com.fastasyncworldedit.core.util.TaskManager;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -553,27 +554,34 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
); // bukkit skips the feature gen which does this offset normally, so we have to add it back
}
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
- serverLevel.captureTreeGeneration = true;
- serverLevel.captureBlockStates = true;
- boolean grownTree = bukkitWorld.generateTree(BukkitAdapter.adapt(bukkitWorld, blockVector3), bukkitType);
- serverLevel.captureBlockStates = false;
- serverLevel.captureTreeGeneration = false;
- if (!grownTree) {
- serverLevel.capturedBlockStates.clear();
- return false;
- } else {
- for (CraftBlockState craftBlockState : serverLevel.capturedBlockStates.values()) {
- if (craftBlockState == null || craftBlockState.getType() == Material.AIR) {
- continue;
+ final BlockVector3 finalBlockVector = blockVector3;
+ // Sync to main thread to ensure no clashes occur
+ Map placed = TaskManager.taskManager().sync(() -> {
+ serverLevel.captureTreeGeneration = true;
+ serverLevel.captureBlockStates = true;
+ try {
+ if (!bukkitWorld.generateTree(BukkitAdapter.adapt(bukkitWorld, finalBlockVector), bukkitType)) {
+ return null;
}
- editSession.setBlock(craftBlockState.getX(), craftBlockState.getY(), craftBlockState.getZ(),
- BukkitAdapter.adapt(((org.bukkit.block.BlockState) craftBlockState).getBlockData())
- );
+ return ImmutableMap.copyOf(serverLevel.capturedBlockStates);
+ } finally {
+ serverLevel.captureBlockStates = false;
+ serverLevel.captureTreeGeneration = false;
+ serverLevel.capturedBlockStates.clear();
}
-
- serverLevel.capturedBlockStates.clear();
- return true;
+ });
+ if (placed == null || placed.isEmpty()) {
+ return false;
}
+ for (CraftBlockState craftBlockState : placed.values()) {
+ if (craftBlockState == null || craftBlockState.getType() == Material.AIR) {
+ continue;
+ }
+ editSession.setBlock(craftBlockState.getX(), craftBlockState.getY(), craftBlockState.getZ(),
+ BukkitAdapter.adapt(((org.bukkit.block.BlockState) craftBlockState).getBlockData())
+ );
+ }
+ return true;
}
@Override
diff --git a/worldedit-bukkit/adapters/adapter-1_19/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R1/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_19/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R1/PaperweightFaweAdapter.java
index 809283df5..997e11e21 100644
--- a/worldedit-bukkit/adapters/adapter-1_19/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R1/PaperweightFaweAdapter.java
+++ b/worldedit-bukkit/adapters/adapter-1_19/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R1/PaperweightFaweAdapter.java
@@ -10,6 +10,7 @@ import com.fastasyncworldedit.core.queue.IBatchProcessor;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
import com.fastasyncworldedit.core.util.NbtUtils;
+import com.fastasyncworldedit.core.util.TaskManager;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -554,27 +555,34 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
); // bukkit skips the feature gen which does this offset normally, so we have to add it back
}
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
- serverLevel.captureTreeGeneration = true;
- serverLevel.captureBlockStates = true;
- boolean grownTree = bukkitWorld.generateTree(BukkitAdapter.adapt(bukkitWorld, blockVector3), bukkitType);
- serverLevel.captureBlockStates = false;
- serverLevel.captureTreeGeneration = false;
- if (!grownTree) {
- serverLevel.capturedBlockStates.clear();
- return false;
- } else {
- for (CraftBlockState craftBlockState : serverLevel.capturedBlockStates.values()) {
- if (craftBlockState == null || craftBlockState.getType() == Material.AIR) {
- continue;
+ final BlockVector3 finalBlockVector = blockVector3;
+ // Sync to main thread to ensure no clashes occur
+ Map placed = TaskManager.taskManager().sync(() -> {
+ serverLevel.captureTreeGeneration = true;
+ serverLevel.captureBlockStates = true;
+ try {
+ if (!bukkitWorld.generateTree(BukkitAdapter.adapt(bukkitWorld, finalBlockVector), bukkitType)) {
+ return null;
}
- editSession.setBlock(craftBlockState.getX(), craftBlockState.getY(), craftBlockState.getZ(),
- BukkitAdapter.adapt(((org.bukkit.block.BlockState) craftBlockState).getBlockData())
- );
+ return ImmutableMap.copyOf(serverLevel.capturedBlockStates);
+ } finally {
+ serverLevel.captureBlockStates = false;
+ serverLevel.captureTreeGeneration = false;
+ serverLevel.capturedBlockStates.clear();
}
-
- serverLevel.capturedBlockStates.clear();
- return true;
+ });
+ if (placed == null || placed.isEmpty()) {
+ return false;
}
+ for (CraftBlockState craftBlockState : placed.values()) {
+ if (craftBlockState == null || craftBlockState.getType() == Material.AIR) {
+ continue;
+ }
+ editSession.setBlock(craftBlockState.getX(), craftBlockState.getY(), craftBlockState.getZ(),
+ BukkitAdapter.adapt(((org.bukkit.block.BlockState) craftBlockState).getBlockData())
+ );
+ }
+ return true;
}
@Override
diff --git a/worldedit-bukkit/adapters/adapter-legacy/src/main/resources/worldedit-adapters.jar b/worldedit-bukkit/adapters/adapter-legacy/src/main/resources/worldedit-adapters.jar
index 136135971..e6ed1ff79 100644
Binary files a/worldedit-bukkit/adapters/adapter-legacy/src/main/resources/worldedit-adapters.jar and b/worldedit-bukkit/adapters/adapter-legacy/src/main/resources/worldedit-adapters.jar differ
diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
index 9017f9866..1fa1b3646 100644
--- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
+++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
@@ -24,7 +24,6 @@ import com.fastasyncworldedit.core.Fawe;
import com.fastasyncworldedit.core.internal.exception.FaweException;
import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
-import com.fastasyncworldedit.core.util.TaskManager;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.sk89q.jnbt.CompoundTag;
@@ -334,9 +333,7 @@ public class BukkitWorld extends AbstractWorld {
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) {
//FAWE start - allow tree commands to be undone and obey region restrictions
- return TaskManager.taskManager().sync(() -> WorldEditPlugin.getInstance().getBukkitImplAdapter().generateTree(type, editSession, pt,
- getWorld()
- ));
+ return WorldEditPlugin.getInstance().getBukkitImplAdapter().generateTree(type, editSession, pt, getWorld());
//FAWE end
}
diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java
index fcaf33288..4c5339017 100644
--- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java
+++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java
@@ -77,7 +77,7 @@ public class FaweAPI {
*
*
* @param world The name of the world
- * @param autoQueue If it should start dispatching before you enqueue it.
+ * @param autoQueue If it should start dispatching before you close/flush it.
* @return the queue extent
*/
public static IQueueExtent createQueue(World world, boolean autoQueue) {
diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java
index 282f37509..2893b7290 100644
--- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java
+++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/WorldWrapper.java
@@ -273,13 +273,11 @@ public class WorldWrapper extends AbstractWorld {
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws
MaxChangedBlocksException {
- return TaskManager.taskManager().sync(() -> {
- try {
- return parent.generateTree(type, editSession, position);
- } catch (MaxChangedBlocksException e) {
- throw new RuntimeException(e);
- }
- });
+ try {
+ return parent.generateTree(type, editSession, position);
+ } catch (MaxChangedBlocksException e) {
+ throw new RuntimeException(e);
+ }
}
@Override