From 46a8a7d04ce610bdfb52a6fa48c27715132bade1 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Tue, 6 Jul 2021 21:31:35 -0400 Subject: [PATCH] Remove join/quit message null checks If you don't want to see them, don't configure them. --- .../discord/listeners/BukkitListener.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java index 8ca50902f..bcde3c6a7 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/listeners/BukkitListener.java @@ -109,18 +109,26 @@ public class BukkitListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onJoin(AsyncUserDataLoadEvent event) { // Delay join to let nickname load - if (event.getJoinMessage() != null && !isVanishHide(event.getUser())) { + if (!isSilentJoinQuit(event.getUser(), "join") && !isVanishHide(event.getUser())) { sendJoinQuitMessage(event.getUser().getBase(), event.getJoinMessage(), true); } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onQuit(PlayerQuitEvent event) { - if (event.getQuitMessage() != null && !isVanishHide(event.getPlayer())) { + if (!isSilentJoinQuit(event.getPlayer(), "quit") && !isVanishHide(event.getPlayer())) { sendJoinQuitMessage(event.getPlayer(), event.getQuitMessage(), false); } } + public boolean isSilentJoinQuit(final Player player, final String type) { + return isSilentJoinQuit(jda.getPlugin().getEss().getUser(player), type); + } + + public boolean isSilentJoinQuit(final IUser user, final String type) { + return jda.getPlugin().getEss().getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silent" + type); + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onVanishStatusChange(VanishStatusChangeEvent event) { if (!jda.getSettings().isVanishFakeJoinLeave()) {