Search in sources :

Example 1 with VelocityLoginSession

use of com.github.games647.fastlogin.velocity.VelocityLoginSession in project FastLogin by games647.

the class PluginMessageListener method onSuccessMessage.

private void onSuccessMessage(Player forPlayer) {
    if (forPlayer.isOnlineMode()) {
        // bukkit module successfully received and force logged in the user
        // update only on success to prevent corrupt data
        VelocityLoginSession loginSession = plugin.getSession().get(forPlayer.getRemoteAddress());
        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) VelocityLoginSession(com.github.games647.fastlogin.velocity.VelocityLoginSession)

Example 2 with VelocityLoginSession

use of com.github.games647.fastlogin.velocity.VelocityLoginSession in project FastLogin by games647.

the class AsyncPremiumCheck method requestPremiumLogin.

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

Example 3 with VelocityLoginSession

use of com.github.games647.fastlogin.velocity.VelocityLoginSession 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

VelocityLoginSession (com.github.games647.fastlogin.velocity.VelocityLoginSession)3 StoredProfile (com.github.games647.fastlogin.core.StoredProfile)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