Skip to content

Commit b9011b6

Browse files
author
games647
committed
Add support for 1.17
Fixes #552
1 parent 7fdbedb commit b9011b6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@
3939
import com.github.games647.craftapi.resolver.MojangResolver;
4040
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
4141
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
42-
import org.bukkit.entity.Player;
4342

44-
import javax.crypto.Cipher;
45-
import javax.crypto.SecretKey;
4643
import java.io.IOException;
4744
import java.lang.reflect.InvocationTargetException;
4845
import java.lang.reflect.Method;
@@ -56,11 +53,23 @@
5653
import java.util.Optional;
5754
import java.util.UUID;
5855

56+
import javax.crypto.Cipher;
57+
import javax.crypto.SecretKey;
58+
59+
import org.bukkit.entity.Player;
60+
5961
import static com.comphenix.protocol.PacketType.Login.Client.START;
6062
import static com.comphenix.protocol.PacketType.Login.Server.DISCONNECT;
6163

6264
public class VerifyResponseTask implements Runnable {
6365

66+
private static final String ENCRYPTION_CLASS_NAME = "MinecraftEncryption";
67+
private static final Class<?> ENCRYPTION_CLASS;
68+
69+
static {
70+
ENCRYPTION_CLASS = MinecraftReflection.getMinecraftClass("util." + ENCRYPTION_CLASS_NAME, ENCRYPTION_CLASS_NAME);
71+
}
72+
6473
private final FastLoginBukkit plugin;
6574
private final PacketEvent packetEvent;
6675
private final KeyPair serverKey;
@@ -214,8 +223,7 @@ private boolean enableEncryption(SecretKey loginKey) throws IllegalArgumentExcep
214223
.getMethodByParameters("a", Cipher.class, Cipher.class);
215224

216225
// Get the needed Cipher helper method (used to generate ciphers from login key)
217-
Class<?> encryptionClass = MinecraftReflection.getMinecraftClass("MinecraftEncryption");
218-
cipherMethod = FuzzyReflection.fromClass(encryptionClass)
226+
cipherMethod = FuzzyReflection.fromClass(ENCRYPTION_CLASS)
219227
.getMethodByParameters("a", int.class, Key.class);
220228
}
221229
}

0 commit comments

Comments
 (0)