Search in sources :

Example 1 with StoredProfile

use of com.github.games647.fastlogin.core.StoredProfile 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 StoredProfile

use of com.github.games647.fastlogin.core.StoredProfile 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 StoredProfile

use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.

the class AsyncToggleMessage method turnOffPremium.

private void turnOffPremium() {
    StoredProfile playerProfile = core.getStorage().loadProfile(targetPlayer);
    // existing player is already cracked
    if (playerProfile.isSaved() && !playerProfile.isPremium()) {
        sendMessage("not-premium");
        return;
    }
    playerProfile.setPremium(false);
    playerProfile.setId(null);
    core.getStorage().save(playerProfile);
    PremiumToggleReason reason = (!isPlayerSender || !senderName.equalsIgnoreCase(playerProfile.getName())) ? PremiumToggleReason.COMMAND_OTHER : PremiumToggleReason.COMMAND_SELF;
    core.getPlugin().getProxy().getEventManager().fire(new VelocityFastLoginPremiumToggleEvent(playerProfile, reason));
    sendMessage("remove-premium");
}
Also used : StoredProfile(com.github.games647.fastlogin.core.StoredProfile) VelocityFastLoginPremiumToggleEvent(com.github.games647.fastlogin.velocity.event.VelocityFastLoginPremiumToggleEvent) PremiumToggleReason(com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason)

Example 4 with StoredProfile

use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.

the class ConnectListener method onLogin.

@EventHandler(priority = EventPriority.LOWEST)
public void onLogin(LoginEvent loginEvent) {
    if (loginEvent.isCancelled()) {
        return;
    }
    // use the login event instead of the post login event in order to send the login success packet to the client
    // with the offline uuid this makes it possible to set the skin then
    PendingConnection connection = loginEvent.getConnection();
    if (connection.isOnlineMode()) {
        LoginSession session = plugin.getSession().get(connection);
        UUID verifiedUUID = connection.getUniqueId();
        String verifiedUsername = connection.getName();
        session.setUuid(verifiedUUID);
        session.setVerifiedUsername(verifiedUsername);
        StoredProfile playerProfile = session.getProfile();
        playerProfile.setId(verifiedUUID);
        // bungeecord will do this automatically so override it on disabled option
        if (uniqueIdSetter != null) {
            InitialHandler initialHandler = (InitialHandler) connection;
            if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
                setOfflineId(initialHandler, verifiedUsername);
            }
            if (!plugin.getCore().getConfig().get("forwardSkin", true)) {
                // this is null on offline mode
                LoginResult loginProfile = initialHandler.getLoginProfile();
                loginProfile.setProperties(emptyProperties);
            }
        }
    }
}
Also used : BungeeLoginSession(com.github.games647.fastlogin.bungee.BungeeLoginSession) LoginSession(com.github.games647.fastlogin.core.shared.LoginSession) StoredProfile(com.github.games647.fastlogin.core.StoredProfile) LoginResult(net.md_5.bungee.connection.LoginResult) PendingConnection(net.md_5.bungee.api.connection.PendingConnection) UUID(java.util.UUID) InitialHandler(net.md_5.bungee.connection.InitialHandler) EventHandler(net.md_5.bungee.event.EventHandler)

Example 5 with StoredProfile

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

Aggregations

StoredProfile (com.github.games647.fastlogin.core.StoredProfile)17 BukkitLoginSession (com.github.games647.fastlogin.bukkit.BukkitLoginSession)4 BukkitFastLoginPremiumToggleEvent (com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPremiumToggleEvent)4 PremiumToggleReason (com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason)4 UUID (java.util.UUID)4 BungeeLoginSession (com.github.games647.fastlogin.bungee.BungeeLoginSession)3 VelocityLoginSession (com.github.games647.fastlogin.velocity.VelocityLoginSession)3 Profile (com.github.games647.craftapi.model.Profile)2 RateLimitException (com.github.games647.craftapi.resolver.RateLimitException)2 BukkitFastLoginPreLoginEvent (com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent)2 BungeeFastLoginPremiumToggleEvent (com.github.games647.fastlogin.bungee.event.BungeeFastLoginPremiumToggleEvent)2 LoginSession (com.github.games647.fastlogin.core.shared.LoginSession)2 VelocityFastLoginPremiumToggleEvent (com.github.games647.fastlogin.velocity.event.VelocityFastLoginPremiumToggleEvent)2 BukkitFastLoginAutoLoginEvent (com.github.games647.fastlogin.bukkit.event.BukkitFastLoginAutoLoginEvent)1 FloodgateService (com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService)1 SQLStorage (com.github.games647.fastlogin.core.storage.SQLStorage)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 IOException (java.io.IOException)1 Instant (java.time.Instant)1 PendingConnection (net.md_5.bungee.api.connection.PendingConnection)1