I want to get a value inside a CompletableFuture (in this case clonedWorld) in another CompletableFuture and return that future. This is my code, and I'm stuck here:
@Override
public CompletableFuture<SlimeWorld> asyncCloneWorld(String worldName, String newWorld) {
loadWorldAsync(worldName).whenComplete((slimeWorld, throwable) -> {
if (throwable != null || slimeWorld.isEmpty()) {
plugin.getLogger().log(Level.SEVERE, "Impossibile caricare il mondo template!", throwable);
return;
}
try {
SlimeWorld clonedWorld = slimeWorld.get().clone(newWorld, loader, true);
} catch (IOException | WorldAlreadyExistsException e) {
plugin.getLogger().log(Level.SEVERE, "Non è stato possibile clonare il mondo: " + worldName, e);
}
});
return ?;
}