diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index cd37dda2..f0a37a22 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -41,5 +41,7 @@ namespace TShockAPI public bool RangeChecks = true; public bool SpamChecks = false; public bool DisableBuild = false; + public float[] AdminChatRGB = {255, 0, 0}; + public string AdminChatPrefix = "(Admin) "; } } \ No newline at end of file diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index f1ce1b29..9a0b9b4b 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -52,6 +52,8 @@ namespace TShockAPI public static int maxSlots = 8; public static bool spamChecks = false; public static bool disableBuild = false; + public static float[] adminChatRGB = {255, 0, 0}; + public static string adminChatPrefix = "(Admin) "; public enum NPCList { @@ -90,6 +92,8 @@ namespace TShockAPI disableBuild = cfg.DisableBuild; NPC.maxSpawns = defaultMaxSpawns; NPC.defaultSpawnRate = defaultSpawnRate; + adminChatRGB = cfg.AdminChatRGB; + adminChatPrefix = cfg.AdminChatPrefix; } public static void WriteJsonConfiguration() @@ -121,6 +125,8 @@ namespace TShockAPI cfg.RangeChecks = rangeChecks; cfg.SpamChecks = spamChecks; cfg.DisableBuild = disableBuild; + cfg.AdminChatRGB = adminChatRGB; + cfg.AdminChatPrefix = adminChatPrefix; string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json"); tr.Write(json); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 0a5c2212..96f3c8ff 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -600,6 +600,13 @@ namespace TShockAPI return; } + if (players[ply].group.HasPermission("adminchat") && !text.StartsWith("/")) + { + Tools.Broadcast(ConfigurationManager.adminChatPrefix + "<" + Main.player[ply].name + "> " + text, ConfigurationManager.adminChatRGB); + e.Handled = true; + return; + } + int x = (int)Main.player[ply].position.X; int y = (int)Main.player[ply].position.Y; diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index f818bb11..025e3e58 100755 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -105,7 +105,16 @@ namespace TShockAPI { for (int i = 0; i < Main.player.Length; i++) { - SendMessage(i, msg, red, green, blue); + SendMessage(i, msg, Tools.Clamp(red, 255, 0), Tools.Clamp(green, 255, 0), Tools.Clamp(blue, 255, 0)); + } + Log.Info(string.Format("Broadcast: {0}", msg)); + } + + public static void Broadcast(string msg, float[] colors) + { + for (int i = 0; i < Main.player.Length; i++) + { + SendMessage(i, msg, Tools.Clamp(colors[0], 255, 0), Tools.Clamp(colors[1], 255, 0), Tools.Clamp(colors[2], 255, 0)); } Log.Info(string.Format("Broadcast: {0}", msg)); }