fix: move main-thread call to be implementation from WorldWrapper (#1991)

- Fixes #1990
This commit is contained in:
Jordan 2022-10-23 20:22:53 +01:00 committed by GitHub
parent bf28ab47b8
commit 0d112b2913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -144,7 +144,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 = world.getEntities(); List<Entity> ents = 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()))) {
@ -157,7 +157,9 @@ public class BukkitWorld extends AbstractWorld {
@Override @Override
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<>();
for (Entity entity : getWorld().getEntities()) {
List<Entity> ents = TaskManager.taskManager().sync(getWorld()::getEntities);
for (Entity entity : ents) {
list.add(BukkitAdapter.adapt(entity)); list.add(BukkitAdapter.adapt(entity));
} }
return list; return list;

View File

@ -320,12 +320,12 @@ public class WorldWrapper extends AbstractWorld {
@Override @Override
public List<? extends Entity> getEntities(Region region) { public List<? extends Entity> getEntities(Region region) {
return TaskManager.taskManager().sync(() -> parent.getEntities(region)); return parent.getEntities(region);
} }
@Override @Override
public List<? extends Entity> getEntities() { public List<? extends Entity> getEntities() {
return TaskManager.taskManager().sync(parent::getEntities); return parent.getEntities();
} }
@Override @Override