Fix Java 8 API compatibility

This commit is contained in:
games647
2022-07-22 18:46:46 +02:00
parent c090278f82
commit 8df5b11276
5 changed files with 21 additions and 7 deletions

View File

@ -25,6 +25,7 @@
*/
package com.github.games647.fastlogin.bukkit;
import java.util.Collections;
import java.util.List;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@ -49,7 +50,7 @@ public class PremiumPlaceholder extends PlaceholderExpansion {
@Override
public @NotNull List<String> getPlaceholders() {
return List.of(PLACEHOLDER_VARIABLE);
return Collections.singletonList(PLACEHOLDER_VARIABLE);
}
@Override

View File

@ -81,7 +81,7 @@ public abstract class ToggleCommand implements CommandExecutor {
plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
} else {
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
if (optPlayer.isEmpty()) {
if (!optPlayer.isPresent()) {
plugin.getLog().info("No player online to send a plugin message to the proxy");
return;
}

View File

@ -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) {

View File

@ -93,7 +93,7 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
premiumUUID = core.getResolver().findProfile(username);
}
if (premiumUUID.isEmpty()
if (!premiumUUID.isPresent()
|| (!checkNameChange(source, username, premiumUUID.get())
&& !checkPremiumName(source, username, profile))) {
//nothing detected the player as premium -> start a cracked session

17
pom.xml
View File

@ -49,8 +49,6 @@
<git.commit.id>Unknown</git.commit.id>
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<floodgate.version>2.2.0-SNAPSHOT</floodgate.version>
<geyser.version>2.0.0-SNAPSHOT</geyser.version>
@ -152,6 +150,8 @@
</execution>
</executions>
</plugin>
<!-- Require newer versions for Junit5 support -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
@ -160,6 +160,19 @@
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<!-- Verify Java 8 compatibility while compiling with a newer toolchain
(i.e. check for unavailable methods) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release>
</configuration>
</plugin>
</plugins>
<resources>