mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix all warnings & Trim (#2226)
* Fix AutoFishing crash * Fix all warnings * Remove DotNetZip. * Fix the usage of HttpClient.
This commit is contained in:
parent
4aa6c1c99f
commit
1d52d1eadd
227 changed files with 2201 additions and 43564 deletions
|
|
@ -1,16 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace MinecraftClient.Logger
|
||||
{
|
||||
public class FileLogLogger : FilteredLogger
|
||||
{
|
||||
private string logFile;
|
||||
private bool prependTimestamp;
|
||||
private object logFileLock = new object();
|
||||
private readonly string logFile;
|
||||
private readonly bool prependTimestamp;
|
||||
private readonly object logFileLock = new();
|
||||
|
||||
public FileLogLogger(string file, bool prependTimestamp = false)
|
||||
{
|
||||
|
|
@ -34,13 +31,13 @@ namespace MinecraftClient.Logger
|
|||
if (prependTimestamp)
|
||||
msg = GetTimestamp() + ' ' + msg;
|
||||
|
||||
string directory = Path.GetDirectoryName(logFile);
|
||||
string? directory = Path.GetDirectoryName(logFile);
|
||||
if (!String.IsNullOrEmpty(directory) && !Directory.Exists(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
lock (logFileLock)
|
||||
{
|
||||
FileStream stream = new FileStream(logFile, FileMode.OpenOrCreate);
|
||||
StreamWriter writer = new StreamWriter(stream);
|
||||
FileStream stream = new(logFile, FileMode.OpenOrCreate);
|
||||
StreamWriter writer = new(stream);
|
||||
stream.Seek(0, SeekOrigin.End);
|
||||
writer.WriteLine(msg);
|
||||
writer.Dispose();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MinecraftClient.Logger
|
||||
{
|
||||
|
|
@ -12,9 +8,9 @@ namespace MinecraftClient.Logger
|
|||
|
||||
protected bool ShouldDisplay(FilterChannel channel, string msg)
|
||||
{
|
||||
Regex regexToUse = null;
|
||||
Regex? regexToUse = null;
|
||||
// Convert to bool for XOR later. Whitelist = 0, Blacklist = 1
|
||||
bool filterMode = Settings.FilterMode == Settings.FilterModeEnum.Blacklist ? true : false;
|
||||
bool filterMode = Settings.FilterMode == Settings.FilterModeEnum.Blacklist;
|
||||
switch (channel)
|
||||
{
|
||||
case FilterChannel.Chat: regexToUse = Settings.ChatFilter; break;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Logger
|
||||
namespace MinecraftClient.Logger
|
||||
{
|
||||
public interface ILogger
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Logger
|
||||
namespace MinecraftClient.Logger
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract class providing basic implementation of the ILogger interface
|
||||
|
|
@ -30,7 +25,7 @@ namespace MinecraftClient.Logger
|
|||
|
||||
public void Chat(object msg)
|
||||
{
|
||||
Chat(msg.ToString());
|
||||
Chat(msg.ToString() ?? string.Empty);
|
||||
}
|
||||
|
||||
public abstract void Debug(string msg);
|
||||
|
|
@ -42,7 +37,7 @@ namespace MinecraftClient.Logger
|
|||
|
||||
public void Debug(object msg)
|
||||
{
|
||||
Debug(msg.ToString());
|
||||
Debug(msg.ToString() ?? string.Empty);
|
||||
}
|
||||
|
||||
public abstract void Error(string msg);
|
||||
|
|
@ -54,7 +49,7 @@ namespace MinecraftClient.Logger
|
|||
|
||||
public void Error(object msg)
|
||||
{
|
||||
Error(msg.ToString());
|
||||
Error(msg.ToString() ?? string.Empty);
|
||||
}
|
||||
|
||||
public abstract void Info(string msg);
|
||||
|
|
@ -66,7 +61,7 @@ namespace MinecraftClient.Logger
|
|||
|
||||
public void Info(object msg)
|
||||
{
|
||||
Info(msg.ToString());
|
||||
Info(msg.ToString() ?? string.Empty);
|
||||
}
|
||||
|
||||
public abstract void Warn(string msg);
|
||||
|
|
@ -78,12 +73,12 @@ namespace MinecraftClient.Logger
|
|||
|
||||
public void Warn(object msg)
|
||||
{
|
||||
Warn(msg.ToString());
|
||||
Warn(msg.ToString() ?? string.Empty);
|
||||
}
|
||||
|
||||
protected virtual void Log(object msg)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(msg.ToString());
|
||||
ConsoleIO.WriteLineFormatted(msg.ToString() ?? string.Empty);
|
||||
}
|
||||
|
||||
protected virtual void Log(string msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue