Fix all warnings & Trim (#2226)

* Fix AutoFishing crash
* Fix all warnings
* Remove DotNetZip.
* Fix the usage of HttpClient.
This commit is contained in:
BruceChen 2022-10-02 18:31:08 +08:00 committed by GitHub
parent 4aa6c1c99f
commit 1d52d1eadd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
227 changed files with 2201 additions and 43564 deletions

View file

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Net.Mime.MediaTypeNames;
namespace MinecraftClient.ChatBots
{
@ -13,8 +11,8 @@ namespace MinecraftClient.ChatBots
public class PlayerListLogger : ChatBot
{
private int count;
private int timeping;
private string file;
private readonly int timeping;
private readonly string file;
/// <summary>
/// This bot sends a /list command every X seconds and save the result.
@ -35,24 +33,14 @@ namespace MinecraftClient.ChatBots
count++;
if (count == timeping)
{
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(", ");
}
DateTime now = DateTime.Now;
LogDebugToConsole("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" + sb.ToString() + "\n\n");
StringBuilder sb = new();
sb.AppendLine(string.Format("[{0}/{1}/{2} {3}:{4}]", now.Year, now.Month, now.Day, now.Hour, now.Minute));
sb.AppendLine(string.Join(", ", GetOnlinePlayers())).AppendLine();
System.IO.File.AppendAllText(file, sb.ToString());
count = 0;
}