mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 13:36:04 +01:00
Ignore players muted via EssentialsX.
This commit is contained in:
parent
449cc3f049
commit
01e0a93e81
2
pom.xml
2
pom.xml
@ -190,7 +190,7 @@
|
||||
<version>2.0.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- ReportRTS -->
|
||||
<dependency>
|
||||
<groupId>com.nyancraft.reportrts</groupId>
|
||||
|
@ -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)) {
|
||||
|
52
src/main/java/com/cnaude/purpleirc/Hooks/EssentialsHook.java
Normal file
52
src/main/java/com/cnaude/purpleirc/Hooks/EssentialsHook.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user