diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionProvider.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionProvider.java index 347d0ae0f..06f1fd76c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionProvider.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/VersionProvider.java @@ -39,6 +39,20 @@ public interface VersionProvider extends Provider { return null; } + /** + * Calls {@link #getClosestServerProtocol(UserConnection)} and catches any exceptions by returning null. + * + * @param connection connection + * @return closest server protocol version to the user's protocol version + */ + default ProtocolVersion getServerProtocol(UserConnection connection) { + try { + return getClosestServerProtocol(connection); + } catch (Exception e) { + return null; + } + } + /** * Returns the closest server protocol version to the user's protocol version. * On non-proxy servers, this returns the actual server version.