From 2f61a8f8adb8495dbe5d104ffc46356777d7481f Mon Sep 17 00:00:00 2001 From: Smart123s <28480228+Smart123s@users.noreply.github.com> Date: Sun, 24 Oct 2021 17:33:34 +0200 Subject: [PATCH] Add packet level checks for Geyser If AuthType == ONLINE, players will be treated as if they were Java players If AuthType == OFFLINE, name conflicts will be checked the same way it's done with Floodgate Updated config.yml to infrom about the changes. --- .../core/hooks/bedrock/GeyserService.java | 16 ++++++++++++---- core/src/main/resources/config.yml | 15 ++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/GeyserService.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/GeyserService.java index 0fafddf6..181927e9 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/GeyserService.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/GeyserService.java @@ -31,26 +31,34 @@ import com.github.games647.fastlogin.core.shared.FastLoginCore; import com.github.games647.fastlogin.core.shared.LoginSource; import org.geysermc.connector.GeyserConnector; +import org.geysermc.connector.common.AuthType; import org.geysermc.connector.network.session.GeyserSession; public class GeyserService extends BedrockService { private final GeyserConnector geyser; private final FastLoginCore core; + private final AuthType authType; public GeyserService(GeyserConnector geyser, FastLoginCore core) { super(core); this.geyser = geyser; this.core = core; + this.authType = geyser.getConfig().getRemote().getAuthType(); } @Override public boolean performChecks(String username, LoginSource source) { - //TODO: Replace stub with Geyser specific code - if ("false".equals(allowConflict)) { - super.checkNameConflict(username, source); - } else { + // AuthType.FLOODGATE will be handled by FloodgateService + if (authType == AuthType.ONLINE) { + // authenticate everyone, as if they were Java players, since they have signed + // in through Mojang + return false; + } + if ("true".equals(allowConflict)) { core.getPlugin().getLog().info("Skipping name conflict checking for player {}", username); + } else { + super.checkNameConflict(username, source); } return true; } diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index 1581d4da..8cdcb5d1 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -205,8 +205,8 @@ autoLogin: true # Enabling this might lead to people gaining unauthorized access to other's accounts! autoLoginFloodgate: false -# This enables Floodgate players to join the server, even if autoRegister is true and there's an existing -# Java **PREMIUM** account with the same name +# This enables Floodgate or Offline Geyser players to join the server, even if they are using the name of an +# existing Java **PREMIUM** account (so someone has bought Minecraft with that username) # # Java and Bedrock players will get different UUIDs, so their inventories, location, etc. will be different. # However, some plugins (such as AuthMe) rely on names instead of UUIDs to identify a player which might cause issues. @@ -219,12 +219,13 @@ autoLoginFloodgate: false # A solution to this is to replace ProtocolLib with ProtocolSupport # # Possible values: -# false: Check for Premium Java name conflicts as described in 'autoRegister' -# Note: Linked players have the same name as their Java profile, so the Bedrock player will always conflict +# false: Kick Bedrock players, if they are using an existing Premium Java account's name +# Note: Linked Floodgate players have the same name as their Java profile, so the Bedrock player will always conflict # their own Java account's name. Therefore, setting this to false will prevent any linked player from joining. -# true: Bypass 'autoRegister's name conflict checking -# linked: Bedrock accounts linked to a Java account will be allowed to join with conflicting names -# !!!!!!!! WARNING: FLOODGATE SUPPORT IS AN EXPERIMENTAL FEATURE !!!!!!!! +# true: Bypass name conflict checking. +# linked: Floodgate accounts linked to a Java account will be allowed to join with conflicting names +# For Offline Geyser players, 'linked' works as 'false' +# !!!!!!!! WARNING: FLOODGATE/GEYSER SUPPORT IS AN EXPERIMENTAL FEATURE !!!!!!!! # Enabling this might lead to people gaining unauthorized access to other's accounts! allowFloodgateNameConflict: false