From fe464ba75056f0631b345e0f65cf10e38cb2b9ad Mon Sep 17 00:00:00 2001 From: _ProSavage_ Date: Sun, 4 Mar 2018 20:57:27 -0600 Subject: [PATCH] Added /f chat mod --- .../java/com/massivecraft/factions/Conf.java | 1 + .../massivecraft/factions/cmd/CmdChat.java | 8 +++++-- .../listeners/FactionsChatListener.java | 22 ++++++++++++++++--- .../factions/struct/ChatMode.java | 1 + .../massivecraft/factions/zcore/util/TL.java | 2 ++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index c3a30093..2272d7a7 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -74,6 +74,7 @@ public class Conf { public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s"; public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s"; public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s"; + public static String modChatFormat = ChatColor.RED + "%s:" + ChatColor.WHITE + " %s"; public static boolean broadcastDescriptionChanges = false; public static boolean broadcastTagChanges = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java index 9b47a740..9e4a27f9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java @@ -36,7 +36,9 @@ public class CmdChat extends FCommand { if (modeString != null) { modeString = modeString.toLowerCase(); - if (modeString.startsWith("p")) { + if (modeString.startsWith("m")) { + modeTarget = ChatMode.MOD; + } else if (modeString.startsWith("p")) { modeTarget = ChatMode.PUBLIC; } else if (modeString.startsWith("a")) { modeTarget = ChatMode.ALLIANCE; @@ -52,7 +54,9 @@ public class CmdChat extends FCommand { fme.setChatMode(modeTarget); - if (fme.getChatMode() == ChatMode.PUBLIC) { + if (fme.getChatMode() == ChatMode.MOD) { + msg(TL.COMMAND_CHAT_MODE_MOD); + } else if (fme.getChatMode() == ChatMode.PUBLIC) { msg(TL.COMMAND_CHAT_MODE_PUBLIC); } else if (fme.getChatMode() == ChatMode.ALLIANCE) { msg(TL.COMMAND_CHAT_MODE_ALLIANCE); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index ca718a7c..0ca29fc7 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.listeners; import com.massivecraft.factions.*; import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Role; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -14,7 +15,6 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import java.util.UnknownFormatConversionException; import java.util.logging.Level; - public class FactionsChatListener implements Listener { public P p; @@ -30,9 +30,25 @@ public class FactionsChatListener implements Listener { String msg = event.getMessage(); FPlayer me = FPlayers.getInstance().getByPlayer(talkingPlayer); ChatMode chat = me.getChatMode(); + //Is it a MOD chat + if (chat == ChatMode.MOD) { + Faction myFaction = me.getFaction(); - // Is it a faction chat message? - if (chat == ChatMode.FACTION) { + 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); + } + } + + Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("Mod Chat: " + message)); + + event.setCancelled(true); + } else if (chat == ChatMode.FACTION) { Faction myFaction = me.getFaction(); String message = String.format(Conf.factionChatFormat, me.describeTo(myFaction), msg); diff --git a/src/main/java/com/massivecraft/factions/struct/ChatMode.java b/src/main/java/com/massivecraft/factions/struct/ChatMode.java index b83f3a20..27804288 100644 --- a/src/main/java/com/massivecraft/factions/struct/ChatMode.java +++ b/src/main/java/com/massivecraft/factions/struct/ChatMode.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.struct; import com.massivecraft.factions.zcore.util.TL; public enum ChatMode { + MOD(4,TL.CHAT_MOD), FACTION(3, TL.CHAT_FACTION), ALLIANCE(2, TL.CHAT_ALLIANCE), TRUCE(1, TL.CHAT_TRUCE), diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index b14aac24..f3e91a97 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -106,6 +106,7 @@ public enum TL { COMMAND_CHAT_MODE_ALLIANCE("Alliance only chat mode."), COMMAND_CHAT_MODE_TRUCE("Truce only chat mode."), COMMAND_CHAT_MODE_FACTION("Faction only chat mode."), + COMMAND_CHAT_MODE_MOD("Mod only chat mode."), COMMAND_CHATSPY_ENABLE("You have enabled chat spying mode."), COMMAND_CHATSPY_ENABLELOG(" has ENABLED chat spying mode."), @@ -674,6 +675,7 @@ public enum TL { /** * Chat modes */ + CHAT_MOD("mod chat"), CHAT_FACTION("faction chat"), CHAT_ALLIANCE("alliance chat"), CHAT_TRUCE("truce chat"),