diff --git a/MCGalaxy/Chat/Chat.cs b/MCGalaxy/Chat/Chat.cs
index daabad8f2..fbce148cf 100644
--- a/MCGalaxy/Chat/Chat.cs
+++ b/MCGalaxy/Chat/Chat.cs
@@ -106,10 +106,8 @@ namespace MCGalaxy {
public static void MessageAll(string msg) { Message(ChatScope.All, msg, null, null); }
public static void MessageGlobal(string msg) { Message(ChatScope.Global, msg, null, null); }
- public static void MessageOps(string msg) { MessageAboveOrSameRank(OpchatPerm, msg); }
-
- public static void MessageAboveOrSameRank(LevelPermission rank, string msg) {
- Message(ChatScope.AboveEqRank, msg, rank, null);
+ public static void MessageOps(string msg) {
+ Message(ChatScope.AboveEqRank, msg, OpchatPerm, null);
}
public static void MessageGlobal(string message, object a0) {
diff --git a/MCGalaxy/Commands/Chat/CmdHug.cs b/MCGalaxy/Commands/Chat/CmdHug.cs
index 80fee8665..a78b34565 100644
--- a/MCGalaxy/Commands/Chat/CmdHug.cs
+++ b/MCGalaxy/Commands/Chat/CmdHug.cs
@@ -33,9 +33,9 @@ namespace MCGalaxy.Commands.Chatting {
if (args[1] == "loving" || args[1] == "creepy" || args[1] == "friendly" || args[1] == "deadly")
hugType = args[1];
}
- if (hugType == null) { TryMessageAction(p, args[0], "{0} %Shugged {1}", false); return; }
+ if (hugType == null) { TryMessageAction(p, args[0], "λNICK %Shugged λTARGET", false); return; }
- TryMessageAction(p, args[0], "{0} %Sgave {1} %Sa " + hugType + " hug", false);
+ TryMessageAction(p, args[0], "λNICK %Sgave λTARGET %Sa " + hugType + " hug", false);
if (hugType == "deadly") {
if (!CheckExtraPerm(p, 1)) return;
Player target = PlayerInfo.FindMatches(p, args[0]);
diff --git a/MCGalaxy/Commands/Chat/MessageCmd.cs b/MCGalaxy/Commands/Chat/MessageCmd.cs
index 58a22eb86..58ef63bc3 100644
--- a/MCGalaxy/Commands/Chat/MessageCmd.cs
+++ b/MCGalaxy/Commands/Chat/MessageCmd.cs
@@ -19,26 +19,25 @@ namespace MCGalaxy.Commands.Chatting {
public abstract class MessageCmd : Command {
public override string type { get { return CommandTypes.Chat; } }
- protected bool TryMessageAction(Player p, string name, string message, bool messageWho) {
+ protected bool TryMessageAction(Player p, string name, string msg, bool messageWho) {
if (name.Length == 0) { Help(p); return false; }
Player target = PlayerInfo.FindMatches(p, name);
if (target == null) return false;
- string giver = (p == null) ? "(console)" : p.ColoredName;
string reciever = p == target ? "themselves" : target.ColoredName;
- if (!TryMessage(p, string.Format(message, giver, reciever))) return false;
+ if (!TryMessage(p, msg.Replace("λTARGET", reciever))) return false;
if (messageWho && p != target && Chat.NotIgnoring(target, p)) {
- Player.Message(target, string.Format(message, giver, "you"));
+ string giver = (p == null) ? "(console)" : p.ColoredName;
+ msg = msg.Replace("λNICK", giver);
+ Player.Message(target, msg.Replace("λTARGET", "you"));
}
return true;
}
- protected bool TryMessage(Player p, string message) { return TryMessage(p, message, name); }
-
- protected static bool TryMessage(Player p, string message, string cmd) {
- if (!CanSpeak(p, cmd)) return false;
- Chat.MessageFrom(p, message, null);
+ protected bool TryMessage(Player p, string msg) {
+ if (!CanSpeak(p, name)) return false;
+ Chat.MessageFrom(p, msg, null);
p.CheckForMessageSpam();
return true;
@@ -61,7 +60,7 @@ namespace MCGalaxy.Commands.Chatting {
public override string name { get { return "High5"; } }
public override void Use(Player p, string message) {
- TryMessageAction(p, message, "{0} %Sjust highfived {1}", true);
+ TryMessageAction(p, message, "λNICK %Sjust highfived λTARGET", true);
}
public override void Help(Player p) {
diff --git a/MCGalaxy/Commands/Moderation/CmdBlockSet.cs b/MCGalaxy/Commands/Moderation/CmdBlockSet.cs
index 0fadab716..1450c5d3e 100644
--- a/MCGalaxy/Commands/Moderation/CmdBlockSet.cs
+++ b/MCGalaxy/Commands/Moderation/CmdBlockSet.cs
@@ -44,7 +44,7 @@ namespace MCGalaxy.Commands.Moderation {
perms.Allowed.Add(grp.Permission);
}
- UpdatePermissions(block, p, " can now be used by " + grp.ColoredName);
+ UpdatePermissions(block, p, " %Scan now be used by " + grp.ColoredName);
} else if (args.Length == 2 && args[1][0] == '-') {
Group grp = GetGroup(p, args[1].Substring(1));
if (grp == null) return;
@@ -60,14 +60,14 @@ namespace MCGalaxy.Commands.Moderation {
perms.Disallowed.Add(grp.Permission);
}
- UpdatePermissions(block, p, " is no longer usable by " + grp.ColoredName);
+ UpdatePermissions(block, p, " %Sis no longer usable by " + grp.ColoredName);
} else if (args.Length == 2) {
Group grp = GetGroup(p, args[1]);
if (grp == null) return;
BlockPerms perms = BlockPerms.List[block];
perms.MinRank = grp.Permission;
- UpdatePermissions(block, p, "'s permission was set to " + grp.ColoredName);
+ UpdatePermissions(block, p, "%S's permission was set to " + grp.ColoredName);
}
}
@@ -89,7 +89,7 @@ namespace MCGalaxy.Commands.Moderation {
}
string name = Block.GetName(p, block);
- Chat.MessageGlobal("&d{0}%S{1}", name, message);
+ Chat.MessageAll("&d" + name + message);
if (Player.IsSuper(p)) Player.Message(p, name + message);
}
diff --git a/MCGalaxy/Commands/Moderation/CmdCmdSet.cs b/MCGalaxy/Commands/Moderation/CmdCmdSet.cs
index f80d3c6e9..0feb12979 100644
--- a/MCGalaxy/Commands/Moderation/CmdCmdSet.cs
+++ b/MCGalaxy/Commands/Moderation/CmdCmdSet.cs
@@ -16,7 +16,7 @@
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands.Moderation {
- public sealed class CmdCmdSet : Command {
+ public sealed class CmdCmdSet : Command {
public override string name { get { return "CmdSet"; } }
public override string type { get { return CommandTypes.Moderation; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
@@ -45,7 +45,7 @@ namespace MCGalaxy.Commands.Moderation {
perms.Allowed.Add(grp.Permission);
}
- UpdatePermissions(cmd, p, " can now be used by " + grp.ColoredName);
+ UpdatePermissions(cmd, p, " %Scan now be used by " + grp.ColoredName);
} else if (args.Length == 2 && args[1][0] == '-') {
Group grp = GetGroup(p, args[1].Substring(1));
if (grp == null) return;
@@ -61,14 +61,14 @@ namespace MCGalaxy.Commands.Moderation {
perms.Disallowed.Add(grp.Permission);
}
- UpdatePermissions(cmd, p, " is no longer usable by " + grp.ColoredName);
+ UpdatePermissions(cmd, p, " %Sis no longer usable by " + grp.ColoredName);
} else if (args.Length == 2) {
Group grp = GetGroup(p, args[1]);
if (grp == null) return;
CommandPerms perms = CommandPerms.Find(cmd.name);
perms.MinRank = grp.Permission;
- UpdatePermissions(cmd, p, "'s permission was set to " + grp.ColoredName);
+ UpdatePermissions(cmd, p, "%S's permission was set to " + grp.ColoredName);
} else {
int otherPermIndex = 0;
if (!CommandParser.GetInt(p, args[2], "Extra permission number", ref otherPermIndex)) return;
@@ -86,10 +86,8 @@ namespace MCGalaxy.Commands.Moderation {
perms.MinRank = grp.Permission;
CommandExtraPerms.Save();
- string permName = "extra permission " + otherPermIndex;
- Chat.MessageGlobal("&d{0}%S's {1} was set to {2}", cmd.name, permName, grp.ColoredName);
- if (Player.IsSuper(p))
- Player.Message(p, "{0}'s {1} was set to {2}", cmd.name, permName, grp.ColoredName);
+ string msg = "extra permission " + otherPermIndex;
+ Announce(p, cmd.name + "%S's " + msg + " was set to " + grp.ColoredName);
}
}
@@ -103,13 +101,15 @@ namespace MCGalaxy.Commands.Moderation {
return grp;
}
- static void UpdatePermissions(Command cmd, Player p, string message) {
+ static void UpdatePermissions(Command cmd, Player p, string msg) {
CommandPerms.Save();
CommandPerms.Load();
-
- Chat.MessageGlobal("&d{0}%S{1}", cmd.name, message);
- if (Player.IsSuper(p))
- Player.Message(p, cmd.name + message);
+ Announce(p, cmd.name + msg);
+ }
+
+ static void Announce(Player p, string msg) {
+ Chat.MessageAll("&d" + msg);
+ if (Player.IsSuper(p)) Player.Message(p, msg);
}
public override void Help(Player p) {
diff --git a/MCGalaxy/Commands/Moderation/CmdReport.cs b/MCGalaxy/Commands/Moderation/CmdReport.cs
index accb77de2..743b7c2ce 100644
--- a/MCGalaxy/Commands/Moderation/CmdReport.cs
+++ b/MCGalaxy/Commands/Moderation/CmdReport.cs
@@ -56,11 +56,11 @@ namespace MCGalaxy.Commands.Moderation {
}
static string[] GetReportedUsers() {
- string[] users = Directory.GetFiles("extra/reported", "*.txt");
+ string[] users = Directory.GetFiles("extra/reported", "*.txt");
for (int i = 0; i < users.Length; i++) {
users[i] = Path.GetFileNameWithoutExtension(users[i]);
}
- return users;
+ return users;
}
static void DeleteReport(string user) {
@@ -166,8 +166,9 @@ namespace MCGalaxy.Commands.Moderation {
File.WriteAllLines("extra/reported/" + target + ".txt", reports.ToArray());
Player.Message(p, "&aReport sent! It should be viewed when a {0}&a+ is online", checkRankName);
- string opsMsg = p.ColoredName + " %Smade a report, view it with %T/Report check " + target;
- Chat.MessageAboveOrSameRank(checkRank, opsMsg);
+ string opsMsg = "λNICK %Smade a report, view it with %T/Report check " + target;
+ Chat.MessageFrom(ChatScope.AboveEqRank, p, opsMsg,
+ checkRank, null, true);
}
public override void Help(Player p) {
diff --git a/MCGalaxy/Commands/Moderation/CmdReview.cs b/MCGalaxy/Commands/Moderation/CmdReview.cs
index d701dd1d0..f08a5a524 100644
--- a/MCGalaxy/Commands/Moderation/CmdReview.cs
+++ b/MCGalaxy/Commands/Moderation/CmdReview.cs
@@ -1,4 +1,4 @@
-/*
+/*
Written by BeMacized
Assisted by RedNoodle
@@ -72,22 +72,18 @@ namespace MCGalaxy.Commands.Moderation {
}
Server.reviewlist.Add(p.name);
- int pos = Server.reviewlist.IndexOf(p.name);
- if (pos > 1) { Player.Message(p, "You entered the &creview %Squeue. You have &c" + pos + " %Speople in front of you in the queue"); }
- if (pos == 1) { Player.Message(p, "You entered the &creview %Squeue. There is &c1 %Sperson in front of you in the queue"); }
- if (pos == 0) { Player.Message(p, "You entered the &creview %Squeue. You are &cfirst %Sin line!"); }
+ int pos = Server.reviewlist.IndexOf(p.name) + 1;
+ Player.Message(p, "You entered the &creview %Squeue at &aposition #" + pos);
string msg = opsOn ?
- "The Online staff have been notified. Someone should be with you shortly." :
+ "The online staff have been notified. Someone should be with you shortly." :
"There are currently no staff online. Staff will be notified when they join the server.";
Player.Message(p, msg);
- string start = pos > 0 ? "There are now &c" + (pos + 1) + " %Speople" : "There is now &c1 %Sperson";
- Chat.MessageAboveOrSameRank(nextPerm, p.ColoredName + " %Sis requesting a review!");
- Chat.MessageAboveOrSameRank(nextPerm, start + " waiting for a &creview!");
+ Chat.MessageFrom(ChatScope.AboveEqRank, p,
+ "λNICK %Srequested a review! &c(Total " + pos + " waiting)", nextPerm, null, true);
p.NextReviewTime = DateTime.UtcNow.AddSeconds(ServerConfig.ReviewCooldown);
- OnPlayerActionEvent.Call(p, PlayerAction.Review, null, true);
}
void HandleView(Player p) {
@@ -109,17 +105,12 @@ namespace MCGalaxy.Commands.Moderation {
void HandleLeave(Player p) {
if (p == null) { Player.Message(p, "Console cannot leave the review queue."); return; }
- bool inQueue = false;
- foreach (string who in Server.reviewlist) {
- inQueue |= who.CaselessEq(p.name);
+ if (Server.reviewlist.CaselessRemove(p.name)) {
+ AnnounceQueueChanged();
+ Player.Message(p, "You have left the review queue!");
+ } else {
+ Player.Message(p, "You weren't in the review queue to begin with.");
}
-
- if (!inQueue) {
- Player.Message(p, "You aren't in the review queue so you cannot leave it."); return;
- }
- Server.reviewlist.Remove(p.name);
- MessageReviewPosChanged();
- Player.Message(p, "You have left the review queue!");
}
void HandleNext(Player p) {
@@ -131,21 +122,17 @@ namespace MCGalaxy.Commands.Moderation {
string user = Server.reviewlist[0];
Player who = PlayerInfo.FindExact(user);
+ Server.reviewlist.RemoveAt(0);
+
if (who == null) {
- Player.Message(p, "Player " + user + " doesn't exist or is offline, and was removed from the review queue");
- Server.reviewlist.Remove(user);
- return;
- } else if (who == p) {
- Player.Message(p, "Cannot teleport to yourself. You have been removed from the review queue.");
- Server.reviewlist.Remove(user);
+ Player.Message(p, "Player " + user + " is offline, and was removed from the review queue");
return;
}
- Server.reviewlist.Remove(user);
Command.Find("TP").Use(p, who.name);
Player.Message(p, "You have been teleported to " + user);
- Player.Message(who, "Your review request has been answered by " + p.name + ".");
- MessageReviewPosChanged();
+ Player.Message(who, "Your review request has been answered by " + p.ColoredName + ".");
+ AnnounceQueueChanged();
}
void HandleClear(Player p) {
@@ -154,13 +141,14 @@ namespace MCGalaxy.Commands.Moderation {
Player.Message(p, "The review queue has been cleared");
}
- static void MessageReviewPosChanged() {
- int count = 0;
+ static void AnnounceQueueChanged() {
+ int pos = 1;
foreach (string name in Server.reviewlist) {
Player who = PlayerInfo.FindExact(name);
if (who == null) continue;
- Player.Message(who, "The review queue has changed. You now have " + count + " players in front of you.");
- count++;
+
+ Player.Message(who, "The review queue has changed. You are now at &aposition #" + pos);
+ pos++;
}
}
diff --git a/MCGalaxy/Commands/World/CmdMap.cs b/MCGalaxy/Commands/World/CmdMap.cs
index c3874cd0f..797b65f96 100644
--- a/MCGalaxy/Commands/World/CmdMap.cs
+++ b/MCGalaxy/Commands/World/CmdMap.cs
@@ -127,7 +127,7 @@ namespace MCGalaxy.Commands.World {
if (message.CaselessEq("options")) {
Player.Message(p, "%HOptions: %S{0}",
LevelOptions.Options.Join(opt_ => opt_.Name));
- Player.Message(p, "%HUse %T/Help map [option] %Hto see description for that option");
+ Player.Message(p, "%HUse %T/Help map [option] %Hto see description for that option");
return;
}
diff --git a/MCGalaxy/Events/PlayerEvents.cs b/MCGalaxy/Events/PlayerEvents.cs
index c0d3d36ef..c6de7bc35 100644
--- a/MCGalaxy/Events/PlayerEvents.cs
+++ b/MCGalaxy/Events/PlayerEvents.cs
@@ -19,7 +19,7 @@ using System;
using BlockID = System.UInt16;
namespace MCGalaxy.Events.PlayerEvents {
- public enum PlayerAction { Me, Review, Referee, UnReferee };
+ public enum PlayerAction { Me, Referee, UnReferee };
public delegate void OnPlayerChat(Player p, string message);
/// Called whenever a player chats on the server.
diff --git a/MCGalaxy/Games/LavaSurvival/LSGame.cs b/MCGalaxy/Games/LavaSurvival/LSGame.cs
index 6f2b816ba..07acd7b00 100644
--- a/MCGalaxy/Games/LavaSurvival/LSGame.cs
+++ b/MCGalaxy/Games/LavaSurvival/LSGame.cs
@@ -23,12 +23,12 @@ namespace MCGalaxy.Games {
internal sealed class LSData {
public int TimesDied;
}
-
+
class LSLevelPicker : LevelPicker {
public List maps;
public override List GetCandidateMaps() { return new List(maps); }
}
-
+
public sealed partial class LSGame : RoundsGame {
const string propsDir = "properties/lavasurvival/";
List maps;
diff --git a/MCGalaxy/Levels/LevelOptions.cs b/MCGalaxy/Levels/LevelOptions.cs
index d3c8b319d..b4053b956 100644
--- a/MCGalaxy/Levels/LevelOptions.cs
+++ b/MCGalaxy/Levels/LevelOptions.cs
@@ -139,7 +139,7 @@ namespace MCGalaxy {
Toggle(p, l, ref l.Config.ServerWideChat, "Roleplay (level only) chat", true);
}
static void SetDrawing(Player p, Level l, string v) {
- Toggle(p, l, ref l.Config.Drawing, "Drawing commands");
+ Toggle(p, l, ref l.Config.Drawing, "Drawing commands");
}
static void SetLoadDelay(Player p, Level l, string value) {
diff --git a/MCGalaxy/Network/IRCPlugin/IRCHandlers.cs b/MCGalaxy/Network/IRCPlugin/IRCHandlers.cs
index 160152785..9931bd1fa 100644
--- a/MCGalaxy/Network/IRCPlugin/IRCHandlers.cs
+++ b/MCGalaxy/Network/IRCPlugin/IRCHandlers.cs
@@ -49,10 +49,13 @@ namespace MCGalaxy.Network {
public void Hook() {
if (hookedEvents) return;
hookedEvents = true;
-
- OnPlayerChatEvent.Register(HandleChat, Priority.Low);
+
OnPlayerActionEvent.Register(HandlePlayerAction, Priority.Low);
OnShuttingDownEvent.Register(HandleShutdown, Priority.Low);
+
+ OnChatEvent.Register(HandleChat, Priority.Low);
+ OnChatSysEvent.Register(HandleChatSys, Priority.Low);
+ OnChatFromEvent.Register(HandleChatFrom, Priority.Low);
// Regster events for incoming
bot.connection.Listener.OnNick += Listener_OnNick;
@@ -78,10 +81,13 @@ namespace MCGalaxy.Network {
hookedEvents = false;
userMap.Clear();
- OnPlayerChatEvent.Unregister(HandleChat);
OnPlayerActionEvent.Unregister(HandlePlayerAction);
OnShuttingDownEvent.Unregister(HandleShutdown);
+ OnChatEvent.Unregister(HandleChat);
+ OnChatSysEvent.Unregister(HandleChatSys);
+ OnChatFromEvent.Unregister(HandleChatFrom);
+
// Regster events for incoming
bot.connection.Listener.OnNick -= Listener_OnNick;
bot.connection.Listener.OnRegistered -= Listener_OnRegistered;
@@ -102,25 +108,33 @@ namespace MCGalaxy.Network {
void HandlePlayerAction(Player p, PlayerAction action, string message, bool stealth) {
- if (!p.level.SeesServerWideChat) return;
- string msg = null;
- if (p.muted || (Server.chatmod && !p.voice)) return;
-
- if (action == PlayerAction.Me)
- msg = "*" + p.DisplayName + " " + message;
- else if (action == PlayerAction.Review)
- msg = p.ColoredName + " %Sis requesting a review.";
-
- if (msg != null) bot.Say(msg, stealth);
- }
+ if (!p.level.SeesServerWideChat || action != PlayerAction.Me) return;
+ bot.Say("*" + p.DisplayName + " " + message, stealth);
+ }
- static char[] trimChars = new char[] { ' ' };
- void HandleChat(Player p, string message) {
- if (p.cancelchat || !p.level.SeesServerWideChat) return;
- if (message.Trim(trimChars).Length == 0) return;
-
- string name = ServerConfig.IRCShowPlayerTitles ? p.FullName : p.group.Prefix + p.ColoredName;
- bot.Say(name + "%S: " + message, p.opchat);
+ void HandleChatSys(ChatScope scope, ref string msg, object arg,
+ ref ChatMessageFilter filter, bool irc) {
+ if (!irc) return;
+ // TODO: Check filter
+ bot.Say(msg);
+ }
+
+ void HandleChatFrom(ChatScope scope, Player source, ref string msg,
+ object arg, ref ChatMessageFilter filter, bool irc) {
+ if (!irc) return;
+ // TODO: Check filter
+ string full = ServerConfig.IRCShowPlayerTitles ? source.FullName : source.group.Prefix + source.ColoredName;
+ msg = msg.Replace("λFULL", full).Replace("λNICK", source.ColoredName);
+ bot.Say(msg);
+ }
+
+ void HandleChat(ChatScope scope, Player source, ref string msg,
+ object arg, ref ChatMessageFilter filter, bool irc) {
+ if (!irc) return;
+ // TODO: Check filter
+ string full = ServerConfig.IRCShowPlayerTitles ? source.FullName : source.group.Prefix + source.ColoredName;
+ msg = msg.Replace("λFULL", full).Replace("λNICK", source.ColoredName);
+ bot.Say(msg);
}
void HandleShutdown(bool restarting, string message) {
@@ -205,7 +219,7 @@ namespace MCGalaxy.Network {
} else {
Logger.Log(LogType.IRCChat, "(IRC) {0}: {1}", user.Nick, message);
MessageInGame(user.Nick, string.Format("%I(IRC) {0}: &f{1}", user.Nick,
- ServerConfig.ProfanityFiltering ? ProfanityFilter.Parse(message) : message));
+ ServerConfig.ProfanityFiltering ? ProfanityFilter.Parse(message) : message));
}
}
@@ -250,12 +264,12 @@ namespace MCGalaxy.Network {
Logger.Log(LogType.CommandUsage, "/{0} (by {1} from IRC)", logCmd, user.Nick);
try {
- if (!p.group.CanExecute(cmd)) {
+ if (!p.group.CanExecute(cmd)) {
CommandPerms.Find(cmd.name).MessageCannotUse(p);
- return false;
- }
- if (!cmd.SuperUseable) {
- Player.Message(p, cmd.name + " can only be used in-game.");
+ return false;
+ }
+ if (!cmd.SuperUseable) {
+ Player.Message(p, cmd.name + " can only be used in-game.");
return false;
}
cmd.Use(p, cmdArgs);