got paste -e working, still throws IllegalStateException but idc

This commit is contained in:
Aurora 2020-06-26 13:52:18 +02:00
parent aac02ceea1
commit 54008be1a2
No known key found for this signature in database
GPG Key ID: 89839F67B53656AD
2 changed files with 16 additions and 2 deletions

View File

@ -54,6 +54,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.bukkit.Effect;
import org.bukkit.TreeType;
@ -61,6 +64,7 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory;
@ -115,7 +119,7 @@ public class BukkitWorld extends AbstractWorld {
@Override
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
if (adapter != null && Fawe.isMainThread()) {
try {
Entity createdEntity = adapter.createEntity(BukkitAdapter.adapt(getWorld(), location), entity);
if (createdEntity != null) {
@ -131,6 +135,16 @@ public class BukkitWorld extends AbstractWorld {
e.printStackTrace();
return null;
}
} else if (adapter != null && !Fawe.isMainThread()){
Future<com.sk89q.worldedit.entity.Entity> future = Fawe.get().getQueueHandler().sync((Supplier<com.sk89q.worldedit.entity.Entity>)() -> this.createEntity(location, entity));
while (!future.isDone()) {
((CraftWorld)worldRef.get()).getHandle().getChunkProvider().runTasks();
}
try {
return future.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
} else {
return null;
}