Use CompletableFuture.runAsync

This commit is contained in:
KennyTV 2020-03-23 11:53:04 +01:00
parent 757654aa9d
commit 248fd92f6e

View File

@ -127,16 +127,8 @@ public class ProtocolRegistry {
if (protocol.hasMappingDataToLoad()) {
if (mappingLoaderExecutor != null) {
// Submit mapping data loading
CompletableFuture<Void> future = new CompletableFuture<>();
CompletableFuture<Void> future = CompletableFuture.runAsync(protocol::loadMappingData, mappingLoaderExecutor);
mappingLoaderFutures.put(protocol.getClass(), future);
mappingLoaderExecutor.execute(() -> {
try {
protocol.loadMappingData();
} catch (Exception e) {
e.printStackTrace();
}
future.complete(null);
});
} else {
// Late protocol adding - just do it on the current thread
protocol.loadMappingData();