From 563c5f830d8418bbd084d9ba5a71a714de6b5032 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Mon, 23 Mar 2020 12:22:34 +0100 Subject: [PATCH] Don't expose executor and future map --- .../api/protocol/ProtocolRegistry.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index 4c3180c9a..d4ae5e12e 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -127,8 +127,7 @@ public class ProtocolRegistry { if (protocol.hasMappingDataToLoad()) { if (mappingLoaderExecutor != null) { // Submit mapping data loading - CompletableFuture future = CompletableFuture.runAsync(protocol::loadMappingData, mappingLoaderExecutor); - mappingLoaderFutures.put(protocol.getClass(), future); + addMappingLoaderFuture(protocol.getClass(), protocol::loadMappingData); } else { // Late protocol adding - just do it on the current thread protocol.loadMappingData(); @@ -330,15 +329,12 @@ public class ProtocolRegistry { } } + public static void addMappingLoaderFuture(Class protocolClass, Runnable runnable) { + CompletableFuture future = CompletableFuture.runAsync(runnable, mappingLoaderExecutor); + mappingLoaderFutures.put(protocolClass, future); + } + public static CompletableFuture getMappingLoaderFuture(Class protocolClass) { return mappingLoaderFutures.get(protocolClass); } - - public static Map, CompletableFuture> getMappingLoaderFutures() { - return mappingLoaderFutures; - } - - public static ThreadPoolExecutor getMappingLoaderExecutor() { - return mappingLoaderExecutor; - } }