refactor: convert == null / != null to is null / is not null in 31 files

Replace old-style null comparisons with modern C# pattern matching
syntax across Commands, Protocol, Mapping, ChatBots, Physics,
Inventory, Logger, CommandHandler, Scripting, Crypto, and other modules.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 00:42:59 +00:00
parent 446c6e7739
commit c7bc25aa17
31 changed files with 77 additions and 77 deletions

View file

@ -251,7 +251,7 @@ namespace MinecraftClient.Protocol.Handlers
/// <returns>Net read thread ID</returns>
public int GetNetMainThreadId()
{
return netRead != null ? netRead.Item1.ManagedThreadId : -1;
return netRead is not null ? netRead.Item1.ManagedThreadId : -1;
}
public bool SendCookieResponse(string name, byte[]? data)
@ -268,7 +268,7 @@ namespace MinecraftClient.Protocol.Handlers
{
try
{
if (netRead != null)
if (netRead is not null)
{
netRead.Item2.Cancel();
c.Close();
@ -556,7 +556,7 @@ namespace MinecraftClient.Protocol.Handlers
string serverHash = CryptoHandler.GetServerHash(serverIDhash, serverPublicKey, secretKey);
bool needCheckSession = true;
if (session.ServerPublicKey != null && session.SessionPreCheckTask != null
if (session.ServerPublicKey is not null && session.SessionPreCheckTask is not null
&& serverIDhash == session.ServerIDhash && Enumerable.SequenceEqual(serverPublicKey, session.ServerPublicKey))
{
session.SessionPreCheckTask.Wait();

View file

@ -21,7 +21,7 @@ namespace MinecraftClient.Protocol.Handlers
private readonly ForgeInfo? forgeInfo;
private FMLHandshakeClientState fmlHandshakeState = FMLHandshakeClientState.START;
private bool ForgeEnabled() { return forgeInfo != null; }
private bool ForgeEnabled() { return forgeInfo is not null; }
/// <summary>
/// Initialize a new Forge protocol handler

View file

@ -29,7 +29,7 @@ namespace MinecraftClient.Protocol.Handlers
/// <remarks>Silently dropped connection can only be detected by attempting to read/write data</remarks>
public bool IsConnected()
{
return c.Client != null && c.Connected;
return c.Client is not null && c.Connected;
}
/// <summary>