diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java index a47715aa..c6fb4f02 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BungeeManager.java @@ -35,6 +35,7 @@ import com.google.common.io.ByteStreams; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -61,7 +62,7 @@ public class BungeeManager { private final FastLoginBukkit plugin; private boolean enabled; - private final Set firedJoinEvents = new HashSet<>(); + private final Collection firedJoinEvents = new HashSet<>(); public BungeeManager(FastLoginBukkit plugin) { this.plugin = plugin; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/CrackedCommand.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/CrackedCommand.java index a6ac9b7b..61533387 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/CrackedCommand.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/CrackedCommand.java @@ -44,7 +44,7 @@ public class CrackedCommand extends ToggleCommand { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 0) { - onCrackedSelf(sender, command, args); + onCrackedSelf(sender); } else { onCrackedOther(sender, command, args); } @@ -52,7 +52,7 @@ public class CrackedCommand extends ToggleCommand { return true; } - private void onCrackedSelf(CommandSender sender, Command cmd, String[] args) { + private void onCrackedSelf(CommandSender sender) { if (isConsole(sender)) { return; } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java index 26b6d312..9f1ef982 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/command/PremiumCommand.java @@ -51,7 +51,7 @@ public class PremiumCommand extends ToggleCommand { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 0) { - onPremiumSelf(sender, command, args); + onPremiumSelf(sender); } else { onPremiumOther(sender, command, args); } @@ -59,7 +59,7 @@ public class PremiumCommand extends ToggleCommand { return true; } - private void onPremiumSelf(CommandSender sender, Command cmd, String[] args) { + private void onPremiumSelf(CommandSender sender) { if (isConsole(sender)) { return; } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginAutoLoginEvent.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginAutoLoginEvent.java index 8c61330b..6412c6d8 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginAutoLoginEvent.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginAutoLoginEvent.java @@ -28,6 +28,7 @@ package com.github.games647.fastlogin.bukkit.event; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.LoginSession; import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; + import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java index 6b2edfca..5bf6df99 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPreLoginEvent.java @@ -28,6 +28,7 @@ package com.github.games647.fastlogin.bukkit.event; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.LoginSource; import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; + import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPremiumToggleEvent.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPremiumToggleEvent.java index 146efb07..0904826d 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPremiumToggleEvent.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/event/BukkitFastLoginPremiumToggleEvent.java @@ -27,6 +27,7 @@ package com.github.games647.fastlogin.bukkit.event; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent; + import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java index fecfb73b..45d5a5f4 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/AuthMeHook.java @@ -28,18 +28,20 @@ package com.github.games647.fastlogin.bukkit.hook; import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; import com.github.games647.fastlogin.core.hooks.AuthPlugin; + import fr.xephi.authme.api.v3.AuthMeApi; import fr.xephi.authme.events.RestoreSessionEvent; import fr.xephi.authme.process.Management; import fr.xephi.authme.process.register.executors.ApiPasswordRegisterParams; import fr.xephi.authme.process.register.executors.RegistrationMethod; + +import java.lang.reflect.Field; + import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import java.lang.reflect.Field; - /** * GitHub: ... *

diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/PaperCacheListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/PaperCacheListener.java index e444ed92..44ff6ea0 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/PaperCacheListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/PaperCacheListener.java @@ -29,6 +29,7 @@ import com.destroystokyo.paper.profile.ProfileProperty; import com.github.games647.craftapi.model.skin.Textures; import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; + import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ManualNameChange.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ManualNameChange.java index cdf39997..2a36e88a 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ManualNameChange.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ManualNameChange.java @@ -25,6 +25,7 @@ */ package com.github.games647.fastlogin.bukkit.listener.protocollib; +import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; @@ -36,8 +37,6 @@ import org.geysermc.floodgate.api.FloodgateApi; import static com.comphenix.protocol.PacketType.Login.Client.START; -import com.comphenix.protocol.ProtocolLibrary; - /** * Manually inject Floodgate player name prefixes. *
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java index 485c065d..d3b38eae 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java @@ -49,7 +49,7 @@ public class NameCheckTask extends JoinManagement publicKey = packetEvent.getPacket().getOptionals(BukkitConverters.getWrappedPublicKeyDataConverter()).read(0); + Optional clientKey = packetEvent.getPacket().getOptionals(BukkitConverters.getWrappedPublicKeyDataConverter()).read(0); - super.onLogin(username, new ProtocolLibLoginSource(player, random, publicKey.get(), this.publicKey)); + super.onLogin(username, new ProtocolLibLoginSource(player, random, clientKey.get(), serverKey)); } finally { ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent); } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java index 5bf9be76..10377b04 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java @@ -127,7 +127,7 @@ public class ProtocolLibListener extends PacketAdapter { } } - private Boolean isFastLoginPacket(PacketEvent packetEvent) { + private boolean isFastLoginPacket(PacketEvent packetEvent) { return packetEvent.getPacket().getMeta(SOURCE_META_KEY) .map(val -> val.equals(plugin.getName())) .orElse(false); @@ -146,7 +146,7 @@ public class ProtocolLibListener extends PacketAdapter { long salt = FuzzyReflection.getFieldValue(signatureData, Long.TYPE, true); byte[] signature = FuzzyReflection.getFieldValue(signatureData, byte[].class, true); - PublicKey publicKey = session.getClientPublicKey().getKey(); + PublicKey publicKey = session.getClientPublicKey().key(); try { if (EncryptionUtil.verifySignedNonce(session.getVerifyToken(), publicKey, salt, signature)) { packetEvent.getAsyncMarker().incrementProcessingDelay(); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java index d87b602d..d4c1130c 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java @@ -33,7 +33,6 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedProfilePublicKey.WrappedProfileKeyData; import com.github.games647.fastlogin.core.shared.LoginSource; -import java.lang.reflect.InvocationTargetException; import java.net.InetSocketAddress; import java.security.PublicKey; import java.util.Arrays; @@ -64,7 +63,7 @@ class ProtocolLibLoginSource implements LoginSource { } @Override - public void enableOnlinemode() throws InvocationTargetException { + public void enableOnlinemode() { verifyToken = EncryptionUtil.generateVerifyToken(random); /* @@ -92,7 +91,7 @@ class ProtocolLibLoginSource implements LoginSource { } @Override - public void kick(String message) throws InvocationTargetException { + public void kick(String message) { ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); PacketContainer kickPacket = new PacketContainer(DISCONNECT); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SkinApplyListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SkinApplyListener.java index 7d43835d..3d4a807b 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SkinApplyListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/SkinApplyListener.java @@ -34,6 +34,9 @@ import com.comphenix.protocol.wrappers.WrappedSignedProperty; import com.github.games647.craftapi.model.skin.Textures; import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; + +import java.lang.reflect.InvocationTargetException; + import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -41,8 +44,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent.Result; -import java.lang.reflect.InvocationTargetException; - public class SkinApplyListener implements Listener { private static final Class GAME_PROFILE = MinecraftReflection.getGameProfileClass(); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java index acb35976..ef9fed0a 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/FloodgateAuthTask.java @@ -25,6 +25,11 @@ */ package com.github.games647.fastlogin.bukkit.task; +import com.github.games647.fastlogin.bukkit.BukkitLoginSession; +import com.github.games647.fastlogin.bukkit.FastLoginBukkit; +import com.github.games647.fastlogin.core.shared.FastLoginCore; +import com.github.games647.fastlogin.core.shared.FloodgateManagement; + import java.net.InetSocketAddress; import java.util.UUID; @@ -33,11 +38,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.geysermc.floodgate.api.player.FloodgatePlayer; -import com.github.games647.fastlogin.bukkit.BukkitLoginSession; -import com.github.games647.fastlogin.bukkit.FastLoginBukkit; -import com.github.games647.fastlogin.core.shared.FastLoginCore; -import com.github.games647.fastlogin.core.shared.FloodgateManagement; - public class FloodgateAuthTask extends FloodgateManagement { public FloodgateAuthTask(FastLoginCore core, Player player, FloodgatePlayer floodgatePlayer) { diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginAutoLoginEvent.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginAutoLoginEvent.java index 365a1980..6503ff92 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginAutoLoginEvent.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginAutoLoginEvent.java @@ -28,6 +28,7 @@ package com.github.games647.fastlogin.bungee.event; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.LoginSession; import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; + import net.md_5.bungee.api.plugin.Cancellable; import net.md_5.bungee.api.plugin.Event; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginPreLoginEvent.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginPreLoginEvent.java index b3507633..2128caba 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginPreLoginEvent.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/event/BungeeFastLoginPreLoginEvent.java @@ -28,6 +28,7 @@ package com.github.games647.fastlogin.bungee.event; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.LoginSource; import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; + import net.md_5.bungee.api.plugin.Event; public class BungeeFastLoginPreLoginEvent extends Event implements FastLoginPreLoginEvent { diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncToggleMessage.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncToggleMessage.java index 98c384c0..29658553 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncToggleMessage.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncToggleMessage.java @@ -29,8 +29,8 @@ import com.github.games647.fastlogin.bungee.FastLoginBungee; import com.github.games647.fastlogin.bungee.event.BungeeFastLoginPremiumToggleEvent; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.FastLoginCore; - import com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason; + import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.TextComponent; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/FloodgateAuthTask.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/FloodgateAuthTask.java index 72719cfc..51331984 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/FloodgateAuthTask.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/FloodgateAuthTask.java @@ -25,19 +25,19 @@ */ package com.github.games647.fastlogin.bungee.task; +import com.github.games647.fastlogin.bungee.BungeeLoginSession; +import com.github.games647.fastlogin.bungee.FastLoginBungee; +import com.github.games647.fastlogin.core.shared.FastLoginCore; +import com.github.games647.fastlogin.core.shared.FloodgateManagement; + import java.net.InetSocketAddress; import java.util.UUID; -import org.geysermc.floodgate.api.player.FloodgatePlayer; - import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.Server; -import com.github.games647.fastlogin.bungee.BungeeLoginSession; -import com.github.games647.fastlogin.bungee.FastLoginBungee; -import com.github.games647.fastlogin.core.shared.FastLoginCore; -import com.github.games647.fastlogin.core.shared.FloodgateManagement; +import org.geysermc.floodgate.api.player.FloodgatePlayer; public class FloodgateAuthTask extends FloodgateManagement { 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 b6802a69..9caadef5 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; +import java.util.random.RandomGenerator; 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 Random random = new SecureRandom(); + private final RandomGenerator 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 7e6a1c24..1b555f18 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 @@ -54,14 +54,13 @@ public class FloodgateService extends BedrockService { *

  • autoLoginFloodgate *
  • autoRegisterFloodgate * - *

    * * @param key the key of the entry in config.yml * @return true if the entry's value is "true", "false", or "linked" */ public boolean isValidFloodgateConfigString(String key) { String value = core.getConfig().get(key).toString().toLowerCase(Locale.ENGLISH); - if (!value.equals("true") && !value.equals("linked") && !value.equals("false") && !value.equals("no-conflict")) { + if (!"true".equals(value) && !"linked".equals(value) && !"false".equals(value) && !"no-conflict".equals(value)) { core.getPlugin().getLog().error("Invalid value detected for {} in FastLogin/config.yml.", key); return false; } @@ -87,7 +86,7 @@ public class FloodgateService extends BedrockService { } else { core.getPlugin().getLog().info("Skipping name conflict checking for player {}", username); } - + //Floodgate users don't need Java specific checks return true; } @@ -98,7 +97,7 @@ public class FloodgateService extends BedrockService { * username can be found *
    * Falls back to non-prefixed name checks, if ProtocolLib is installed - * + * * @param prefixedUsername the name of the player with the prefix appended * @return FloodgatePlayer if found, null otherwise */ diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java index c8c7bea8..873a8552 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java @@ -25,10 +25,10 @@ */ package com.github.games647.fastlogin.core.shared; -import com.github.games647.fastlogin.core.storage.SQLStorage; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; +import com.github.games647.fastlogin.core.storage.SQLStorage; public abstract class ForceLoginManagement

    > implements Runnable { diff --git a/core/src/test/java/com/github/games647/fastlogin/core/TickingRateLimiterTest.java b/core/src/test/java/com/github/games647/fastlogin/core/TickingRateLimiterTest.java index 3f753cd4..34f196aa 100644 --- a/core/src/test/java/com/github/games647/fastlogin/core/TickingRateLimiterTest.java +++ b/core/src/test/java/com/github/games647/fastlogin/core/TickingRateLimiterTest.java @@ -32,8 +32,8 @@ import java.util.concurrent.TimeUnit; import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; public class TickingRateLimiterTest { @@ -43,7 +43,7 @@ public class TickingRateLimiterTest { * Always expired */ @Test - public void allowExpire() throws InterruptedException { + public void allowExpire() { int size = 3; FakeTicker ticker = new FakeTicker(5_000_000L); @@ -51,17 +51,17 @@ public class TickingRateLimiterTest { // run twice the size to fill it first and then test it TickingRateLimiter rateLimiter = new TickingRateLimiter(ticker, size, 0); for (int i = 0; i < size; i++) { - assertTrue("Filling up", rateLimiter.tryAcquire()); + assertThat("Filling up", rateLimiter.tryAcquire(), is(true)); } for (int i = 0; i < size; i++) { ticker.add(Duration.ofSeconds(1)); - assertTrue("Should be expired", rateLimiter.tryAcquire()); + assertThat("Should be expired", rateLimiter.tryAcquire(), is(true)); } } @Test - public void allowExpireNegative() throws InterruptedException { + public void allowExpireNegative() { int size = 3; FakeTicker ticker = new FakeTicker(-5_000_000L); @@ -69,12 +69,12 @@ public class TickingRateLimiterTest { // run twice the size to fill it first and then test it TickingRateLimiter rateLimiter = new TickingRateLimiter(ticker, size, 0); for (int i = 0; i < size; i++) { - assertTrue("Filling up", rateLimiter.tryAcquire()); + assertThat("Filling up", rateLimiter.tryAcquire(), is(true)); } for (int i = 0; i < size; i++) { ticker.add(Duration.ofSeconds(1)); - assertTrue("Should be expired", rateLimiter.tryAcquire()); + assertThat("Should be expired", rateLimiter.tryAcquire(), is(true)); } } @@ -90,10 +90,10 @@ public class TickingRateLimiterTest { // fill the size TickingRateLimiter rateLimiter = new TickingRateLimiter(ticker, size, TimeUnit.SECONDS.toMillis(30)); for (int i = 0; i < size; i++) { - assertTrue("Filling up", rateLimiter.tryAcquire()); + assertThat("Filling up", rateLimiter.tryAcquire(), is(true)); } - assertFalse("Should be full and no entry should be expired", rateLimiter.tryAcquire()); + assertThat("Should be full and no entry should be expired", rateLimiter.tryAcquire(), is(false)); } /** @@ -108,51 +108,51 @@ public class TickingRateLimiterTest { // fill the size TickingRateLimiter rateLimiter = new TickingRateLimiter(ticker, size, TimeUnit.SECONDS.toMillis(30)); for (int i = 0; i < size; i++) { - assertTrue("Filling up", rateLimiter.tryAcquire()); + assertThat("Filling up", rateLimiter.tryAcquire(), is(true)); } - assertFalse("Should be full and no entry should be expired", rateLimiter.tryAcquire()); + assertThat("Should be full and no entry should be expired", rateLimiter.tryAcquire(), is(false)); } /** * Blocked attempts shouldn't replace existing ones. */ @Test - public void blockedNotAdded() throws InterruptedException { + public void blockedNotAdded() { FakeTicker ticker = new FakeTicker(5_000_000L); // fill the size - 100ms should be reasonable high TickingRateLimiter rateLimiter = new TickingRateLimiter(ticker, 1, 100); - assertTrue("Filling up", rateLimiter.tryAcquire()); + assertThat("Filling up", rateLimiter.tryAcquire(), is(true)); ticker.add(Duration.ofMillis(50)); // still is full - should fail - assertFalse("Expired too early", rateLimiter.tryAcquire()); + assertThat("Expired too early", rateLimiter.tryAcquire(), is(false)); // wait the remaining time and add a threshold, because ticker.add(Duration.ofMillis(50)); - assertTrue("Request not released", rateLimiter.tryAcquire()); + assertThat("Request not released", rateLimiter.tryAcquire(), is(true)); } /** * Blocked attempts shouldn't replace existing ones. */ @Test - public void blockedNotAddedNegative() throws InterruptedException { + public void blockedNotAddedNegative() { FakeTicker ticker = new FakeTicker(-5_000_000L); // fill the size - 100ms should be reasonable high TickingRateLimiter rateLimiter = new TickingRateLimiter(ticker, 1, 100); - assertTrue("Filling up", rateLimiter.tryAcquire()); + assertThat("Filling up", rateLimiter.tryAcquire(), is(true)); ticker.add(Duration.ofMillis(50)); // still is full - should fail - assertFalse("Expired too early", rateLimiter.tryAcquire()); + assertThat("Expired too early", rateLimiter.tryAcquire(), is(false)); // wait the remaining time and add a threshold, because ticker.add(Duration.ofMillis(50)); - assertTrue("Request not released", rateLimiter.tryAcquire()); + assertThat("Request not released", rateLimiter.tryAcquire(), is(true)); } } diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java index 33c8c311..902fb039 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/listener/ConnectListener.java @@ -45,9 +45,11 @@ import com.velocitypowered.api.proxy.InboundConnection; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.util.GameProfile; +import com.velocitypowered.api.util.GameProfile.Property; import java.net.InetSocketAddress; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -121,7 +123,7 @@ public class ConnectListener { } } - private List removeSkin(List oldProperties) { + private List removeSkin(Collection oldProperties) { List newProperties = new ArrayList<>(oldProperties.size() - 1); for (GameProfile.Property property : oldProperties) { if (!"textures".equals(property.getName())) diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncToggleMessage.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncToggleMessage.java index 12444fca..8dc7d1c0 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncToggleMessage.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncToggleMessage.java @@ -32,6 +32,7 @@ import com.github.games647.fastlogin.velocity.FastLoginVelocity; import com.github.games647.fastlogin.velocity.event.VelocityFastLoginPremiumToggleEvent; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; + import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; public class AsyncToggleMessage implements Runnable {