Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-16 04:50:08 +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
Dieser Commit ist enthalten in:
Ursprung
b1f64fd081
Commit
c9d6fbfcd0
@ -39,6 +39,20 @@ public interface VersionProvider extends Provider {
|
|||||||
return null;
|
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.
|
* Returns the closest server protocol version to the user's protocol version.
|
||||||
* On non-proxy servers, this returns the actual server version.
|
* On non-proxy servers, this returns the actual server version.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren