mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-29 18:27:36 +02:00
Add floodgate service to Bungee
This commit is contained in:
@ -53,6 +53,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
@ -146,7 +147,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
||||
|
||||
private boolean initializeFloodgate() {
|
||||
if (getServer().getPluginManager().getPlugin("Floodgate") != null) {
|
||||
floodgateService = new FloodgateService(core);
|
||||
floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
|
||||
}
|
||||
|
||||
// Check Floodgate config values
|
||||
|
@ -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.getCore().getFloodgateService());
|
||||
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
|
||||
|
||||
this.plugin = plugin;
|
||||
this.packetEvent = packetEvent;
|
||||
|
@ -53,7 +53,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
|
||||
private final RateLimiter rateLimiter;
|
||||
|
||||
public ProtocolSupportListener(FastLoginBukkit plugin, RateLimiter rateLimiter) {
|
||||
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
|
||||
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
|
||||
|
||||
this.plugin = plugin;
|
||||
this.rateLimiter = rateLimiter;
|
||||
|
@ -33,6 +33,7 @@ import com.github.games647.fastlogin.bungee.listener.PluginMessageListener;
|
||||
import com.github.games647.fastlogin.core.AsyncScheduler;
|
||||
import com.github.games647.fastlogin.core.CommonUtil;
|
||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||
import com.github.games647.fastlogin.core.hooks.FloodgateService;
|
||||
import com.github.games647.fastlogin.core.message.ChangePremiumMessage;
|
||||
import com.github.games647.fastlogin.core.message.ChannelMessage;
|
||||
import com.github.games647.fastlogin.core.message.NamespaceKey;
|
||||
@ -59,6 +60,7 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
import net.md_5.bungee.api.scheduler.GroupedThreadFactory;
|
||||
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
@ -70,6 +72,7 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
|
||||
|
||||
private FastLoginCore<ProxiedPlayer, CommandSender, FastLoginBungee> core;
|
||||
private AsyncScheduler scheduler;
|
||||
private FloodgateService floodgateService;
|
||||
private Logger logger;
|
||||
|
||||
@Override
|
||||
@ -83,6 +86,10 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPluginInstalled("Floodgate")) {
|
||||
floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
|
||||
}
|
||||
|
||||
//events
|
||||
PluginManager pluginManager = getProxy().getPluginManager();
|
||||
|
||||
@ -185,4 +192,9 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin<CommandSen
|
||||
public boolean isPluginInstalled(String name) {
|
||||
return getProxy().getPluginManager().getPlugin(name) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloodgateService getFloodgateService() {
|
||||
return floodgateService;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class AsyncPremiumCheck extends JoinManagement<ProxiedPlayer, CommandSend
|
||||
|
||||
public AsyncPremiumCheck(FastLoginBungee plugin, PreLoginEvent preLoginEvent, PendingConnection connection,
|
||||
String username) {
|
||||
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
|
||||
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
|
||||
|
||||
this.plugin = plugin;
|
||||
this.preLoginEvent = preLoginEvent;
|
||||
|
@ -41,9 +41,11 @@ import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
public class FloodgateService {
|
||||
|
||||
private final FloodgateApi floodgate;
|
||||
private final FastLoginCore<?, ?, ?> core;
|
||||
|
||||
public FloodgateService(FastLoginCore<?, ?, ?> core) {
|
||||
public FloodgateService(FloodgateApi floodgate, FastLoginCore<?, ?, ?> core) {
|
||||
this.floodgate = floodgate;
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
@ -84,10 +86,11 @@ public class FloodgateService {
|
||||
* @param username the name of the player
|
||||
* @param source an instance of LoginSource
|
||||
*/
|
||||
public void checkFloodgateNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
|
||||
public void checkNameConflict(String username, LoginSource source) {
|
||||
String allowConflict = core.getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
|
||||
|
||||
// check if the Bedrock player is linked to a Java account
|
||||
FloodgatePlayer floodgatePlayer = getFloodgatePlayer(username);
|
||||
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
|
||||
|
||||
if ("false".equals(allowConflict)
|
||||
@ -151,6 +154,5 @@ public class FloodgateService {
|
||||
|
||||
public boolean isFloodgateConnection(String username) {
|
||||
return getFloodgatePlayer(username) != null;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,6 @@ import java.util.Optional;
|
||||
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
||||
|
||||
protected final FastLoginCore<P, C, ?> core;
|
||||
@ -60,7 +58,7 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
||||
//check if the player is connecting through Floodgate
|
||||
if (floodgateService != null) {
|
||||
if (floodgateService.isFloodgateConnection(username)) {
|
||||
floodgateService.checkFloodgateNameConflict(username, source, floodgatePlayer);
|
||||
floodgateService.checkNameConflict(username, source);
|
||||
// skip flow for any floodgate player
|
||||
return;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
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.message.ChangePremiumMessage;
|
||||
import com.github.games647.fastlogin.core.message.ChannelMessage;
|
||||
import com.github.games647.fastlogin.core.message.SuccessMessage;
|
||||
@ -138,6 +139,11 @@ public class FastLoginVelocity implements PlatformPlugin<CommandSource> {
|
||||
return server.getPluginManager().isLoaded(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloodgateService getFloodgateService() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public FastLoginCore<Player, CommandSource, FastLoginVelocity> getCore() {
|
||||
return core;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ 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());
|
||||
super(plugin.getCore(), plugin.getCore().getAuthPluginHook(), plugin.getFloodgateService());
|
||||
this.plugin = plugin;
|
||||
this.connection = connection;
|
||||
this.username = username;
|
||||
|
Reference in New Issue
Block a user