Search in sources :

Example 6 with LoginSession

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

the class FastLoginBukkit method onEnable.

@Override
public void onEnable() {
    core = new FastLoginCore<>(this);
    core.load();
    if (getServer().getOnlineMode()) {
        // we need to require offline to prevent a loginSession request for an offline player
        logger.error("Server has to be in offline mode");
        setEnabled(false);
        return;
    }
    if (!initializeFloodgate()) {
        setEnabled(false);
    }
    bungeeManager = new BungeeManager(this);
    bungeeManager.initialize();
    PluginManager pluginManager = getServer().getPluginManager();
    if (bungeeManager.isEnabled()) {
        markInitialized();
    } else {
        if (!core.setupDatabase()) {
            setEnabled(false);
            return;
        }
        if (pluginManager.isPluginEnabled("ProtocolSupport")) {
            pluginManager.registerEvents(new ProtocolSupportListener(this, core.getRateLimiter()), this);
        } else if (pluginManager.isPluginEnabled("ProtocolLib")) {
            ProtocolLibListener.register(this, core.getRateLimiter());
            if (isPluginInstalled("floodgate")) {
                if (getConfig().getBoolean("floodgatePrefixWorkaround")) {
                    ManualNameChange.register(this, floodgateService);
                    logger.info("Floodgate prefix injection workaround has been enabled.");
                    logger.info("If you have problems joining the server, try disabling it in the configuration.");
                } else {
                    logger.warn("We have detected that you are runnging FastLogin alongside Floodgate and ProtocolLib.");
                    logger.warn("Currently there is an issue with FastLogin that prevents Floodgate name prefixes from showing up " + "when it is together used with ProtocolLib.");
                    logger.warn("If you would like to use Floodgate name prefixes, you can enable an experimental workaround by changing " + "the value 'floodgatePrefixWorkaround' to true in config.yml.");
                    logger.warn("For more information visit https://github.com/games647/FastLogin/issues/493");
                }
            }
            // if server is using paper - we need to set the skin at pre login anyway, so no need for this listener
            if (!PaperLib.isPaper() && getConfig().getBoolean("forwardSkin")) {
                pluginManager.registerEvents(new SkinApplyListener(this), this);
            }
        } else {
            logger.warn("Either ProtocolLib or ProtocolSupport have to be installed if you don't use BungeeCord");
            setEnabled(false);
            return;
        }
    }
    // delay dependency setup because we load the plugin very early where plugins are initialized yet
    getServer().getScheduler().runTaskLater(this, new DelayedAuthHook(this), 5L);
    pluginManager.registerEvents(new ConnectionListener(this), this);
    // if server is using paper - we need to add one more listener to correct the user cache usage
    if (PaperLib.isPaper()) {
        pluginManager.registerEvents(new PaperCacheListener(this), this);
    }
    // register commands using a unique name
    Optional.ofNullable(getCommand("premium")).ifPresent(c -> c.setExecutor(new PremiumCommand(this)));
    Optional.ofNullable(getCommand("cracked")).ifPresent(c -> c.setExecutor(new CrackedCommand(this)));
    if (pluginManager.isPluginEnabled("PlaceholderAPI")) {
        premiumPlaceholder = new PremiumPlaceholder(this);
        premiumPlaceholder.register();
    }
    dependencyWarnings();
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) PremiumCommand(com.github.games647.fastlogin.bukkit.command.PremiumCommand) ProtocolSupportListener(com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener) SkinApplyListener(com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener) CrackedCommand(com.github.games647.fastlogin.bukkit.command.CrackedCommand) ConnectionListener(com.github.games647.fastlogin.bukkit.listener.ConnectionListener) PaperCacheListener(com.github.games647.fastlogin.bukkit.listener.PaperCacheListener) DelayedAuthHook(com.github.games647.fastlogin.bukkit.task.DelayedAuthHook)

Example 7 with LoginSession

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

the class ForceLoginTask method callFastLoginAutoLoginEvent.

@Override
public FastLoginAutoLoginEvent callFastLoginAutoLoginEvent(LoginSession session, StoredProfile profile) {
    BukkitFastLoginAutoLoginEvent event = new BukkitFastLoginAutoLoginEvent(session, profile);
    core.getPlugin().getServer().getPluginManager().callEvent(event);
    return event;
}
Also used : BukkitFastLoginAutoLoginEvent(com.github.games647.fastlogin.bukkit.event.BukkitFastLoginAutoLoginEvent)

Example 8 with LoginSession

use of com.github.games647.fastlogin.core.shared.LoginSession 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 9 with LoginSession

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

the class ForceLoginTask method onForceActionSuccess.

@Override
public void onForceActionSuccess(LoginSession session) {
    // sub channel name
    Type type = Type.LOGIN;
    if (session.needsRegistration()) {
        type = Type.REGISTER;
    }
    UUID proxyId = UUID.fromString(ProxyServer.getInstance().getConfig().getUuid());
    ChannelMessage loginMessage = new LoginActionMessage(type, player.getName(), proxyId);
    core.getPlugin().sendPluginMessage(server, loginMessage);
}
Also used : Type(com.github.games647.fastlogin.core.message.LoginActionMessage.Type) LoginActionMessage(com.github.games647.fastlogin.core.message.LoginActionMessage) UUID(java.util.UUID) ChannelMessage(com.github.games647.fastlogin.core.message.ChannelMessage)

Example 10 with LoginSession

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

the class ConnectListener method onGameprofileRequest.

@Subscribe
public void onGameprofileRequest(GameProfileRequestEvent event) {
    if (event.isOnlineMode()) {
        LoginSession session = plugin.getSession().get(event.getConnection().getRemoteAddress());
        UUID verifiedUUID = event.getGameProfile().getId();
        String verifiedUsername = event.getUsername();
        session.setUuid(verifiedUUID);
        session.setVerifiedUsername(verifiedUsername);
        StoredProfile playerProfile = session.getProfile();
        playerProfile.setId(verifiedUUID);
        if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
            UUID offlineUUID = UUIDAdapter.generateOfflineId(playerProfile.getName());
            event.setGameProfile(event.getGameProfile().withId(offlineUUID));
            plugin.getLog().info("Overridden UUID from {} to {} (based of {}) on {}", verifiedUUID, offlineUUID, verifiedUsername, event.getConnection());
        }
        if (!plugin.getCore().getConfig().get("forwardSkin", true)) {
            event.setGameProfile(event.getGameProfile().withProperties(removeSkin(event.getGameProfile().getProperties())));
        }
    }
}
Also used : VelocityLoginSession(com.github.games647.fastlogin.velocity.VelocityLoginSession) LoginSession(com.github.games647.fastlogin.core.shared.LoginSession) StoredProfile(com.github.games647.fastlogin.core.StoredProfile) UUID(java.util.UUID) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

StoredProfile (com.github.games647.fastlogin.core.StoredProfile)4 UUID (java.util.UUID)4 BukkitLoginSession (com.github.games647.fastlogin.bukkit.BukkitLoginSession)2 BungeeLoginSession (com.github.games647.fastlogin.bungee.BungeeLoginSession)2 ChannelMessage (com.github.games647.fastlogin.core.message.ChannelMessage)2 LoginActionMessage (com.github.games647.fastlogin.core.message.LoginActionMessage)2 Type (com.github.games647.fastlogin.core.message.LoginActionMessage.Type)2 LoginSession (com.github.games647.fastlogin.core.shared.LoginSession)2 VelocityLoginSession (com.github.games647.fastlogin.velocity.VelocityLoginSession)2 CrackedCommand (com.github.games647.fastlogin.bukkit.command.CrackedCommand)1 PremiumCommand (com.github.games647.fastlogin.bukkit.command.PremiumCommand)1 BukkitFastLoginAutoLoginEvent (com.github.games647.fastlogin.bukkit.event.BukkitFastLoginAutoLoginEvent)1 ConnectionListener (com.github.games647.fastlogin.bukkit.listener.ConnectionListener)1 PaperCacheListener (com.github.games647.fastlogin.bukkit.listener.PaperCacheListener)1 SkinApplyListener (com.github.games647.fastlogin.bukkit.listener.protocollib.SkinApplyListener)1 ProtocolSupportListener (com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener)1 DelayedAuthHook (com.github.games647.fastlogin.bukkit.task.DelayedAuthHook)1 FloodgateService (com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 PendingConnection (net.md_5.bungee.api.connection.PendingConnection)1