Search in sources :

Example 1 with Message

use of io.github.lxgaming.discordbot.entries.Message in project DiscordBot by LXGaming.

the class PlayerListener method onPlayerDeath.

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
    if (!DiscordBotCore.getInstance().getConfiguration().isPlayerDeath() || event.getEntity().hasPermission("DiscordBot.Silent")) {
        return;
    }
    Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get("InGame").getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get("InGame")).setName(event.getEntity().getName()).setNick(event.getEntity().getDisplayName()).setServer("Unknown").setMessage(event.getDeathMessage()).setDiscord(true).setMinecraft(false).setConsole(false).setRedis(false);
    if (event.getEntity().getServer() != null && event.getEntity().getServer().getName() != null) {
        message.setServer(event.getEntity().getServer().getName());
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
    return;
}
Also used : Message(io.github.lxgaming.discordbot.entries.Message) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Message

use of io.github.lxgaming.discordbot.entries.Message in project DiscordBot by LXGaming.

the class PlayerListener method onPlayerChat.

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncPlayerChatEvent event) {
    if (event.isCancelled() && !DiscordBotCore.getInstance().getConfiguration().isForceChat()) {
        return;
    }
    Player player = event.getPlayer();
    String permission = DiscordBotCore.getInstance().getConfiguration().getChannels().get("Global").getPermission();
    boolean hasPermission = false;
    if (permission == null || permission.trim().equals("") || permission.trim().equals("null")) {
        hasPermission = false;
    } else if (permission.equals("*") || player.hasPermission(permission)) {
        hasPermission = true;
    }
    if (!DiscordBotCore.getInstance().getConfiguration().isPlayerChat() || !hasPermission || DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(player.getUniqueId())) {
        return;
    }
    Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get("Global").getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get("Global")).setName(player.getName()).setNick(player.getDisplayName()).setServer("Unknown").setMessage(event.getMessage()).setDiscord(true).setMinecraft(false).setConsole(false).setRedis(false);
    if (player.getServer() != null && player.getServer().getName() != null) {
        message.setServer(player.getServer().getName());
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
    return;
}
Also used : Player(org.bukkit.entity.Player) Message(io.github.lxgaming.discordbot.entries.Message) EventHandler(org.bukkit.event.EventHandler)

Example 3 with Message

use of io.github.lxgaming.discordbot.entries.Message in project DiscordBot by LXGaming.

the class VoiceListener method onGuildVoiceDeafen.

@Override
public void onGuildVoiceDeafen(GuildVoiceDeafenEvent event) {
    if (!DiscordBotCore.getInstance().getConfiguration().isVoiceDeafen()) {
        return;
    }
    Message message = new Message().setChannel(DiscordBotCore.getInstance().getChannelManager().getChannelId("Bot")).setName(event.getMember().getEffectiveName()).setNick(event.getMember().getNickname()).setServer(DiscordBotCore.getInstance().getChannelManager().getGuild().getName()).setDiscord(true).setMinecraft(true).setConsole(false).setRedis(false);
    if (event.isDeafened()) {
        message.setFormat(DiscordBotCore.getInstance().getConfiguration().getVoiceDeafenFormat().get("Deafened")).setMessage("Deafened");
    } else {
        message.setFormat(DiscordBotCore.getInstance().getConfiguration().getVoiceDeafenFormat().get("Undeafened")).setMessage("Undeafened");
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
    return;
}
Also used : Message(io.github.lxgaming.discordbot.entries.Message)

Example 4 with Message

use of io.github.lxgaming.discordbot.entries.Message in project DiscordBot by LXGaming.

the class BotListener method onReady.

@Override
public void onReady(ReadyEvent event) {
    DiscordBotCore.getInstance().getChannelManager().setupChannels();
    DiscordBotCore.getInstance().getJDA().addEventListener(new MessageListener());
    DiscordBotCore.getInstance().getJDA().addEventListener(new UserListener());
    DiscordBotCore.getInstance().getJDA().addEventListener(new VoiceListener());
    if (!DiscordBotCore.getInstance().getConfiguration().isConnectionMessage()) {
        return;
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(new Message().setChannel(DiscordBotCore.getInstance().getChannelManager().getChannelId("Bot")).setFormat(DiscordBotCore.getInstance().getConfiguration().getReadyFormat()).setName("").setNick("").setServer(DiscordBotCore.getInstance().getChannelManager().getGuild().getName()).setMessage("DiscordBot Connected").setDiscord(true).setMinecraft(true).setConsole(true).setRedis(false));
    return;
}
Also used : Message(io.github.lxgaming.discordbot.entries.Message)

Example 5 with Message

use of io.github.lxgaming.discordbot.entries.Message in project DiscordBot by LXGaming.

the class UserListener method onUserOnlineStatusUpdate.

@Override
public void onUserOnlineStatusUpdate(UserOnlineStatusUpdateEvent event) {
    if (!DiscordBotCore.getInstance().getConfiguration().isUserOnlineStatusUpdate()) {
        return;
    }
    String status = DiscordBotCore.getInstance().getChannelManager().getGuild().getMember(event.getUser()).getOnlineStatus().name();
    DiscordBotCore.getInstance().getMessageSender().sendMessage(new Message().setChannel(DiscordBotCore.getInstance().getChannelManager().getChannelId("Bot")).setFormat(DiscordBotCore.getInstance().getConfiguration().getUserOnlineStatusUpdateFormat().get(status)).setName(event.getUser().getName()).setNick(DiscordBotCore.getInstance().getChannelManager().getGuild().getMember(event.getUser()).getNickname()).setServer(DiscordBotCore.getInstance().getChannelManager().getGuild().getName()).setMessage(status).setDiscord(true).setMinecraft(true).setConsole(false).setRedis(false));
    return;
}
Also used : Message(io.github.lxgaming.discordbot.entries.Message)

Aggregations

Message (io.github.lxgaming.discordbot.entries.Message)14 EventHandler (org.bukkit.event.EventHandler)4 EventHandler (net.md_5.bungee.event.EventHandler)3 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)2 Player (org.bukkit.entity.Player)2 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 JsonParser (com.google.gson.JsonParser)1 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)1