diff --git a/bukkit/build.gradle b/bukkit/build.gradle index e898d7dd..ba607c4f 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -70,6 +70,7 @@ dependencies { // Chat Integrations compileOnly(libs.chatty) + compileOnly(libs.griefprevention) compileOnly(libs.lunachat) compileOnly(libs.mcmmo) compileOnly(libs.townychat) diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java index 8c52a7ce..34eb7f16 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java @@ -248,6 +248,7 @@ public class BukkitDiscordSRV extends ServerDiscordSRV { + + public GriefPreventionChatIntegration(BukkitDiscordSRV discordSRV) { + super(discordSRV, new NamedLogger(discordSRV, "GRIEFPREVENTION")); + } + + @Override + public @NotNull String getIntegrationName() { + return "GriefPrevention"; + } + + @Override + public boolean isEnabled() { + try { + Class.forName("me.ryanhamshire.GriefPrevention.GriefPrevention"); + } catch (ClassNotFoundException ignored) { + return false; + } + + return super.isEnabled(); + } + + @Subscribe(priority = EventPriority.EARLY) + public void onGameChatMessageReceive(GameChatMessageReceiveEvent event) { + GriefPrevention griefPrevention = (GriefPrevention) discordSRV.server().getPluginManager().getPlugin(getIntegrationName()); + if (griefPrevention == null) { + return; + } + + DiscordSRVPlayer player = event.getPlayer(); + if (griefPrevention.dataStore.isSoftMuted(player.uniqueId())) { + logger().debug(player.username() + " is softmuted"); + event.setCancelled(true); + } + } +} diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java index b136ec16..96003bbe 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/integration/chat/McMMOChatIntegration.java @@ -64,7 +64,11 @@ public class McMMOChatIntegration extends PluginIntegration im return; } - if (ChatAPI.isUsingPartyChat(player) || ChatAPI.isUsingAdminChat(player)) { + if (ChatAPI.isUsingPartyChat(player)) { + logger().debug(player.getName() + " is using party chat"); + event.setCancelled(true); + } else if (ChatAPI.isUsingAdminChat(player)) { + logger().debug(player.getName() + " is using admin chat"); event.setCancelled(true); } } diff --git a/settings.gradle b/settings.gradle index 01f4560c..9617076e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -110,6 +110,7 @@ dependencyResolutionManagement { library('chatty', 'ru.mrbrikster', 'chatty-api').version('2.19.13') library('lunachat', 'com.github.ucchyocean.lc', 'LunaChat').version('3.0.16') library('mcmmo', 'com.gmail.nossr50', 'mcmmo').version('2.1.220') + library('griefprevention', 'me.ryanhamshire', 'GriefPrevention').version('16.18.1') // Logging library('slf4j-api', 'org.slf4j', 'slf4j-api').version('1.7.36')