mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 20:53:40 -04:00
PM counts towards total messages written
This commit is contained in:
parent
88b3cf1e31
commit
35a46ea6bc
@ -36,6 +36,8 @@ namespace MCGalaxy {
|
||||
Rank,
|
||||
/// <summary> Messages all players who can use an ItemPerms argument. </summary>
|
||||
Perms,
|
||||
/// <summary> Message to a specific player </summary>
|
||||
PM,
|
||||
}
|
||||
|
||||
public delegate bool ChatMessageFilter(Player pl, object arg);
|
||||
@ -96,10 +98,11 @@ namespace MCGalaxy {
|
||||
|
||||
public static bool FilterRank(Player pl, object arg) { return pl.Rank == (LevelPermission)arg; }
|
||||
public static bool FilterPerms(Player pl, object arg) { return ((ItemPerms)arg).UsableBy(pl.Rank); }
|
||||
public static bool FilterPM(Player pl, object arg) { return pl == arg; }
|
||||
|
||||
public static ChatMessageFilter[] scopeFilters = new ChatMessageFilter[] {
|
||||
FilterAll, FilterGlobal, FilterLevel, FilterChatroom,
|
||||
FilterAllChatrooms, FilterRank, FilterPerms,
|
||||
FilterAllChatrooms, FilterRank, FilterPerms, FilterPM,
|
||||
};
|
||||
|
||||
public static ChatMessageFilter FilterVisible(Player source) {
|
||||
@ -184,7 +187,7 @@ namespace MCGalaxy {
|
||||
public static void MessageChat(ChatScope scope, Player source, string msg, object arg,
|
||||
ChatMessageFilter filter, bool irc = false) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
ChatMessageFilter scopeFilter = scopeFilters[(int)scope];
|
||||
ChatMessageFilter scopeFilter = scopeFilters[(int)scope];
|
||||
if (source == null) source = ConsolePlayer.Instance;
|
||||
|
||||
OnChatEvent.Call(scope, source, msg, arg, ref filter, irc);
|
||||
@ -194,6 +197,9 @@ namespace MCGalaxy {
|
||||
if (pl != source) {
|
||||
if (!scopeFilter(pl, arg)) continue;
|
||||
if (filter != null && !filter(pl, arg)) continue;
|
||||
} else {
|
||||
// don't send PM back to self
|
||||
if (scope == ChatScope.PM) { continue; }
|
||||
}
|
||||
|
||||
Player.Message(pl, UnescapeMessage(pl, source, msg));
|
||||
|
@ -22,25 +22,30 @@ namespace MCGalaxy {
|
||||
public static bool Handle(Player p, string text) {
|
||||
if (text.Length >= 2 && text[0] == '@' && text[1] == '@') {
|
||||
text = text.Remove(0, 2);
|
||||
DoConsolePM(p, text);
|
||||
DoPM(p, ConsolePlayer.Instance, text);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (text[0] == '@' || p.whisper) {
|
||||
if (text[0] == '@') text = text.Remove(0, 1).Trim();
|
||||
|
||||
if (p.whisperTo.Length == 0) {
|
||||
string target = p.whisperTo;
|
||||
if (target.Length == 0) {
|
||||
int sepIndex = text.IndexOf(' ');
|
||||
if (sepIndex != -1) {
|
||||
string target = text.Substring(0, sepIndex);
|
||||
target = text.Substring(0, sepIndex);
|
||||
text = text.Substring(sepIndex + 1);
|
||||
HandleWhisper(p, target, text);
|
||||
} else {
|
||||
Player.Message(p, "No message entered");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
HandleWhisper(p, p.whisperTo, text);
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindMatches(p, target);
|
||||
if (who == null) return true;
|
||||
if (who == p) { Player.Message(p, "Trying to talk to yourself, huh?"); return true; }
|
||||
|
||||
DoPM(p, who, text);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -86,27 +91,14 @@ namespace MCGalaxy {
|
||||
Chat.MessageChat(ChatScope.Perms, p, chatMsg, perms, null, true);
|
||||
}
|
||||
|
||||
static void HandleWhisper(Player p, string target, string message) {
|
||||
Player who = PlayerInfo.FindMatches(p, target);
|
||||
if (who == null) return;
|
||||
if (who == p) { Player.Message(p, "Trying to talk to yourself, huh?"); return; }
|
||||
|
||||
static void DoPM(Player p, Player who, string message) {
|
||||
if (message.Length == 0) { Player.Message(p, "No message entered"); return; }
|
||||
Logger.Log(LogType.PrivateChat, "{0} @{1}: {2}", p.name, who.name, message);
|
||||
Player.Message(p, "[<] {0}: &f{1}", who.ColoredName, message);
|
||||
|
||||
if (!Chat.Ignoring(who, p)) {
|
||||
Player.Message(who, "&9[>] {0}: &f{1}", p.ColoredName, message);
|
||||
if (p != ConsolePlayer.Instance) {
|
||||
Player.Message(p, "[<] {0}: &f{1}", who.ColoredName, message);
|
||||
}
|
||||
|
||||
p.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
static void DoConsolePM(Player p, string message) {
|
||||
if (message.Length < 1) { Player.Message(p, "No message entered"); return; }
|
||||
Player.Message(p, "[<] Console: &f" + message);
|
||||
Logger.Log(LogType.PrivateChat, "{0} @(console): {1}", p.name, message);
|
||||
|
||||
p.CheckForMessageSpam();
|
||||
Chat.MessageChat(ChatScope.PM, p, "&9[>] λNICK: &f" + message, who, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Core {
|
||||
logType = LogType.RankChat;
|
||||
}
|
||||
|
||||
Logger.Log(logType, msg);
|
||||
if (scope != ChatScope.PM) Logger.Log(logType, msg);
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
ChatMessageFilter scopeFilter = Chat.scopeFilters[(int)scope];
|
||||
|
||||
|
@ -66,11 +66,9 @@ namespace MCGalaxy.Games {
|
||||
|
||||
CtfTeam team = TeamOf(p);
|
||||
if (team == null) return;
|
||||
Player[] members = team.Members.Items;
|
||||
|
||||
foreach (Player pl in members) {
|
||||
Player.Message(pl, "({0}) {1}: &f{2}", team.Name, p.ColoredName, message);
|
||||
}
|
||||
|
||||
Chat.MessageChat(ChatScope.Level, p, "(" + team.Name + ") λNICK: &f" + message,
|
||||
Map, (pl, arg) => TeamOf(pl) == team);
|
||||
p.cancelchat = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user