diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/auth/protocollib/EncryptionUtil.java similarity index 99% rename from bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java rename to bukkit/src/main/java/com/github/games647/fastlogin/bukkit/auth/protocollib/EncryptionUtil.java index c3c5dad3..f1228885 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtil.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/auth/protocollib/EncryptionUtil.java @@ -116,7 +116,7 @@ final class EncryptionUtil { * @param random random generator * @return a token with 4 bytes long */ - public static byte[] generateVerifyToken(RandomGenerator random) { + public static byte[] generateVerifyToken(Random random) { byte[] token = new byte[VERIFY_TOKEN_LENGTH]; random.nextBytes(token); return token; diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/DefaultPasswordGenerator.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/DefaultPasswordGenerator.java index 549039ea..7d27bdf4 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/DefaultPasswordGenerator.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/hooks/DefaultPasswordGenerator.java @@ -26,7 +26,7 @@ package com.github.games647.fastlogin.core.hooks; import java.security.SecureRandom; -import java.util.random.RandomGenerator; +import java.util.Random; import java.util.stream.IntStream; public class DefaultPasswordGenerator

implements PasswordGenerator

{ @@ -35,7 +35,7 @@ public class DefaultPasswordGenerator

implements PasswordGenerator

{ private static final char[] PASSWORD_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" .toCharArray(); - private final RandomGenerator random = new SecureRandom(); + private final Random random = new SecureRandom(); @Override public String getRandomPassword(P player) { diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/FloodgateService.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/FloodgateService.java index d48c62dc..7c14f43b 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/FloodgateService.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/FloodgateService.java @@ -59,13 +59,16 @@ public class FloodgateService extends BedrockService { */ public boolean isValidFloodgateConfigString(String key) { String value = core.getConfig().get(key).toString().toLowerCase(Locale.ENGLISH); - return switch (value) { - case "true", "linked", "false", "no-conflict" -> true; - default -> { + switch (value) { + case "true": + case "linked": + case "false": + case "no-conflict": + return true; + default: core.getPlugin().getLog().error("Invalid value detected for {} in FastLogin/config.yml.", key); - yield false; - } - }; + return false; + } } @Override diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateState.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateState.java index f2f03eb7..14e916e7 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateState.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FloodgateState.java @@ -70,12 +70,17 @@ public enum FloodgateState { */ public static FloodgateState fromInt(int num) { // using Enum.values()[i] is expensive as per https://stackoverflow.com/a/8762387/9767089 - return switch (num) { - case 0 -> FloodgateState.FALSE; - case 1 -> FloodgateState.TRUE; - case 2 -> FloodgateState.LINKED; - case 3 -> FloodgateState.NOT_MIGRATED; - default -> null; - }; + switch (num) { + case 0: + return FloodgateState.FALSE; + case 1: + return FloodgateState.TRUE; + case 2: + return FloodgateState.LINKED; + case 3: + return FloodgateState.NOT_MIGRATED; + default: + return null; + } } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java index 48085861..85311536 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java @@ -109,7 +109,7 @@ public abstract class JoinManagement

{ premiumUUID = core.getResolver().findProfile(username); } - if (premiumUUID.isEmpty() + if (premiumUUID.isPresent() || (!isNameChanged(source, username, premiumUUID.get()) && !isUsernameAvailable(source, username, profile))) { //nothing detected the player as premium -> start a cracked session diff --git a/core/src/main/java/com/github/games647/fastlogin/core/storage/StoredProfile.java b/core/src/main/java/com/github/games647/fastlogin/core/storage/StoredProfile.java index 313f6939..a2e2d60b 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/storage/StoredProfile.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/storage/StoredProfile.java @@ -163,16 +163,16 @@ public class StoredProfile extends Profile { } @Override - public synchronized boolean equals(Object o) { - if (this == o) { + public synchronized boolean equals(Object other) { + if (this == other) { return true; } - if (!(o instanceof StoredProfile that)) { + if (!(other instanceof StoredProfile)) { return false; } - - if (!super.equals(o)) { + StoredProfile that = (StoredProfile) other; + if (!super.equals(other)) { return false; }