mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-22 16:38:20 +01:00
Add VersionProvider#getServerProtocol (#4049)
Most platforms won't ever throw an error and usually ViaVersion shouldn't even load when the server version can't be found. Therefore, I added this bouncer function, so I don't need to try catch my code in ViaLoader/VFP where an exception is never thrown
This commit is contained in:
parent
b1f64fd081
commit
c9d6fbfcd0
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user