From bf825d5ef61ae8d1468e0b041707ebc91376d166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ossi=20Erkkil=C3=A4?= <52257907+avaruus1@users.noreply.github.com> Date: Fri, 9 Jun 2023 12:29:55 +0300 Subject: [PATCH] Fix `SpongeViaInjector#getServerProtocolVersion()` for Sponge API-10+ (#3337) --- .../viaversion/sponge/platform/SpongeViaInjector.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java index 49242be90..32d8e886d 100644 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java +++ b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java @@ -32,7 +32,13 @@ public class SpongeViaInjector extends LegacyViaInjector { @Override public int getServerProtocolVersion() throws ReflectiveOperationException { MinecraftVersion version = Sponge.platform().minecraftVersion(); - return (int) version.getClass().getDeclaredMethod("getProtocol").invoke(version); + + // 'protocolVersion' method was exposed to the API in a 1.19.4 build and 'getProtocol' no longer exists in the impl. + try { + return (int) version.getClass().getDeclaredMethod("getProtocol").invoke(version); + } catch (NoSuchMethodException e) { + return (int) version.getClass().getDeclaredMethod("protocolVersion").invoke(version); + } } @Override