Detect Geyser connections at packet level

It is possible to use Geyser without Floodgate by configuring Geyser to
use auth-type= 'online' or 'offline'. In that scenario, floodgateService
will be either unavailable or empty.
This commit is contained in:
Smart123s
2021-10-24 10:18:34 +02:00
committed by games647
parent 3ee6cb2ada
commit f570474fa3
5 changed files with 15 additions and 5 deletions

View File

@ -54,7 +54,7 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
public NameCheckTask(FastLoginBukkit plugin, Random random, Player player, PacketEvent packetEvent,
String username, PublicKey publicKey) {
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService(), plugin.getGeyserService());
this.plugin = plugin;
this.packetEvent = packetEvent;

View File

@ -53,7 +53,8 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
private final RateLimiter rateLimiter;
public ProtocolSupportListener(FastLoginBukkit plugin, RateLimiter rateLimiter) {
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService(),
plugin.getGeyserService());
this.plugin = plugin;
this.rateLimiter = rateLimiter;

View File

@ -49,7 +49,8 @@ public class AsyncPremiumCheck extends JoinManagement<ProxiedPlayer, CommandSend
public AsyncPremiumCheck(FastLoginBungee plugin, PreLoginEvent preLoginEvent, PendingConnection connection,
String username) {
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService(),
plugin.getGeyserService());
this.plugin = plugin;
this.preLoginEvent = preLoginEvent;

View File

@ -30,6 +30,7 @@ import com.github.games647.craftapi.resolver.RateLimitException;
import com.github.games647.fastlogin.core.StoredProfile;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import com.github.games647.fastlogin.core.hooks.FloodgateService;
import com.github.games647.fastlogin.core.hooks.GeyserService;
import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
import java.util.Optional;
@ -41,11 +42,13 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
protected final FastLoginCore<P, C, ?> core;
protected final AuthPlugin<P> authHook;
private final FloodgateService floodgateService;
private final GeyserService geyserService;
public JoinManagement(FastLoginCore<P, C, ?> core, AuthPlugin<P> authHook, FloodgateService floodService) {
public JoinManagement(FastLoginCore<P, C, ?> core, AuthPlugin<P> 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<P extends C, C, S extends LoginSource> {
return;
}
}
//check if the player is connecting through Geyser (without Floodgate)
else if (geyserService != null && geyserService.isGeyserConnection(username)) {
}
callFastLoginPreLoginEvent(username, source, profile);

View File

@ -50,7 +50,8 @@ public class AsyncPremiumCheck extends JoinManagement<Player, CommandSource, Vel
private final InboundConnection connection;
public AsyncPremiumCheck(FastLoginVelocity plugin, InboundConnection connection, String username, Continuation continuation, PreLoginEvent preLoginEvent) {
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService(),
plugin.getGeyserService());
this.plugin = plugin;
this.connection = connection;
this.username = username;