core; protected final AuthPlugin
authHook; private final FloodgateService floodgateService; + private final GeyserService geyserService; - public JoinManagement(FastLoginCore
core, AuthPlugin
authHook, FloodgateService floodService) { + public JoinManagement(FastLoginCore
core, AuthPlugin
authHook, FloodgateService floodService, GeyserService geyserService) { this.core = core; this.authHook = authHook; this.floodgateService = floodService; + this.geyserService = geyserService; } public void onLogin(String username, S source) { @@ -63,6 +66,10 @@ public abstract class JoinManagement
{
return;
}
}
+ //check if the player is connecting through Geyser (without Floodgate)
+ else if (geyserService != null && geyserService.isGeyserConnection(username)) {
+
+ }
callFastLoginPreLoginEvent(username, source, profile);
diff --git a/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncPremiumCheck.java b/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncPremiumCheck.java
index d219ef46..7a93d8fa 100644
--- a/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncPremiumCheck.java
+++ b/velocity/src/main/java/com/github/games647/fastlogin/velocity/task/AsyncPremiumCheck.java
@@ -50,7 +50,8 @@ public class AsyncPremiumCheck extends JoinManagement {
private final FloodgateService floodgateService;
private final GeyserService geyserService;
- public JoinManagement(FastLoginCore core, AuthPlugin authHook, FloodgateService floodService, GeyserService geyserService) {
+ public JoinManagement(FastLoginCore core, AuthPlugin authHook, FloodgateService floodService,
+ GeyserService geyserService) {
this.core = core;
this.authHook = authHook;
this.floodgateService = floodService;
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
index 1268a865..2d53b6c9 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
@@ -26,8 +26,8 @@
package com.github.games647.fastlogin.core.shared;
import com.github.games647.fastlogin.core.AsyncScheduler;
-import com.github.games647.fastlogin.core.hooks.FloodgateService;
-import com.github.games647.fastlogin.core.hooks.GeyserService;
+import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
+import com.github.games647.fastlogin.core.hooks.bedrock.GeyserService;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.nio.file.Path;
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 69ae0899..543ef67e 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
@@ -26,8 +26,8 @@
package com.github.games647.fastlogin.velocity;
import com.github.games647.fastlogin.core.AsyncScheduler;
-import com.github.games647.fastlogin.core.hooks.FloodgateService;
-import com.github.games647.fastlogin.core.hooks.GeyserService;
+import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
+import com.github.games647.fastlogin.core.hooks.bedrock.GeyserService;
import com.github.games647.fastlogin.core.message.ChangePremiumMessage;
import com.github.games647.fastlogin.core.message.ChannelMessage;
import com.github.games647.fastlogin.core.message.SuccessMessage;
From fcd2aa95f04ae74e7968cd76110399222110788f Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sun, 24 Oct 2021 15:30:47 +0200
Subject: [PATCH 4/9] Use BedrockService in JoinManagement
Since the code only needs to interact with Geyser, if Floodgate is not
installed, and perform similar things with both, it's reasonable, to
merge their code.
This commit breaks premium checking with `auth-type=online` in Geyser
---
.../fastlogin/bukkit/FastLoginBukkit.java | 11 ++++-
.../bukkit/listener/ConnectionListener.java | 2 +-
.../listener/protocollib/NameCheckTask.java | 2 +-
.../ProtocolSupportListener.java | 3 +-
.../fastlogin/bungee/FastLoginBungee.java | 11 ++++-
.../bungee/listener/ConnectListener.java | 2 +-
.../listener/PluginMessageListener.java | 2 +-
.../bungee/task/AsyncPremiumCheck.java | 3 +-
.../core/hooks/bedrock/BedrockService.java | 42 ++++++++++++++++++-
.../core/hooks/bedrock/FloodgateService.java | 17 ++++----
.../core/hooks/bedrock/GeyserService.java | 24 +++--------
.../fastlogin/core/shared/JoinManagement.java | 28 +++++--------
.../fastlogin/core/shared/PlatformPlugin.java | 7 +---
.../fastlogin/velocity/FastLoginVelocity.java | 10 +----
.../velocity/task/AsyncPremiumCheck.java | 3 +-
15 files changed, 94 insertions(+), 73 deletions(-)
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java
index c08bc0da..c3171bc0 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java
@@ -35,6 +35,7 @@ import com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSup
import com.github.games647.fastlogin.bukkit.task.DelayedAuthHook;
import com.github.games647.fastlogin.core.CommonUtil;
import com.github.games647.fastlogin.core.PremiumStatus;
+import com.github.games647.fastlogin.core.hooks.bedrock.BedrockService;
import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
import com.github.games647.fastlogin.core.hooks.bedrock.GeyserService;
import com.github.games647.fastlogin.core.shared.FastLoginCore;
@@ -283,16 +284,22 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin {
protected final FastLoginCore core;
protected final AuthPlugin authHook;
- private final FloodgateService floodgateService;
- private final GeyserService geyserService;
+ private final BedrockService> bedrockService;
- public JoinManagement(FastLoginCore core, AuthPlugin authHook, FloodgateService floodService,
- GeyserService geyserService) {
+ public JoinManagement(FastLoginCore core, AuthPlugin authHook, BedrockService> bedrockService) {
this.core = core;
this.authHook = authHook;
- this.floodgateService = floodService;
- this.geyserService = geyserService;
+ this.bedrockService = bedrockService;
}
public void onLogin(String username, S source) {
@@ -59,18 +55,14 @@ public abstract class JoinManagement {
return;
}
- //check if the player is connecting through Floodgate
- if (floodgateService != null) {
- if (floodgateService.isFloodgateConnection(username)) {
- floodgateService.checkNameConflict(username, source);
- // skip flow for any floodgate player
+ //check if the player is connecting through Bedrock Edition
+ if (bedrockService != null) {
+ if (bedrockService.isBedrockConnection(username)) {
+ bedrockService.checkNameConflict(username, source);
+ // skip flow for any Bedrock player
return;
}
}
- //check if the player is connecting through Geyser (without Floodgate)
- else if (geyserService != null && geyserService.isGeyserConnection(username)) {
-
- }
callFastLoginPreLoginEvent(username, source, profile);
@@ -125,7 +117,7 @@ public abstract class JoinManagement {
}
protected boolean isValidUsername(LoginSource source, StoredProfile profile) throws Exception {
- if (floodgateService != null && floodgateService.isUsernameForbidden(profile)) {
+ if (bedrockService != null && bedrockService.isUsernameForbidden(profile)) {
core.getPlugin().getLog().info("Floodgate Prefix detected on cracked player");
source.kick("Your username contains illegal characters");
return false;
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
index 2d53b6c9..1c4eccf2 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/PlatformPlugin.java
@@ -26,8 +26,7 @@
package com.github.games647.fastlogin.core.shared;
import com.github.games647.fastlogin.core.AsyncScheduler;
-import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
-import com.github.games647.fastlogin.core.hooks.bedrock.GeyserService;
+import com.github.games647.fastlogin.core.hooks.bedrock.BedrockService;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.nio.file.Path;
@@ -55,9 +54,7 @@ public interface PlatformPlugin {
}
//check if the player is connecting through Bedrock Edition
- if (bedrockService != null) {
- if (bedrockService.isBedrockConnection(username)) {
- bedrockService.checkNameConflict(username, source);
- // skip flow for any Bedrock player
+ if (bedrockService != null && bedrockService.isBedrockConnection(username)) {
+ //perform Bedrock specific checks and skip Java checks, if they are not needed
+ if (bedrockService.performChecks(username, source)) {
return;
}
}
From d0a78329290f7607cb66d41e1214e5a7d7201867 Mon Sep 17 00:00:00 2001
From: Smart123s <28480228+Smart123s@users.noreply.github.com>
Date: Sun, 24 Oct 2021 16:24:50 +0200
Subject: [PATCH 7/9] Remove unused Floodgate 1.0 dependency
---
bungee/pom.xml | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/bungee/pom.xml b/bungee/pom.xml
index 9670c577..778eb077 100644
--- a/bungee/pom.xml
+++ b/bungee/pom.xml
@@ -123,15 +123,6 @@
+ * Falls back to non-prefixed name checks, if ProtocolLib is installed
+ *
+ * @param prefixedUsername the name of the player with the prefix appended
+ * @return Bedrock Player if found, null otherwise
+ */
+ public B getBedrockPlayer(String prefixedUsername) {
+ return null;
+ }
+
+ public B getBedrockPlayer(UUID uuid) {
+ return null;
+ }
+
+ public boolean isBedrockPlayer(UUID uuid) {
+ return getBedrockPlayer(uuid) != null;
+ }
+
+ public boolean isBedrockConnection(String username) {
+ return getBedrockPlayer(username) != null;
+ }
+
+ /**
+ * Checks if a profile's name starts with the Floodgate prefix, if it's available
+ * @param profile profile of the conecting player
+ * @return true if the username is forbidden
+ */
+ public boolean isUsernameForbidden(StoredProfile profile) {
+ return false;
+ }
+
}
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 f97b952f..a69c896b 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
@@ -35,7 +35,7 @@ import java.util.UUID;
import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
-public class FloodgateService extends BedrockService {
+public class FloodgateService extends BedrockService