diff --git a/CHANGELOG.md b/CHANGELOG.md
index b51cfcdd..5fdfb994 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -76,6 +76,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Moved `Utils.SendMultipleMatchError()` to `TSPlayer.SendMultipleMatchError`. (@hakusaro)
* Removed `Utils.GetPlayers()`. Iterate over the TSPlayers on the server and make your own list.
* Removed `Utils.HasBanExpired()` and replaced with `Bans.RemoveBanIfExpired()`. (@hakusaro)
+* Removed `Utils.SendFileToUser()` and replaced with `TSPlayer.SendFileTextAsMessage()`. (@hakusaro)
## TShock 4.3.25
* Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6.
diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs
index d7cdcf96..e6b7feca 100644
--- a/TShockAPI/Commands.cs
+++ b/TShockAPI/Commands.cs
@@ -4979,12 +4979,12 @@ namespace TShockAPI
private static void Motd(CommandArgs args)
{
- TShock.Utils.ShowFileToUser(args.Player, FileTools.MotdPath);
+ args.Player.SendFileTextAsMessage(FileTools.MotdPath);
}
private static void Rules(CommandArgs args)
{
- TShock.Utils.ShowFileToUser(args.Player, FileTools.RulesPath);
+ args.Player.SendFileTextAsMessage(FileTools.RulesPath);
}
private static void Whisper(CommandArgs args)
diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs
index 24578de6..c71141e7 100644
--- a/TShockAPI/TSPlayer.cs
+++ b/TShockAPI/TSPlayer.cs
@@ -1458,6 +1458,43 @@ namespace TShockAPI
SendDataFromPlayer(PacketTypes.SmartTextMessage, ply, msg, red, green, blue, -1);
}
+ ///
+ /// Sends the text of a given file to the player. Replacement of %map% and %players% if in the file.
+ ///
+ /// Filename relative to
+ public void SendFileTextAsMessage(string file)
+ {
+ string foo = "";
+ bool containsOldFormat = false;
+ using (var tr = new StreamReader(file))
+ {
+ Color lineColor;
+ while ((foo = tr.ReadLine()) != null)
+ {
+ lineColor = Color.White;
+ if (string.IsNullOrWhiteSpace(foo))
+ {
+ continue;
+ }
+
+ var players = new List();
+
+ foreach (TSPlayer ply in TShock.Players)
+ {
+ if (ply != null && ply.Active)
+ {
+ players.Add(ply.Name);
+ }
+ }
+
+ foo = foo.Replace("%map%", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName));
+ foo = foo.Replace("%players%", String.Join(",", players));
+
+ SendMessage(foo, lineColor);
+ }
+ }
+ }
+
///
/// Wounds the player with the given damage.
///
diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs
index 9549b6fb..26594077 100644
--- a/TShockAPI/TShock.cs
+++ b/TShockAPI/TShock.cs
@@ -1637,7 +1637,7 @@ namespace TShockAPI
if (Config.DisplayIPToAdmins)
Utils.SendLogs(string.Format("{0} has joined. IP: {1}", player.Name, player.IP), Color.Blue);
- Utils.ShowFileToUser(player, FileTools.MotdPath);
+ player.SendFileTextAsMessage(FileTools.MotdPath);
string pvpMode = Config.PvPMode.ToLowerInvariant();
if (pvpMode == "always")
diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs
index 778d211c..2907abb8 100644
--- a/TShockAPI/Utils.cs
+++ b/TShockAPI/Utils.cs
@@ -479,44 +479,6 @@ namespace TShockAPI
TShock.TileBans.UpdateBans();
}
- ///
- /// Shows a file to the user.
- ///
- /// 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(file))
- {
- Color lineColor;
- while ((foo = tr.ReadLine()) != null)
- {
- lineColor = Color.White;
- if (string.IsNullOrWhiteSpace(foo))
- {
- continue;
- }
-
- var players = new List();
-
- foreach (TSPlayer ply in TShock.Players)
- {
- if (ply != null && ply.Active)
- {
- players.Add(ply.Name);
- }
- }
-
- foo = foo.Replace("%map%", (TShock.Config.UseServerName ? TShock.Config.ServerName : Main.worldName));
- foo = foo.Replace("%players%", String.Join(",", players));
-
- player.SendMessage(foo, lineColor);
- }
- }
- }
-
///
/// Returns a Group from the name of the group
///