Skip to content

Commit

Permalink
Rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed Dec 5, 2024
1 parent 6579341 commit dcc2726
Showing 1 changed file with 1 addition and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,7 @@ public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B
public BaseBlock getFullBlock(BlockVector3 position) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
final org.bukkit.Location location = BukkitAdapter.adapt(getWorld(), position);
return getRegion(location, () -> {
return adapter.getFullBlock(location);
});
return adapter.getFullBlock(BukkitAdapter.adapt(getWorld(), position));
} else {
return getBlock(position).toBaseBlock();
}
Expand Down Expand Up @@ -558,21 +555,4 @@ public boolean setBiome(BlockVector3 position, BiomeType biome) {
}
return true;
}

private <T> T getRegion(org.bukkit.Location location, java.util.concurrent.Callable<T> callable) {
java.util.concurrent.CompletableFuture<T> future = new java.util.concurrent.CompletableFuture<>();
org.bukkit.Bukkit.getRegionScheduler().execute(WorldEditPlugin.getInstance(), location, () -> {
try {
T result = callable.call();
future.complete(result);
} catch (Exception e) {
future.completeExceptionally(e);
}
});
try {
return future.get(); // This will block until the computation is done
} catch (InterruptedException | java.util.concurrent.ExecutionException e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit dcc2726

Please sign in to comment.