Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
Controllerdestiny committed Dec 25, 2024
commit 70e4b6797936f5a43b8f515139835310e9891d91
11 changes: 10 additions & 1 deletion src/ServerTools/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public partial class Plugin : LazyPlugin

public Plugin(Main game) : base(game)
{
typeof(TextLog).GetField("_logWriter")?.SetValue(TShock.Log, new StreamWriter(TShock.Log.FileName, true, new UTF8Encoding(true, true)));
new Hook(typeof(TextLog).GetConstructor(new Type[] { typeof(string), typeof(bool) }), TextLogCtor);

}

private RestCommand[] addRestCommands = null!;
Expand Down Expand Up @@ -244,6 +245,14 @@ public static void RestPlayerCtor(Action<TSRestPlayer, string, TShockAPI.Group>
orig(self, name, group);
}

public static void TextLogCtor(Action<TextLog, string, bool> orig, TextLog self, string filename, bool clear)
{
typeof(TextLog)
.GetField("_logWriter", System.Reflection.BindingFlags.NonPublic)
?.SetValue(self, new StreamWriter(TShock.Log.FileName, !clear, new UTF8Encoding(true, true)));
orig(self, filename, clear);
}

private void OnPlayerSpawn(object? sender, GetDataHandlers.SpawnEventArgs e)
{
if (e.Player != null)
Expand Down