forked from TuxCoding/FastLogin
Restore older Java compatibility
This commit is contained in:
@ -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;
|
@ -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<P> implements PasswordGenerator<P> {
|
||||
@ -35,7 +35,7 @@ public class DefaultPasswordGenerator<P> implements PasswordGenerator<P> {
|
||||
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) {
|
||||
|
@ -59,13 +59,16 @@ public class FloodgateService extends BedrockService<FloodgatePlayer> {
|
||||
*/
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user