From 37d40374bedf595fb7ceceb83a5ff749879888ac Mon Sep 17 00:00:00 2001 From: Shank Date: Tue, 14 Jun 2011 02:15:18 -0600 Subject: [PATCH] /rules now follows MOTD formatting rules. Tools.ShowMOTD is deprecated, use Tools.ShowFileToUser instead. --- TShockAPI/Commands.cs | 10 +--------- TShockAPI/Tools.cs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f2923168..abb1ba1e 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -240,15 +240,7 @@ namespace TShockAPI public static void Rules(CommandArgs args) { - TextReader sr = new StreamReader(FileTools.SaveDir + "rules.txt"); - string unsplit = sr.ReadToEnd(); - sr.Close(); - - string[] split = unsplit.Split(Convert.ToChar("\n")); - for (int i = 0; i < split.Length; i++) - { - Tools.SendMessage(args.PlayerID, split[i]); - } + Tools.ShowFileToUser(args.PlayerID, "rules.txt"); } public static void ToggleAntiBuild(CommandArgs args) diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index ed0e7a78..f818bb11 100755 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -342,15 +342,20 @@ namespace TShockAPI } return false; } - - /// - /// Shows a MOTD to the player - /// - /// int player + [Obsolete("Use ShowFileToUser(int ply, string file) instead.")] public static void ShowMOTD(int ply) + { + ShowFileToUser(ply, "motd.txt"); + } + /// + /// Shows a file to the user. + /// + /// int player + /// string filename reletave to savedir + public static void ShowFileToUser(int ply, string file) { string foo = ""; - TextReader tr = new StreamReader(FileTools.SaveDir + "motd.txt"); + TextReader tr = new StreamReader(FileTools.SaveDir + file); while ((foo = tr.ReadLine()) != null) { foo = foo.Replace("%map%", Main.worldName);