diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java index 5c030bb9..e0c4385a 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java @@ -110,17 +110,17 @@ public class BungeeManager { throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException { try { - if (isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport")) { - return true; - } - } catch (ClassNotFoundException classNotFoundException) { - // try again using the newer Paper configuration Class globalConfig = Class.forName("io.papermc.paper.configuration.GlobalConfiguration"); Object global = globalConfig.getDeclaredMethod("get").invoke(null); Object proxiesConfiguration = global.getClass().getDeclaredField("proxies").get(global); Object velocityConfig = proxiesConfiguration.getClass().getDeclaredField("velocity").get(proxiesConfiguration); return velocityConfig.getClass().getDeclaredField("enabled").getBoolean(velocityConfig); + } catch (ClassNotFoundException classNotFoundException) { + // try again using the older Paper configuration, because the old class file still exists in newer versions + if (isProxySupported("com.destroystokyo.paper.PaperConfig", "velocitySupport")) { + return true; + } } return false; diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java index d8a4f5b2..3a8adbfb 100644 --- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java +++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java @@ -142,7 +142,7 @@ public class EncryptionUtilTest { assertThat(decryptSharedKey, is(secretKey)); } - private static byte[] encrypt(PublicKey receiverKey, byte[] message) + private static byte[] encrypt(PublicKey receiverKey, byte... message) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { var encryptCipher = Cipher.getInstance(receiverKey.getAlgorithm()); @@ -169,13 +169,14 @@ public class EncryptionUtilTest { assertThat(EncryptionUtil.getServerIdHashString(serverId, sharedSecret, serverPK), is(sessionHash)); } - private static String getServerHash(String serverId, SecretKey sharedSecret, PublicKey serverPK) { + private static String getServerHash(CharSequence serverId, SecretKey sharedSecret, PublicKey serverPK) { // https://wiki.vg/Protocol_Encryption#Client // sha1 := Sha1() // sha1.update(ASCII encoding of the server id string from Encryption Request) // sha1.update(shared secret) // sha1.update(server's encoded public key from Encryption Request) // hash := sha1.hexdigest() # String of hex characters + @SuppressWarnings("deprecation") var hasher = Hashing.sha1().newHasher(); hasher.putString(serverId, StandardCharsets.US_ASCII); hasher.putBytes(sharedSecret.getEncoded()); @@ -197,7 +198,7 @@ public class EncryptionUtilTest { } @Test - public void testServerIdHashWrongServerKey() throws Exception { + public void testServerIdHashWrongServerKey() { var serverId = ""; var sharedSecret = generateSharedKey(); var serverPK = EncryptionUtil.generateKeyPair().getPublic();