From fc163baf516a4e62a943ba3e6b65b6f66b3b015e Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 2 Oct 2020 18:12:34 -0500 Subject: [PATCH] DiscordSRV now ignores shadow mute players + Added DiscordSRV as a softdepend + Added a listener to cancel DiscordSRV events for players who are shadow muted --- pom.xml | 17 ++++++++++---- src/main/java/xyz/etztech/qol/QoL.java | 4 ++++ .../qol/commands/ShadowMuteCommand.java | 2 +- .../qol/listeners/DiscordSRVListener.java | 23 +++++++++++++++++++ src/main/resources/plugin.yml | 2 +- 5 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/main/java/xyz/etztech/qol/listeners/DiscordSRVListener.java diff --git a/pom.xml b/pom.xml index 8d0d2af..6f2a341 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xyz.etztech QoL - 1.9 + 1.10 jar @@ -31,7 +31,7 @@ org.spigotmc spigot-api - 1.16.1-R0.1-SNAPSHOT + 1.16.3-R0.1-SNAPSHOT provided @@ -54,7 +54,12 @@ commons-lang 2.6 - + + com.discordsrv + discordsrv + 1.19.1 + provided + @@ -62,6 +67,10 @@ spigotmc-repo https://hub.spigotmc.org/nexus/content/groups/public/ + + Scarsz-Nexus + https://nexus.scarsz.me/content/groups/public/ + etztech-repo http://repo.etztech.xyz @@ -80,7 +89,7 @@ jcenter - http://jcenter.bintray.com + https://jcenter.bintray.com jitpack.io diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index d2ec1ac..8d26c61 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -84,6 +84,10 @@ public class QoL extends JavaPlugin { } } + if (Bukkit.getPluginManager().isPluginEnabled("DiscordSRV")) { + new DiscordSRVListener(this); + } + if( isEnabled() ) { // Add listeners diff --git a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java index 0be8bda..643bb49 100644 --- a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java @@ -54,7 +54,7 @@ public class ShadowMuteCommand implements CommandExecutor { } EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Shadow Muting " + ChatColor.YELLOW + - player.getName() + ChatColor.GREEN + " for " + ChatColor.YELLOW + duration.toString()); + player.getName() + ChatColor.GREEN + " for " + ChatColor.YELLOW + duration.getDuration().toMinutes() + "minutes."); QoL.addSM(player); Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { diff --git a/src/main/java/xyz/etztech/qol/listeners/DiscordSRVListener.java b/src/main/java/xyz/etztech/qol/listeners/DiscordSRVListener.java new file mode 100644 index 0000000..b737bc5 --- /dev/null +++ b/src/main/java/xyz/etztech/qol/listeners/DiscordSRVListener.java @@ -0,0 +1,23 @@ +package xyz.etztech.qol.listeners; + +import github.scarsz.discordsrv.DiscordSRV; +import github.scarsz.discordsrv.api.events.GameChatMessagePreProcessEvent; +import xyz.etztech.qol.QoL; +import github.scarsz.discordsrv.api.Subscribe; + +public class DiscordSRVListener { + private final QoL plugin; + + public DiscordSRVListener(QoL plugin) { + this.plugin = plugin; + DiscordSRV.api.subscribe(this); + } + + @Subscribe + public void gameChatMessagePreProcess(GameChatMessagePreProcessEvent event) { + if (QoL.hasSM(event.getPlayer())) { + event.setCancelled(true); + } + } + +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 98041e7..098c952 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ description: ${description} author: ${author} website: ${url} main: ${mainClass} -softdepend: [Essentials, dynmap] +softdepend: [Essentials, dynmap, DiscordSRV] commands: qol: description: Base command