diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs
index 0cd9c0a8..6af27068 100644
--- a/TShockAPI/Utils.cs
+++ b/TShockAPI/Utils.cs
@@ -50,6 +50,8 @@ namespace TShockAPI
/// instance - an instance of the utils class
private static readonly Utils instance = new Utils();
+ private Regex byteRegex = new Regex("%\\s*(?\\d{1,3})\\s*,\\s*(?\\d{1,3})\\s*,\\s*(?\\d{1,3})\\s*%");
+
/// Utils - Creates a utilities object.
private Utils() {}
@@ -691,11 +693,12 @@ namespace TShockAPI
///
/// Shows a file to the user.
///
- /// TSPlayer player
- /// string filename reletave to savedir
+ /// Player the file contents will be sent to
+ /// Filename relative to
public void ShowFileToUser(TSPlayer player, string file)
{
string foo = "";
+ bool containsOldFormat = false;
using (var tr = new StreamReader(Path.Combine(TShock.SavePath, file)))
{
while ((foo = tr.ReadLine()) != null)
@@ -707,21 +710,14 @@ namespace TShockAPI
foo = foo.Replace("%map%", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName));
foo = foo.Replace("%players%", String.Join(",", GetPlayers(false)));
- Regex reg = new Regex("%\\s*(?\\d{1,3})\\s*,\\s*(?\\d{1,3})\\s*,\\s*(?\\d{1,3})\\s*%");
- var matches = reg.Matches(foo);
- Color c = Color.White;
- foreach (Match match in matches)
+ if (byteRegex.IsMatch(foo) && !containsOldFormat)
{
- byte r, g, b;
- if (byte.TryParse(match.Groups["r"].Value, out r) &&
- byte.TryParse(match.Groups["g"].Value, out g) &&
- byte.TryParse(match.Groups["b"].Value, out b))
- {
- c = new Color(r, g, b);
- }
- foo = foo.Remove(match.Index, match.Length);
+ TShock.Log.ConsoleInfo($"You are using an old color format in file {file}.");
+ TShock.Log.ConsoleInfo("To send coloured text please use Terraria's inbuilt format of: [c/#hex:text].");
+ TShock.Log.ConsoleInfo("For example: [c/ff00aa:This is a message!].");
+ containsOldFormat = true;
}
- player.SendMessage(foo, c);
+ player.SendMessage(foo, Color.White);
}
}
}