Skip to content

Commit 8df5b11

Browse files
author
games647
committed
Fix Java 8 API compatibility
1 parent c090278 commit 8df5b11

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/PremiumPlaceholder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626
package com.github.games647.fastlogin.bukkit;
2727

28+
import java.util.Collections;
2829
import java.util.List;
2930

3031
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@@ -49,7 +50,7 @@ public boolean persist() {
4950

5051
@Override
5152
public @NotNull List<String> getPlaceholders() {
52-
return List.of(PLACEHOLDER_VARIABLE);
53+
return Collections.singletonList(PLACEHOLDER_VARIABLE);
5354
}
5455

5556
@Override

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/ToggleCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected void sendBungeeActivateMessage(CommandSender invoker, String target, b
8181
plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
8282
} else {
8383
Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
84-
if (optPlayer.isEmpty()) {
84+
if (!optPlayer.isPresent()) {
8585
plugin.getLog().info("No player online to send a plugin message to the proxy");
8686
return;
8787
}

core/src/main/java/com/github/games647/fastlogin/core/hooks/DefaultPasswordGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
package com.github.games647.fastlogin.core.hooks;
2727

2828
import java.security.SecureRandom;
29-
import java.util.random.RandomGenerator;
29+
import java.util.Random;
3030
import java.util.stream.IntStream;
3131

3232
public class DefaultPasswordGenerator<P> implements PasswordGenerator<P> {
@@ -35,7 +35,7 @@ public class DefaultPasswordGenerator<P> implements PasswordGenerator<P> {
3535
private static final char[] PASSWORD_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
3636
.toCharArray();
3737

38-
private final RandomGenerator random = new SecureRandom();
38+
private final Random random = new SecureRandom();
3939

4040
@Override
4141
public String getRandomPassword(P player) {

core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void onLogin(String username, S source) {
9393
premiumUUID = core.getResolver().findProfile(username);
9494
}
9595

96-
if (premiumUUID.isEmpty()
96+
if (!premiumUUID.isPresent()
9797
|| (!checkNameChange(source, username, premiumUUID.get())
9898
&& !checkPremiumName(source, username, profile))) {
9999
//nothing detected the player as premium -> start a cracked session

pom.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
<git.commit.id>Unknown</git.commit.id>
5050

5151
<java.version>8</java.version>
52-
<maven.compiler.source>${java.version}</maven.compiler.source>
53-
<maven.compiler.target>${java.version}</maven.compiler.target>
5452

5553
<floodgate.version>2.2.0-SNAPSHOT</floodgate.version>
5654
<geyser.version>2.0.0-SNAPSHOT</geyser.version>
@@ -152,6 +150,8 @@
152150
</execution>
153151
</executions>
154152
</plugin>
153+
154+
<!-- Require newer versions for Junit5 support -->
155155
<plugin>
156156
<artifactId>maven-surefire-plugin</artifactId>
157157
<version>2.22.2</version>
@@ -160,6 +160,19 @@
160160
<artifactId>maven-failsafe-plugin</artifactId>
161161
<version>2.22.2</version>
162162
</plugin>
163+
164+
<!-- Verify Java 8 compatibility while compiling with a newer toolchain
165+
(i.e. check for unavailable methods) -->
166+
<plugin>
167+
<groupId>org.apache.maven.plugins</groupId>
168+
<artifactId>maven-compiler-plugin</artifactId>
169+
<version>3.10.1</version>
170+
<configuration>
171+
<source>${java.version}</source>
172+
<target>${java.version}</target>
173+
<release>${java.version}</release>
174+
</configuration>
175+
</plugin>
163176
</plugins>
164177

165178
<resources>

0 commit comments

Comments
 (0)