|
39 | 39 | import com.github.games647.craftapi.resolver.MojangResolver; |
40 | 40 | import com.github.games647.fastlogin.bukkit.BukkitLoginSession; |
41 | 41 | import com.github.games647.fastlogin.bukkit.FastLoginBukkit; |
42 | | -import org.bukkit.entity.Player; |
43 | 42 |
|
44 | | -import javax.crypto.Cipher; |
45 | | -import javax.crypto.SecretKey; |
46 | 43 | import java.io.IOException; |
47 | 44 | import java.lang.reflect.InvocationTargetException; |
48 | 45 | import java.lang.reflect.Method; |
|
56 | 53 | import java.util.Optional; |
57 | 54 | import java.util.UUID; |
58 | 55 |
|
| 56 | +import javax.crypto.Cipher; |
| 57 | +import javax.crypto.SecretKey; |
| 58 | + |
| 59 | +import org.bukkit.entity.Player; |
| 60 | + |
59 | 61 | import static com.comphenix.protocol.PacketType.Login.Client.START; |
60 | 62 | import static com.comphenix.protocol.PacketType.Login.Server.DISCONNECT; |
61 | 63 |
|
62 | 64 | public class VerifyResponseTask implements Runnable { |
63 | 65 |
|
| 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 | + |
64 | 73 | private final FastLoginBukkit plugin; |
65 | 74 | private final PacketEvent packetEvent; |
66 | 75 | private final KeyPair serverKey; |
@@ -214,8 +223,7 @@ private boolean enableEncryption(SecretKey loginKey) throws IllegalArgumentExcep |
214 | 223 | .getMethodByParameters("a", Cipher.class, Cipher.class); |
215 | 224 |
|
216 | 225 | // 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) |
219 | 227 | .getMethodByParameters("a", int.class, Key.class); |
220 | 228 | } |
221 | 229 | } |
|
0 commit comments