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 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 DiscordChatCommand method onCommand.
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!sender.hasPermission(this.permission)) {
sender.sendMessage(ChatColor.RED + "You do not have permission!");
return true;
}
StringBuilder stringBuilder = new StringBuilder();
for (String arg : args) {
stringBuilder.append(arg + " ");
}
if (stringBuilder.toString().trim().length() == 0) {
sender.sendMessage(ChatColor.RED + "Message cannot be blank!");
return true;
}
Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get(this.name).getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get(this.name)).setName(sender.getName()).setNick("").setServer("Unknown").setMessage(stringBuilder.toString().trim()).setDiscord(true).setMinecraft(true).setConsole(true).setRedis(true);
if (sender instanceof Player) {
Player player = (Player) sender;
if (DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(player.getUniqueId())) {
player.sendMessage(ChatColor.RED + "DiscordChat disabled. '/DiscordBot Toggle' to enable");
return true;
}
message.setName(player.getName()).setNick(player.getDisplayName());
if (player.getServer() != null && player.getServer().getName() != null) {
message.setServer(player.getServer().getName());
}
}
DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
return true;
}
use of io.github.lxgaming.discordbot.entries.Message in project DiscordBot by LXGaming.
the class PlayerListener method onPlayerJoin.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
if (!DiscordBotCore.getInstance().getConfiguration().isPlayerJoin() || event.getPlayer().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.getPlayer().getName()).setNick(event.getPlayer().getDisplayName()).setServer("Unknown").setMessage("Joined").setDiscord(true).setMinecraft(false).setConsole(false).setRedis(false);
if (event.getPlayer().getServer() != null && event.getPlayer().getServer().getName() != null) {
message.setServer(event.getPlayer().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 onPlayerQuit.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
if (!DiscordBotCore.getInstance().getConfiguration().isPlayerQuit() || event.getPlayer().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.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().getName() != null) {
message.setServer(event.getPlayer().getServer().getName());
}
DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
return;
}
Aggregations