From cfb64ea316c0f1b4cb01b5ec6105e27b139d54fc Mon Sep 17 00:00:00 2001 From: ProSavage Date: Tue, 17 Jul 2018 09:36:46 -0500 Subject: [PATCH] Mod chat issue fix. --- .../factions/listeners/FactionsChatListener.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 14805b93..2054164b 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -54,11 +54,14 @@ public class FactionsChatListener implements Listener { String message = String.format(Conf.modChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); //Send to all mods - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - if (myFaction == fplayer.getFaction() && fplayer.getRole().isAtLeast(Role.MODERATOR)) { - fplayer.sendMessage(message); - } else if (fplayer.isSpyingChat() && me != fplayer) { - fplayer.sendMessage("[MCspy]: " + message); + if (me.getRole().isAtLeast(Role.MODERATOR)) { + // Iterates only through the factions' members so we enhance performance. + for (FPlayer fplayer : myFaction.getFPlayers()) { + if (fplayer.getRole().isAtLeast(Role.MODERATOR)) { + fplayer.sendMessage(message); + } else if (fplayer.isSpyingChat() && me != fplayer) { + fplayer.sendMessage("[MCspy]: " + message); + } } }