Search in sources :

Example 1 with BungeeLoginSession

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

the class AsyncPremiumCheck method requestPremiumLogin.

@Override
public void requestPremiumLogin(BungeeLoginSource source, StoredProfile profile, String username, boolean registered) {
    source.enableOnlinemode();
    plugin.getSession().put(source.getConnection(), new BungeeLoginSession(username, registered, profile));
    String ip = source.getAddress().getAddress().getHostAddress();
    plugin.getCore().getPendingLogin().put(ip + username, new Object());
}
Also used : BungeeLoginSession(com.github.games647.fastlogin.bungee.BungeeLoginSession)

Example 2 with BungeeLoginSession

use of com.github.games647.fastlogin.bungee.BungeeLoginSession 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 3 with BungeeLoginSession

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

the class PluginMessageListener method onSuccessMessage.

private void onSuccessMessage(ProxiedPlayer forPlayer) {
    boolean shouldPersist = forPlayer.getPendingConnection().isOnlineMode();
    FloodgateService floodgateService = plugin.getFloodgateService();
    if (!shouldPersist && floodgateService != null) {
        // always save floodgate players to lock this username
        shouldPersist = floodgateService.isBedrockPlayer(forPlayer.getUniqueId());
    }
    if (shouldPersist) {
        // bukkit module successfully received and force logged in the user
        // update only on success to prevent corrupt data
        BungeeLoginSession loginSession = plugin.getSession().get(forPlayer.getPendingConnection());
        StoredProfile playerProfile = loginSession.getProfile();
        loginSession.setRegistered(true);
        if (!loginSession.isAlreadySaved()) {
            playerProfile.setPremium(true);
            plugin.getCore().getStorage().save(playerProfile);
            loginSession.setAlreadySaved(true);
        }
    }
}
Also used : StoredProfile(com.github.games647.fastlogin.core.StoredProfile) FloodgateService(com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService) BungeeLoginSession(com.github.games647.fastlogin.bungee.BungeeLoginSession)

Example 4 with BungeeLoginSession

use of com.github.games647.fastlogin.bungee.BungeeLoginSession 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)

Aggregations

BungeeLoginSession (com.github.games647.fastlogin.bungee.BungeeLoginSession)4 FloodgateService (com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService)2 FloodgateAuthTask (com.github.games647.fastlogin.bungee.task.FloodgateAuthTask)1 ForceLoginTask (com.github.games647.fastlogin.bungee.task.ForceLoginTask)1 StoredProfile (com.github.games647.fastlogin.core.StoredProfile)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 FloodgatePlayer (org.geysermc.floodgate.api.player.FloodgatePlayer)1