Search in sources :

Example 1 with ForceLoginTask

use of com.github.games647.fastlogin.bungee.task.ForceLoginTask in project FastLogin by games647.

the class ConnectionListener method delayForceLogin.

private void delayForceLogin(Player player) {
    // session exists so the player is ready for force login
    // cases: Paper (firing BungeeCord message before PlayerJoinEvent) or not running BungeeCord and already
    // having the login session from the login process
    BukkitLoginSession session = plugin.getSession(player.getAddress());
    if (session == null) {
        // Floodgate players usually don't have a session at this point
        // exception: if force login by bungee message had been delayed
        FloodgateService floodgateService = plugin.getFloodgateService();
        if (floodgateService != null) {
            FloodgatePlayer floodgatePlayer = floodgateService.getBedrockPlayer(player.getUniqueId());
            if (floodgatePlayer != null) {
                Runnable floodgateAuthTask = new FloodgateAuthTask(plugin.getCore(), player, floodgatePlayer);
                Bukkit.getScheduler().runTaskAsynchronously(plugin, floodgateAuthTask);
                return;
            }
        }
        String sessionId = plugin.getSessionId(player.getAddress());
        plugin.getLog().info("No on-going login session for player: {} with ID {}. ", player, sessionId);
        plugin.getLog().info("Setups using Minecraft proxies will start delayed " + "when the command from the proxy is received");
    } else {
        Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
        Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
    }
    plugin.getBungeeManager().markJoinEventFired(player);
}
Also used : ForceLoginTask(com.github.games647.fastlogin.bukkit.task.ForceLoginTask) FloodgatePlayer(org.geysermc.floodgate.api.player.FloodgatePlayer) FloodgateService(com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService) BukkitLoginSession(com.github.games647.fastlogin.bukkit.BukkitLoginSession) FloodgateAuthTask(com.github.games647.fastlogin.bukkit.task.FloodgateAuthTask)

Example 2 with ForceLoginTask

use of com.github.games647.fastlogin.bungee.task.ForceLoginTask in project FastLogin by games647.

the class FloodgateAuthTask method startLogin.

@Override
protected void startLogin() {
    BukkitLoginSession session = new BukkitLoginSession(player.getName(), isRegistered, profile);
    // enable auto login based on the value of 'autoLoginFloodgate' in config.yml
    session.setVerified(isAutoAuthAllowed(autoLoginFloodgate));
    // run login task
    Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, session);
    Bukkit.getScheduler().runTaskAsynchronously(core.getPlugin(), forceLoginTask);
}
Also used : BukkitLoginSession(com.github.games647.fastlogin.bukkit.BukkitLoginSession)

Example 3 with ForceLoginTask

use of com.github.games647.fastlogin.bungee.task.ForceLoginTask in project FastLogin by games647.

the class ConnectListener method onServerConnected.

@EventHandler
public void onServerConnected(ServerConnectedEvent serverConnectedEvent) {
    ProxiedPlayer player = serverConnectedEvent.getPlayer();
    Server server = serverConnectedEvent.getServer();
    FloodgateService floodgateService = plugin.getFloodgateService();
    if (floodgateService != null) {
        FloodgatePlayer floodgatePlayer = floodgateService.getBedrockPlayer(player.getUniqueId());
        if (floodgatePlayer != null) {
            Runnable floodgateAuthTask = new FloodgateAuthTask(plugin.getCore(), player, floodgatePlayer, server);
            plugin.getScheduler().runAsync(floodgateAuthTask);
            return;
        }
    }
    BungeeLoginSession session = plugin.getSession().get(player.getPendingConnection());
    if (session == null) {
        return;
    }
    // delay sending force command, because Paper will process the login event asynchronously
    // In this case it means that the force command (plugin message) is already received and processed while
    // player is still in the login phase and reported to be offline.
    Runnable loginTask = new ForceLoginTask(plugin.getCore(), player, server, session);
    plugin.getScheduler().runAsync(loginTask);
}
Also used : ForceLoginTask(com.github.games647.fastlogin.bungee.task.ForceLoginTask) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) FloodgatePlayer(org.geysermc.floodgate.api.player.FloodgatePlayer) FloodgateService(com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService) Server(net.md_5.bungee.api.connection.Server) BungeeLoginSession(com.github.games647.fastlogin.bungee.BungeeLoginSession) FloodgateAuthTask(com.github.games647.fastlogin.bungee.task.FloodgateAuthTask) EventHandler(net.md_5.bungee.event.EventHandler)

Example 4 with ForceLoginTask

use of com.github.games647.fastlogin.bungee.task.ForceLoginTask in project FastLogin by games647.

the class FloodgateAuthTask method startLogin.

@Override
protected void startLogin() {
    BungeeLoginSession session = new BungeeLoginSession(player.getName(), isRegistered, profile);
    core.getPlugin().getSession().put(player.getPendingConnection(), session);
    // run login task
    Runnable forceLoginTask = new ForceLoginTask(core.getPlugin().getCore(), player, server, session, isAutoAuthAllowed(autoLoginFloodgate));
    core.getPlugin().getScheduler().runAsync(forceLoginTask);
}
Also used : BungeeLoginSession(com.github.games647.fastlogin.bungee.BungeeLoginSession)

Example 5 with ForceLoginTask

use of com.github.games647.fastlogin.bungee.task.ForceLoginTask in project FastLogin by games647.

the class ConnectListener method onServerConnected.

@Subscribe
public void onServerConnected(ServerConnectedEvent serverConnectedEvent) {
    Player player = serverConnectedEvent.getPlayer();
    RegisteredServer server = serverConnectedEvent.getServer();
    VelocityLoginSession session = plugin.getSession().get(player.getRemoteAddress());
    if (session == null) {
        return;
    }
    // delay sending force command, because Paper will process the login event asynchronously
    // In this case it means that the force command (plugin message) is already received and processed while
    // player is still in the login phase and reported to be offline.
    Runnable loginTask = new ForceLoginTask(plugin.getCore(), player, server, session);
    plugin.getProxy().getScheduler().buildTask(plugin, () -> plugin.getScheduler().runAsync(loginTask)).delay(1L, // Delay at least one second, otherwise the login command can be missed
    TimeUnit.SECONDS).schedule();
}
Also used : ForceLoginTask(com.github.games647.fastlogin.velocity.task.ForceLoginTask) Player(com.velocitypowered.api.proxy.Player) RegisteredServer(com.velocitypowered.api.proxy.server.RegisteredServer) VelocityLoginSession(com.github.games647.fastlogin.velocity.VelocityLoginSession) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

BukkitLoginSession (com.github.games647.fastlogin.bukkit.BukkitLoginSession)2 BungeeLoginSession (com.github.games647.fastlogin.bungee.BungeeLoginSession)2 FloodgateService (com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService)2 FloodgatePlayer (org.geysermc.floodgate.api.player.FloodgatePlayer)2 FloodgateAuthTask (com.github.games647.fastlogin.bukkit.task.FloodgateAuthTask)1 ForceLoginTask (com.github.games647.fastlogin.bukkit.task.ForceLoginTask)1 FloodgateAuthTask (com.github.games647.fastlogin.bungee.task.FloodgateAuthTask)1 ForceLoginTask (com.github.games647.fastlogin.bungee.task.ForceLoginTask)1 VelocityLoginSession (com.github.games647.fastlogin.velocity.VelocityLoginSession)1 ForceLoginTask (com.github.games647.fastlogin.velocity.task.ForceLoginTask)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 Player (com.velocitypowered.api.proxy.Player)1 RegisteredServer (com.velocitypowered.api.proxy.server.RegisteredServer)1 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)1 Server (net.md_5.bungee.api.connection.Server)1 EventHandler (net.md_5.bungee.event.EventHandler)1