From e03e67b8fa2808099b28687e0c71f4438a5c07e6 Mon Sep 17 00:00:00 2001 From: Smart123s <28480228+Smart123s@users.noreply.github.com> Date: Fri, 19 Mar 2021 08:58:29 +0100 Subject: [PATCH] Detect if a player is connecting through Floodgate The Floodgate API requires UUID which is inaccessible at the level FastLogion operates on. A workaround for this is to check if the currently connecting player is also a part of the Geyser server's online players list. *TODO: Check for Java and Bedrock name conflicts with multiple configurations.* --- bukkit/pom.xml | 13 +++++++++++++ .../protocollib/ProtocolLibListener.java | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 94ce764d..6b4d4aa8 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -98,6 +98,12 @@ false + + + + nukkitx-snapshot + https://repo.nukkitx.com/maven-snapshots/ + @@ -213,6 +219,13 @@ + + + org.geysermc + connector + 1.2.0-SNAPSHOT + provided + 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 fbc3fda6..2abf273c 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 @@ -12,6 +12,9 @@ import java.security.KeyPair; import java.security.SecureRandom; import org.bukkit.entity.Player; +import org.geysermc.connector.GeyserConnector; +import org.geysermc.connector.common.AuthType; +import org.geysermc.connector.network.session.GeyserSession; import static com.comphenix.protocol.PacketType.Login.Client.ENCRYPTION_BEGIN; import static com.comphenix.protocol.PacketType.Login.Client.START; @@ -87,6 +90,21 @@ public class ProtocolLibListener extends PacketAdapter { String username = packet.getGameProfiles().read(0).getName(); plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username); + // check if the player is connecting through Geyser + if (GeyserConnector.getInstance().getDefaultAuthType() == AuthType.FLOODGATE) { + // the Floodgate API requires UUID, which is inaccessible at this state + // workaround: iterate over Geyser's player's usernames + for (GeyserSession geyserPlayer : GeyserConnector.getInstance().getPlayers()) { + if (geyserPlayer.getName().equals(username)) { + plugin.getLog().info( + "Player {} is connecting throught Geyser Floodgate. FastLogin will not check this player.", + username); + // TODO: auto login (WHEN?) + return; + } + } + } + packetEvent.getAsyncMarker().incrementProcessingDelay(); Runnable nameCheckTask = new NameCheckTask(plugin, packetEvent, random, player, username, keyPair.getPublic()); plugin.getScheduler().runAsync(nameCheckTask);