Search in sources :

Example 1 with FastLoginVelocity

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

the class PluginMessageListener method readMessage.

private void readMessage(Player forPlayer, String channel, byte[] data) {
    FastLoginCore<Player, CommandSource, FastLoginVelocity> core = plugin.getCore();
    ByteArrayDataInput dataInput = ByteStreams.newDataInput(data);
    if (successChannel.equals(channel)) {
        onSuccessMessage(forPlayer);
    } else if (changeChannel.equals(channel)) {
        ChangePremiumMessage changeMessage = new ChangePremiumMessage();
        changeMessage.readFrom(dataInput);
        String playerName = changeMessage.getPlayerName();
        boolean isSourceInvoker = changeMessage.isSourceInvoker();
        if (changeMessage.shouldEnable()) {
            if (playerName.equals(forPlayer.getUsername()) && plugin.getCore().getConfig().get("premium-warning", true) && !core.getPendingConfirms().contains(forPlayer.getUniqueId())) {
                String message = core.getMessage("premium-warning");
                forPlayer.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(message));
                core.getPendingConfirms().add(forPlayer.getUniqueId());
                return;
            }
            core.getPendingConfirms().remove(forPlayer.getUniqueId());
            Runnable task = new AsyncToggleMessage(core, forPlayer, playerName, true, isSourceInvoker);
            plugin.getScheduler().runAsync(task);
        } else {
            Runnable task = new AsyncToggleMessage(core, forPlayer, playerName, false, isSourceInvoker);
            plugin.getScheduler().runAsync(task);
        }
    }
}
Also used : ChangePremiumMessage(com.github.games647.fastlogin.core.message.ChangePremiumMessage) AsyncToggleMessage(com.github.games647.fastlogin.velocity.task.AsyncToggleMessage) Player(com.velocitypowered.api.proxy.Player) FastLoginVelocity(com.github.games647.fastlogin.velocity.FastLoginVelocity) CommandSource(com.velocitypowered.api.command.CommandSource) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput)

Aggregations

ChangePremiumMessage (com.github.games647.fastlogin.core.message.ChangePremiumMessage)1 FastLoginVelocity (com.github.games647.fastlogin.velocity.FastLoginVelocity)1 AsyncToggleMessage (com.github.games647.fastlogin.velocity.task.AsyncToggleMessage)1 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)1 CommandSource (com.velocitypowered.api.command.CommandSource)1 Player (com.velocitypowered.api.proxy.Player)1