From 580f87f28b0972895d63a5454b6ae5c4e0c039e2 Mon Sep 17 00:00:00 2001 From: Focusvity Date: Sun, 20 Mar 2022 13:13:34 +1100 Subject: [PATCH] Move mute into its own class --- .../dev/plex/listener/impl/ChatListener.java | 6 ------ .../dev/plex/listener/impl/MuteListener.java | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 src/main/java/dev/plex/listener/impl/MuteListener.java diff --git a/src/main/java/dev/plex/listener/impl/ChatListener.java b/src/main/java/dev/plex/listener/impl/ChatListener.java index 28a633f..fa8dd88 100644 --- a/src/main/java/dev/plex/listener/impl/ChatListener.java +++ b/src/main/java/dev/plex/listener/impl/ChatListener.java @@ -24,12 +24,6 @@ public class ChatListener extends PlexListener public void onChat(AsyncChatEvent event) { PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(event.getPlayer().getUniqueId()); - if (PlayerCache.getPunishedPlayer(event.getPlayer().getUniqueId()).isMuted()) - { - event.getPlayer().sendMessage(PlexUtils.messageComponent("muted")); - event.setCancelled(true); - return; - } Component prefix = plugin.getRankManager().getPrefix(plexPlayer); if (prefix != null) diff --git a/src/main/java/dev/plex/listener/impl/MuteListener.java b/src/main/java/dev/plex/listener/impl/MuteListener.java new file mode 100644 index 0000000..f4548af --- /dev/null +++ b/src/main/java/dev/plex/listener/impl/MuteListener.java @@ -0,0 +1,21 @@ +package dev.plex.listener.impl; + +import dev.plex.cache.PlayerCache; +import dev.plex.listener.PlexListener; +import dev.plex.util.PlexUtils; +import io.papermc.paper.event.player.AsyncChatEvent; +import org.bukkit.event.EventHandler; + +public class MuteListener extends PlexListener +{ + + @EventHandler + public void onChat(AsyncChatEvent event) + { + if (PlayerCache.getPunishedPlayer(event.getPlayer().getUniqueId()).isMuted()) + { + event.getPlayer().sendMessage(PlexUtils.messageComponent("muted")); + event.setCancelled(true); + } + } +}