Modernize null-check patterns: use 'is null' and 'is not null'

Replace '== null' with 'is null' and '!= null' with 'is not null'
across 19 core files following modern C# pattern matching conventions.

Only literal null comparisons are changed. Assignments, value
comparisons, and LINQ expressions are left untouched.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 00:27:07 +00:00
parent 902e944cbb
commit c5df6a49c6
19 changed files with 111 additions and 111 deletions

View file

@ -109,7 +109,7 @@ namespace MinecraftClient.Scripting
var result = compiler.Compile(code, Guid.NewGuid().ToString(), dlls);
//Process compile warnings and errors
if (result.Failures != null)
if (result.Failures is not null)
{
ConsoleIO.WriteLogLine("[Script] Compilation failed with error(s):");
@ -309,7 +309,7 @@ namespace MinecraftClient.Scripting
/// <returns>Value of the variable or null if no variable</returns>
public object? GetVar(string varName)
{
if (localVars != null && localVars.ContainsKey(varName))
if (localVars is not null && localVars.ContainsKey(varName))
return localVars[varName];
else
return Config.AppVar.GetVar(varName);
@ -322,7 +322,7 @@ namespace MinecraftClient.Scripting
/// <param name="varValue">Value of the variable</param>
public bool SetVar(string varName, object varValue)
{
if (localVars != null && localVars.ContainsKey(varName))
if (localVars is not null && localVars.ContainsKey(varName))
localVars.Remove(varName);
return Config.AppVar.SetVar(varName, varValue);
}
@ -339,12 +339,12 @@ namespace MinecraftClient.Scripting
object? value = GetVar(varName);
if (value is T Tval)
return Tval;
if (value != null)
if (value is not null)
{
try
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
if (converter != null)
if (converter is not null)
return (T?)converter.ConvertFromString(value.ToString() ?? string.Empty);
}
catch (NotSupportedException) { /* Was worth trying */ }

View file

@ -49,9 +49,9 @@ namespace MinecraftClient.Scripting
{
get
{
if (master != null)
if (master is not null)
return master.Handler;
if (_handler != null)
if (_handler is not null)
return _handler;
throw new InvalidOperationException(Translations.exception_chatbot_init);
}
@ -862,7 +862,7 @@ namespace MinecraftClient.Scripting
protected void LogToConsole(object? text)
{
string botName = Translations.ResourceManager.GetString("botname." + GetType().Name) ?? GetType().Name;
if (_handler == null || master == null)
if (_handler is null || master is null)
ConsoleIO.WriteLogLine(string.Format("[{0}] {1}", botName, text));
else
Handler.Log.Info(string.Format("[{0}] {1}", botName, text));