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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations