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 void onLogin(String username, S source) {
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 d219ef46d..7a93d8fa9 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 1268a865f..2d53b6c9d 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 69ae08991..543ef67e1 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 bc5e62d9a7037b18cf95952ec8b656e332e4a2c8 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 c08bc0da2..c3171bc0c 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.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 boolean isPluginInstalled(String name) {
return Bukkit.getServer().getPluginManager().getPlugin(name) != null;
}
- @Override
public FloodgateService getFloodgateService() {
return floodgateService;
}
- @Override
public GeyserService getGeyserService() {
return geyserService;
}
+ @Override
+ public BedrockService> getBedrockService() {
+ if (floodgateService != null) {
+ return floodgateService;
+ }
+ return geyserService;
+ }
+
/**
* Send warning messages to log if incompatible plugins are used
*/
diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java
index 531d2550c..760517804 100644
--- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java
+++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ConnectionListener.java
@@ -82,7 +82,7 @@ private void delayForceLogin(Player player) {
BukkitLoginSession session = plugin.getSession(player.getAddress());
FloodgateService floodgateService = plugin.getFloodgateService();
if (floodgateService != null) {
- FloodgatePlayer floodgatePlayer = floodgateService.getFloodgatePlayer(player.getUniqueId());
+ FloodgatePlayer floodgatePlayer = floodgateService.getBedrockPlayer(player.getUniqueId());
if (floodgatePlayer != null) {
Runnable floodgateAuthTask = new FloodgateAuthTask(plugin.getCore(), player, floodgatePlayer);
Bukkit.getScheduler().runTaskAsynchronously(plugin, floodgateAuthTask);
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 289fd3582..76bf5053c 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
@@ -54,7 +54,7 @@ public class NameCheckTask extends JoinManagement {
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 void onLogin(String username, S source) {
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 @@ else if (geyserService != null && geyserService.isGeyserConnection(username)) {
}
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 2d53b6c9d..1c4eccf21 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 @@ default void sendMultiLineMessage(C receiver, String message) {
}
}
- FloodgateService getFloodgateService();
-
- GeyserService getGeyserService();
+ BedrockService> getBedrockService();
default ThreadFactory getThreadFactory() {
return new ThreadFactoryBuilder()
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 543ef67e1..a96414599 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,7 @@
package com.github.games647.fastlogin.velocity;
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.github.games647.fastlogin.core.message.ChangePremiumMessage;
import com.github.games647.fastlogin.core.message.ChannelMessage;
import com.github.games647.fastlogin.core.message.SuccessMessage;
@@ -141,12 +140,7 @@ public boolean isPluginInstalled(String name) {
}
@Override
- public FloodgateService getFloodgateService() {
- return null;
- }
-
- @Override
- public GeyserService getGeyserService() {
+ public BedrockService> getBedrockService() {
return null;
}
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 7a93d8fa9..3828e2b6f 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,8 +50,7 @@ public class AsyncPremiumCheck extends JoinManagement
+ * 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 f97b952f7..a69c896b3 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 org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
-public class FloodgateService extends BedrockService {
+public class FloodgateService extends BedrockService