Search in sources :

Example 1 with EventPriority

use of net.md_5.bungee.event.EventPriority in project DiscordBot by LXGaming.

the class PlayerListener method onPlayerDisconnect.

// EventPriority is on Lowest due to LuckPerms unloading player data which causes permissions to be null.
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
    if (!DiscordBotCore.getInstance().getConfiguration().isPlayerQuit() || event.getPlayer().hasPermission("DiscordBot.Silent")) {
        return;
    }
    Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get("Global").getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getPlayerFormat().get("Quit")).setName(event.getPlayer().getName()).setNick(event.getPlayer().getDisplayName()).setServer("Unknown").setMessage("Quit").setDiscord(true).setMinecraft(false).setConsole(false).setRedis(false);
    if (event.getPlayer().getServer() != null && event.getPlayer().getServer().getInfo() != null) {
        message.setServer(event.getPlayer().getServer().getInfo().getName());
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
    return;
}
Also used : Message(io.github.lxgaming.discordbot.entries.Message) EventHandler(net.md_5.bungee.event.EventHandler)

Aggregations

Message (io.github.lxgaming.discordbot.entries.Message)1 EventHandler (net.md_5.bungee.event.EventHandler)1