diff --git a/MinecraftClient/ChatBots/PlayerListLogger.cs b/MinecraftClient/ChatBots/PlayerListLogger.cs index 1d1c5cb9..0cf97194 100644 --- a/MinecraftClient/ChatBots/PlayerListLogger.cs +++ b/MinecraftClient/ChatBots/PlayerListLogger.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using static System.Net.Mime.MediaTypeNames; namespace MinecraftClient.ChatBots { @@ -34,19 +35,26 @@ namespace MinecraftClient.ChatBots count++; if (count == timeping) { - SendText("/list"); - count = 0; - } - } + string[] playerList = GetOnlinePlayers(); + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < playerList.Length; i++) + { + sb.Append(playerList[i]); + + // Do not add a comma after the last username + if (i != playerList.Length - 1) + sb.Append(", "); + } + + LogDebugToConsole("Saving Player List"); - public override void GetText(string text) - { - if (text.Contains("Joueurs en ligne") || text.Contains("Connected:") || text.Contains("online:")) - { - LogToConsole("Saving Player List"); DateTime now = DateTime.Now; string TimeStamp = "[" + now.Year + '/' + now.Month + '/' + now.Day + ' ' + now.Hour + ':' + now.Minute + ']'; - System.IO.File.AppendAllText(file, TimeStamp + "\n" + GetVerbatim(text) + "\n\n"); + System.IO.File.AppendAllText(file, TimeStamp + "\n" + sb.ToString() + "\n\n"); + + count = 0; } } } diff --git a/MinecraftClient/Resources/config/MinecraftClient.ini b/MinecraftClient/Resources/config/MinecraftClient.ini index 7ad56938..ece92b4e 100644 --- a/MinecraftClient/Resources/config/MinecraftClient.ini +++ b/MinecraftClient/Resources/config/MinecraftClient.ini @@ -275,4 +275,9 @@ backupinterval=300 # How long should replay file be auto-saved, i # this might clog the thread for terain handling) and thus slow the bot even more. enabled=false update_limit=10 # The rate at which the bot does calculations (10 = 1s) (Default: 5) (You can tweak this if you feel the bot is too slow) -stop_at_distance=3 # Do not follow the player if he is in the range of 3 blocks (prevents the bot from pushing a player in an infinite loop) \ No newline at end of file +stop_at_distance=3 # Do not follow the player if he is in the range of 3 blocks (prevents the bot from pushing a player in an infinite loop) + +[PlayerListLogger] +enabled=false +log_file=playerlog.txt +log_delay=600 # 10 = 1s \ No newline at end of file diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 1baf76f4..8a2577ae 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -10,6 +10,8 @@ using MinecraftClient.Mapping; using System.Threading.Tasks; using System.Collections.Concurrent; using System.Runtime.CompilerServices; +using MinecraftClient.ChatBots; +using System.Diagnostics.CodeAnalysis; namespace MinecraftClient { @@ -256,7 +258,7 @@ namespace MinecraftClient private static string ServerAliasTemp = null; //Mapping for settings sections in the INI file - private enum Section { Default, Main, AppVars, Proxy, MCSettings, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl, ChatFormat, AutoRespond, AutoAttack, AutoFishing, AutoEat, AutoCraft, AutoDrop, Mailer, ReplayMod, FollowPlayer, Logging, Signature }; + private enum Section { Default, Main, AppVars, Proxy, MCSettings, AntiAFK, Hangman, Alerts, ChatLog, AutoRelog, ScriptScheduler, RemoteControl, ChatFormat, AutoRespond, AutoAttack, AutoFishing, AutoEat, AutoCraft, AutoDrop, Mailer, ReplayMod, FollowPlayer, PlayerListLogger, Logging, Signature }; /// /// Get settings section from name @@ -854,6 +856,14 @@ namespace MinecraftClient case "stop_at_distance": FollowPlayer_StopAtDistance = str2int(argValue); return true; } break; + case Section.PlayerListLogger: + switch (ToLowerIfNeed(argName)) + { + case "enabled": PlayerLog_Enabled = str2bool(argValue); return true; + case "log_file": PlayerLog_File = argValue; return true; + case "log_delay": PlayerLog_Delay = str2int(argValue); return true; + } + break; } return false; }