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);
}
}
}
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());
}
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();
}
Aggregations