Search in sources :

Example 1 with PluginMessageRecipient

use of org.bukkit.plugin.messaging.PluginMessageRecipient in project FastLogin by games647.

the class ToggleCommand method sendBungeeActivateMessage.

protected void sendBungeeActivateMessage(CommandSender invoker, String target, boolean activate) {
    if (invoker instanceof PluginMessageRecipient) {
        ChannelMessage message = new ChangePremiumMessage(target, activate, true);
        plugin.getBungeeManager().sendPluginMessage((PluginMessageRecipient) invoker, message);
    } else {
        Optional<? extends Player> optPlayer = Bukkit.getServer().getOnlinePlayers().stream().findFirst();
        if (!optPlayer.isPresent()) {
            plugin.getLog().info("No player online to send a plugin message to the proxy");
            return;
        }
        Player sender = optPlayer.get();
        ChannelMessage message = new ChangePremiumMessage(target, activate, false);
        plugin.getBungeeManager().sendPluginMessage(sender, message);
    }
}
Also used : ChangePremiumMessage(com.github.games647.fastlogin.core.message.ChangePremiumMessage) Player(org.bukkit.entity.Player) PluginMessageRecipient(org.bukkit.plugin.messaging.PluginMessageRecipient) ChannelMessage(com.github.games647.fastlogin.core.message.ChannelMessage)

Aggregations

ChangePremiumMessage (com.github.games647.fastlogin.core.message.ChangePremiumMessage)1 ChannelMessage (com.github.games647.fastlogin.core.message.ChannelMessage)1 Player (org.bukkit.entity.Player)1 PluginMessageRecipient (org.bukkit.plugin.messaging.PluginMessageRecipient)1