diff --git a/MCGalaxy/Commands/Chat/CmdTColor.cs b/MCGalaxy/Commands/Chat/CmdTColor.cs index 7f3df3b10..cdd2d3f4d 100644 --- a/MCGalaxy/Commands/Chat/CmdTColor.cs +++ b/MCGalaxy/Commands/Chat/CmdTColor.cs @@ -29,24 +29,24 @@ public class CmdTColor : EntityPropertyCmd { get { return new[] { new CommandAlias("TColour"), new CommandAlias("XTColor", "-own") }; } } public override void Use(Player p, string message, CommandData data) { - UseOnline(p, data, message, "title color"); + UsePlayer(p, data, message, "title color"); } - protected override void SetOnlineData(Player p, Player target, string colName) { + protected override void SetPlayerData(Player p, string target, string colName) { string col = ""; + Player who = PlayerInfo.FindExact(target); + if (colName.Length == 0) { - Chat.MessageFrom(target, "λNICK %Shad their title color removed"); + MessageFrom(target, who, "had their title color removed"); } else { col = Matcher.FindColor(p, colName); if (col == null) return; - if (col == target.titlecolor) { p.Message("{0} %Salready has that title color.", p.FormatNick(target)); return; } - - Chat.MessageFrom(target, "λNICK %Shad their title color changed to " + col + Colors.Name(col)); + MessageFrom(target, who, "had their title color changed to " + col + Colors.Name(col)); } - target.titlecolor = col; - target.SetPrefix(); - PlayerDB.Update(target.name, PlayerData.ColumnTColor, col); + if (who != null) who.titlecolor = col; + if (who != null) who.SetPrefix(); + PlayerDB.Update(target, PlayerData.ColumnTColor, col); } public override void Help(Player p) { diff --git a/MCGalaxy/Commands/Chat/CmdTitle.cs b/MCGalaxy/Commands/Chat/CmdTitle.cs index a4ea30441..7446414cd 100644 --- a/MCGalaxy/Commands/Chat/CmdTitle.cs +++ b/MCGalaxy/Commands/Chat/CmdTitle.cs @@ -31,21 +31,22 @@ public class CmdTitle : EntityPropertyCmd { public override void Use(Player p, string message, CommandData data) { if (!MessageCmd.CanSpeak(p, name)) return; - UseOnline(p, data, message, "title"); + UsePlayer(p, data, message, "title"); } - protected override void SetOnlineData(Player p, Player who, string title) { + protected override void SetPlayerData(Player p, string target, string title) { if (title.Length >= 20) { p.Message("Title must be under 20 letters."); return; } - + Player who = PlayerInfo.FindExact(target); + if (title.Length == 0) { - Chat.MessageFrom(who, "λNICK %Shad their title removed"); + MessageFrom(target, who, "had their title removed"); } else { - Chat.MessageFrom(who, "λNICK %Shad their title changed to &b[" + title + "&b]"); + MessageFrom(target, who, "had their title changed to &b[" + title + "&b]"); } - who.title = title; - who.SetPrefix(); - PlayerDB.Update(who.name, PlayerData.ColumnTitle, title.UnicodeToCp437()); + if (who != null) who.title = title; + if (who != null) who.SetPrefix(); + PlayerDB.Update(target, PlayerData.ColumnTitle, title.UnicodeToCp437()); } public override void Help(Player p) { diff --git a/MCGalaxy/Commands/EntityPropertyCmd.cs b/MCGalaxy/Commands/EntityPropertyCmd.cs index 7e9263411..fe2cf0c38 100644 --- a/MCGalaxy/Commands/EntityPropertyCmd.cs +++ b/MCGalaxy/Commands/EntityPropertyCmd.cs @@ -52,7 +52,7 @@ public abstract class EntityPropertyCmd : Command2 { if (!CheckRank(p, data, who, "change the " + type + " of", true)) return; SetOnlineData(p, who, args.Length > 1 ? args[1] : ""); } - + protected void UsePlayer(Player p, CommandData data, string message, string type) { if (message.Length == 0) { Help(p); return; } string[] args = message.SplitSpaces(2); @@ -71,5 +71,14 @@ public abstract class EntityPropertyCmd : Command2 { protected virtual void SetBotData(Player p, PlayerBot bot, string args) { } protected virtual void SetOnlineData(Player p, Player who, string args) { } protected virtual void SetPlayerData(Player p, string target, string args) { } + + protected void MessageFrom(string target, Player who, string message) { + if (who == null) { + string nick = Player.Console.FormatNick(target); + Chat.MessageGlobal(nick + " %S" + message); + } else { + Chat.MessageFrom(who, "λNICK %S" + message); + } + } } }