diff --git a/pom.xml b/pom.xml
index fa47508..114e64d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -190,7 +190,7 @@
2.0.1
jar
-
+
com.nyancraft.reportrts
diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerChatListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerChatListener.java
index 9793e7d..f3a9418 100644
--- a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerChatListener.java
+++ b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerChatListener.java
@@ -48,6 +48,12 @@ public class GamePlayerChatListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
+ if (plugin.essentialsChatHook != null) {
+ if (plugin.essentialsChatHook.isMuted(event.getPlayer())) {
+ plugin.logDebug("Ignore chat message due to Essentials mute: " + event.getMessage());
+ return;
+ }
+ }
String message = event.getMessage();
plugin.logDebug("ChatFormat [" + event.isCancelled() + "]: " + event.getFormat());
if (message.startsWith(PurpleIRC.TOWNYTAG)) {
diff --git a/src/main/java/com/cnaude/purpleirc/Hooks/EssentialsHook.java b/src/main/java/com/cnaude/purpleirc/Hooks/EssentialsHook.java
new file mode 100644
index 0000000..22e5c3e
--- /dev/null
+++ b/src/main/java/com/cnaude/purpleirc/Hooks/EssentialsHook.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2017 cnaude
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.cnaude.purpleirc.Hooks;
+
+import com.cnaude.purpleirc.PurpleIRC;
+import com.earth2me.essentials.Essentials;
+import com.earth2me.essentials.User;
+import org.bukkit.entity.Player;
+
+/**
+ *
+ * @author cnaude
+ */
+public class EssentialsHook {
+
+ private final PurpleIRC plugin;
+ private final Essentials essentials;
+
+ /**
+ *
+ * @param plugin the PurpleIRC plugin
+ */
+ public EssentialsHook(PurpleIRC plugin) {
+ this.plugin = plugin;
+ this.essentials = (Essentials) plugin.getServer().getPluginManager().getPlugin(plugin.PL_ESSENTIALS);
+ }
+
+ public boolean isMuted(Player player) {
+ if (essentials != null) {
+ User user = essentials.getUser(player);
+ if (user != null) {
+ return user.isMuted();
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java
index e84ab65..36ab86f 100644
--- a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java
+++ b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java
@@ -50,6 +50,7 @@ import com.cnaude.purpleirc.Hooks.AdminPrivateChatHook;
import com.cnaude.purpleirc.Hooks.CommandBookHook;
import com.cnaude.purpleirc.Hooks.DiscordSRVHook;
import com.cnaude.purpleirc.Hooks.DynmapHook;
+import com.cnaude.purpleirc.Hooks.EssentialsHook;
import com.cnaude.purpleirc.Hooks.FactionChatHook;
import com.cnaude.purpleirc.Hooks.GriefPreventionHook;
import com.cnaude.purpleirc.Hooks.JobsHook;
@@ -206,6 +207,7 @@ public class PurpleIRC extends JavaPlugin {
public CommandBookHook commandBookHook;
public McMMOChatHook mcMMOChatHook;
public PlaceholderApiHook placeholderApiHook;
+ public EssentialsHook essentialsChatHook;
public NetPackets netPackets;
public CommandHandlers commandHandlers;
public PurpleTabCompleter ircTabCompleter;
@@ -225,7 +227,7 @@ public class PurpleIRC extends JavaPlugin {
private final File uuidCacheFile;
public int reconnectSuppression;
- final String PL_ESSENTIALS = "Essentials";
+ public final String PL_ESSENTIALS = "Essentials";
final String PL_REPORTRTS = "ReportRTS";
final String PL_SIMPLETICKET = "SimpleTicketManager";
final String PL_NTHE_END_AGAIN = "NTheEndAgain";
@@ -1007,7 +1009,7 @@ public class PurpleIRC extends JavaPlugin {
m = "Players on " + host + "("
+ players.length
+ "): " + Joiner.on(", ")
- .join(players);
+ .join(players);
}
return m;
} else {
@@ -1755,6 +1757,7 @@ public class PurpleIRC extends JavaPlugin {
if (isPluginEnabled(PL_ESSENTIALS)) {
hookList.add(hookFormat(PL_ESSENTIALS, true));
getServer().getPluginManager().registerEvents(new EssentialsListener(this), this);
+ essentialsChatHook = new EssentialsHook(this);
} else {
hookList.add(hookFormat(PL_ESSENTIALS, false));
}
@@ -1770,7 +1773,7 @@ public class PurpleIRC extends JavaPlugin {
} else {
hookList.add(hookFormat(PL_DISCORDSRV, false));
}
-
+
if (isPluginEnabled(PL_UCHAT)) {
getServer().getPluginManager().registerEvents(new UltimateChatListener(this), this);
} else {