From e5d61101ae055a0f3b7e10aa250c8cc688a96517 Mon Sep 17 00:00:00 2001 From: games647 Date: Tue, 11 Apr 2023 10:36:42 +0200 Subject: [PATCH] Typo fixes --- .../fastlogin/bukkit/BukkitLoginSession.java | 4 ++-- .../fastlogin/bukkit/listener/BungeeListener.java | 2 +- .../listener/protocollib/ProtocolLibListener.java | 2 +- .../listener/protocollib/EncryptionUtilTest.java | 3 ++- .../listener/protocollib/ResourceLoader.java | 5 +++-- .../games647/fastlogin/bungee/FastLoginBungee.java | 4 ++-- .../fastlogin/bungee/hook/BungeeAuthHook.java | 4 ++-- .../{antibot => }/ProxyAgnosticMojangResolver.java | 2 +- .../fastlogin/core/antibot/AntiBotService.java | 2 +- .../games647/fastlogin/core/hooks/AuthPlugin.java | 14 +++++++------- .../fastlogin/core/message/NamespaceKey.java | 8 ++++++++ .../fastlogin/core/shared/FastLoginCore.java | 2 +- .../fastlogin/core/shared/LoginSession.java | 6 +++--- .../fastlogin/core/storage/MySQLStorage.java | 2 +- core/src/main/resources/config.yml | 2 +- .../fastlogin/velocity/FastLoginVelocity.java | 4 ++-- .../fastlogin/velocity/task/ForceLoginTask.java | 2 +- 17 files changed, 39 insertions(+), 29 deletions(-) rename core/src/main/java/com/github/games647/fastlogin/core/{antibot => }/ProxyAgnosticMojangResolver.java (98%) diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java index f720194a..017e99bd 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java @@ -36,7 +36,7 @@ import org.jetbrains.annotations.Nullable; /** * Represents a client connecting to the server. - * + *

* This session is invalid if the player disconnects or the login was successful */ public class BukkitLoginSession extends LoginSession { @@ -76,7 +76,7 @@ public class BukkitLoginSession extends LoginSession { /** * Gets the verify-token the server sent to the client. - * + *

* Empty if it's a BungeeCord connection * * @return verify token from the server diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java index 9de359f0..868116ae 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeListener.java @@ -45,7 +45,7 @@ import org.jetbrains.annotations.NotNull; /** * Responsible for receiving messages from a BungeeCord instance. - * + *

* This class also receives the plugin message from the bungeecord version of this plugin in order to get notified if * the connection is in online mode. */ 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 c198552a..f963be3a 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 @@ -223,7 +223,7 @@ public class ProtocolLibListener extends PacketAdapter { plugin.removeSession(player.getAddress()); PacketContainer packet = packetEvent.getPacket(); - Optional clientKey = Optional.empty(); + Optional clientKey; if (new MinecraftVersion(1, 19, 3).atOrAbove()) { // public key sent separate clientKey = Optional.empty(); diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java index 9a6d2b39..5620a3ad 100644 --- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java +++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java @@ -178,7 +178,8 @@ class EncryptionUtilTest { assertEquals(EncryptionUtil.getServerIdHashString(serverId, sharedSecret, serverPK), sessionHash); } - private static String getServerHash(CharSequence serverId, SecretKey sharedSecret, PublicKey serverPK) { + private static String getServerHash(@SuppressWarnings("SameParameterValue") CharSequence serverId, + SecretKey sharedSecret, PublicKey serverPK) { // https://wiki.vg/Protocol_Encryption#Client // sha1 := Sha1() // sha1.update(ASCII encoding of the server id string from Encryption Request) diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java index 2f6d7b3f..2b1a3efd 100644 --- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java +++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ResourceLoader.java @@ -40,6 +40,7 @@ import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; import java.time.Instant; @@ -58,7 +59,7 @@ public class ResourceLoader { ) { PemObject pemObject = pemReader.readPemObject(); byte[] content = pemObject.getContent(); - PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(content); + KeySpec privateKeySpec = new PKCS8EncodedKeySpec(content); KeyFactory factory = KeyFactory.getInstance("RSA"); return (RSAPrivateKey) factory.generatePrivate(privateKeySpec); @@ -88,7 +89,7 @@ public class ResourceLoader { ) { PemObject pemObject = pemReader.readPemObject(); byte[] content = pemObject.getContent(); - X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(content); + KeySpec pubKeySpec = new X509EncodedKeySpec(content); KeyFactory factory = KeyFactory.getInstance("RSA"); return (RSAPublicKey) factory.generatePublic(pubKeySpec); diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java index 7fcf8ada..aa2525d9 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java @@ -46,7 +46,7 @@ import com.google.common.io.ByteStreams; import com.google.common.util.concurrent.ThreadFactoryBuilder; import java.nio.file.Path; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ThreadFactory; @@ -128,7 +128,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin>> hooks = Arrays.asList( + List>> hooks = Collections.singletonList( BungeeAuthHook.class ); diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java index fe04eff8..ff4c6092 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java @@ -36,9 +36,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; /** * GitHub: * ... - * + *

* Project page: - * + *

* Spigot: * ... */ diff --git a/core/src/main/java/com/github/games647/fastlogin/core/antibot/ProxyAgnosticMojangResolver.java b/core/src/main/java/com/github/games647/fastlogin/core/ProxyAgnosticMojangResolver.java similarity index 98% rename from core/src/main/java/com/github/games647/fastlogin/core/antibot/ProxyAgnosticMojangResolver.java rename to core/src/main/java/com/github/games647/fastlogin/core/ProxyAgnosticMojangResolver.java index 65def8de..41a3e379 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/antibot/ProxyAgnosticMojangResolver.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/ProxyAgnosticMojangResolver.java @@ -23,7 +23,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.github.games647.fastlogin.core.mojang; +package com.github.games647.fastlogin.core; import com.github.games647.craftapi.model.auth.Verification; import com.github.games647.craftapi.resolver.MojangResolver; diff --git a/core/src/main/java/com/github/games647/fastlogin/core/antibot/AntiBotService.java b/core/src/main/java/com/github/games647/fastlogin/core/antibot/AntiBotService.java index 28483355..a1cc5d68 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/antibot/AntiBotService.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/antibot/AntiBotService.java @@ -57,6 +57,6 @@ public class AntiBotService { Block, - Continue; + Continue } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java index 7c6258ab..bec4d726 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java @@ -37,7 +37,7 @@ public interface AuthPlugin

{ /** * Login the premium (paid account) player after the player joined successfully the server. - * + *

* This operation will be performed async while the player successfully * joined the server. * @@ -48,17 +48,17 @@ public interface AuthPlugin

{ /** * Forces a register in order to protect the paid account. - * + *

* This operation will be performed async while the player successfully * joined the server. - * + *

* After a successful registration the player should be logged * in too. - * + *

* The method will be called only for premium accounts. * So it's recommended to set additionally premium property * if possible. - * + *

* Background: If we don't register an account, cracked players * could steal the unregistered account from the paid * player account @@ -71,11 +71,11 @@ public interface AuthPlugin

{ /** * Checks whether an account exists for this player name. - * + *

* This check should check if a cracked player account exists, * so we can be sure the premium player doesn't steal the account * of that player. - * + *

* This operation will be performed async while the player is * connecting. * diff --git a/core/src/main/java/com/github/games647/fastlogin/core/message/NamespaceKey.java b/core/src/main/java/com/github/games647/fastlogin/core/message/NamespaceKey.java index a48ae992..a460620d 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/message/NamespaceKey.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/message/NamespaceKey.java @@ -48,4 +48,12 @@ public class NamespaceKey { public static String getCombined(String namespace, String key) { return new NamespaceKey(namespace, key).combined; } + + public String getNamespace() { + return namespace; + } + + public String getKey() { + return key; + } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java index fc84381d..d232a037 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java @@ -28,6 +28,7 @@ package com.github.games647.fastlogin.core.shared; import com.github.games647.craftapi.resolver.MojangResolver; import com.github.games647.craftapi.resolver.http.RotatingProxySelector; import com.github.games647.fastlogin.core.CommonUtil; +import com.github.games647.fastlogin.core.ProxyAgnosticMojangResolver; import com.github.games647.fastlogin.core.antibot.AntiBotService; import com.github.games647.fastlogin.core.antibot.AntiBotService.Action; import com.github.games647.fastlogin.core.antibot.RateLimiter; @@ -35,7 +36,6 @@ import com.github.games647.fastlogin.core.antibot.TickingRateLimiter; import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.hooks.DefaultPasswordGenerator; import com.github.games647.fastlogin.core.hooks.PasswordGenerator; -import com.github.games647.fastlogin.core.mojang.ProxyAgnosticMojangResolver; import com.github.games647.fastlogin.core.storage.MySQLStorage; import com.github.games647.fastlogin.core.storage.SQLStorage; import com.github.games647.fastlogin.core.storage.SQLiteStorage; diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java index a94cc87d..c4d35aa5 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java @@ -91,10 +91,10 @@ public abstract class LoginSession { @Override public String toString() { - return new StringJoiner(", ", LoginSession.class.getSimpleName() + "[", "]") + return new StringJoiner(", ", LoginSession.class.getSimpleName() + '[', "]") .add("profile=" + profile) - .add("requestUsername='" + requestUsername + "'") - .add("username='" + username + "'") + .add("requestUsername='" + requestUsername + '\'') + .add("username='" + username + '\'') .add("uuid=" + uuid) .add("registered=" + registered) .toString(); diff --git a/core/src/main/java/com/github/games647/fastlogin/core/storage/MySQLStorage.java b/core/src/main/java/com/github/games647/fastlogin/core/storage/MySQLStorage.java index 13480f94..135046bf 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/storage/MySQLStorage.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/storage/MySQLStorage.java @@ -85,7 +85,7 @@ public class MySQLStorage extends SQLStorage { // default false - available in newer versions caches the statements server-side config.addDataSourceProperty("useServerPrepStmts", true); // default false - prefer use of local values for autocommit and - // transaction isolation (alwaysSendSetIsolation) should only be enabled if always use the set* methods + // transaction isolation (alwaysSendSetIsolation) should only be enabled if we always use the set* methods // instead of raw SQL // https://forums.mysql.com/read.php?39,626495,626512 config.addDataSourceProperty("useLocalSessionState", true); diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index c99facbe..2c5405a3 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -281,7 +281,7 @@ database: '{pluginDir}/FastLogin.db' # MySQL/MariaDB # If you want to enable it, uncomment only the lines below; this not this line. -# If on velocity use 'mariadb' as driver +# If on velocity use 'mariadb' as the driver #driver: 'mysql' #host: '127.0.0.1' #port: 3306 diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java index 17934c94..9cbf73b7 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/FastLoginVelocity.java @@ -46,9 +46,9 @@ import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; +import com.velocitypowered.api.proxy.messages.ChannelMessageSink; import com.velocitypowered.api.proxy.messages.ChannelRegistrar; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; -import com.velocitypowered.api.proxy.server.RegisteredServer; import java.io.IOException; import java.net.InetSocketAddress; @@ -159,7 +159,7 @@ public class FastLoginVelocity implements PlatformPlugin { return server; } - public void sendPluginMessage(RegisteredServer server, ChannelMessage message) { + public void sendPluginMessage(ChannelMessageSink server, ChannelMessage message) { if (server != null) { ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(); message.writeTo(dataOutput); diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/ForceLoginTask.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/ForceLoginTask.java index da3ea231..f0af266a 100644 --- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/ForceLoginTask.java +++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/ForceLoginTask.java @@ -48,7 +48,7 @@ public class ForceLoginTask private final RegisteredServer server; - //treat player as if they had a premium account, even when they don't used to do auto login for Floodgate + //treat player as if they had a premium account, even when they don't use to do auto login for Floodgate private final boolean forcedOnlineMode; public ForceLoginTask(FastLoginCore core,