From a8fbb000eb4eb1e0816834fa09fd5a608d28053e Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 15 Feb 2024 18:27:52 +0100 Subject: [PATCH] Add ProtocolManager#hasLoadedMappings --- .../viaversion/api/protocol/ProtocolManager.java | 15 +++++++++++---- .../viaversion/protocol/ProtocolManagerImpl.java | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolManager.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolManager.java index 1d4465edd..d50d3f0c8 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolManager.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/ProtocolManager.java @@ -168,10 +168,10 @@ public interface ProtocolManager { * @throws IllegalArgumentException if both packet classes are null */ VersionedPacketTransformer createPacketTransformer(ProtocolVersion inputVersion, - @Nullable Class clientboundPacketsClass, - @Nullable Class serverboundPacketsClass); + S extends ServerboundPacketType + > VersionedPacketTransformer createPacketTransformer(ProtocolVersion inputVersion, + @Nullable Class clientboundPacketsClass, + @Nullable Class serverboundPacketsClass); /** * Sets the max delta the path calculation allows the distance to the target protocol version to increase. @@ -311,4 +311,11 @@ public interface ProtocolManager { */ @Deprecated PacketWrapper createPacketWrapper(int packetId, @Nullable ByteBuf buf, UserConnection connection); + + /** + * Returns whether the mappings have been loaded and the mapping loader executor shutdown. + * + * @return whether the mappings have been loaded + */ + boolean hasLoadedMappings(); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java index e7899c7b0..88a926601 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java +++ b/common/src/main/java/com/viaversion/viaversion/protocol/ProtocolManagerImpl.java @@ -503,6 +503,11 @@ public class ProtocolManagerImpl implements ProtocolManager { return new PacketWrapperImpl(packetId, buf, connection); } + @Override + public boolean hasLoadedMappings() { + return mappingsLoaded; + } + public void shutdownLoaderExecutor() { Preconditions.checkArgument(!mappingsLoaded);