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

View File

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

View File

@ -26,7 +26,7 @@
package com.github.games647.fastlogin.core.hooks; package com.github.games647.fastlogin.core.hooks;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.random.RandomGenerator; import java.util.Random;
import java.util.stream.IntStream; import java.util.stream.IntStream;
public class DefaultPasswordGenerator<P> implements PasswordGenerator<P> { 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" private static final char[] PASSWORD_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
.toCharArray(); .toCharArray();
private final RandomGenerator random = new SecureRandom(); private final Random random = new SecureRandom();
@Override @Override
public String getRandomPassword(P player) { 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); premiumUUID = core.getResolver().findProfile(username);
} }
if (premiumUUID.isEmpty() if (!premiumUUID.isPresent()
|| (!checkNameChange(source, username, premiumUUID.get()) || (!checkNameChange(source, username, premiumUUID.get())
&& !checkPremiumName(source, username, profile))) { && !checkPremiumName(source, username, profile))) {
//nothing detected the player as premium -> start a cracked session //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> <git.commit.id>Unknown</git.commit.id>
<java.version>8</java.version> <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> <floodgate.version>2.2.0-SNAPSHOT</floodgate.version>
<geyser.version>2.0.0-SNAPSHOT</geyser.version> <geyser.version>2.0.0-SNAPSHOT</geyser.version>
@ -152,6 +150,8 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Require newer versions for Junit5 support -->
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version> <version>2.22.2</version>
@ -160,6 +160,19 @@
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version> <version>2.22.2</version>
</plugin> </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> </plugins>
<resources> <resources>