refactor: use pattern matching for null checks (is null / is not null)

Convert remaining == null to is null and != null to is not null
across 17 files in CommandHandler/ArgumentType, StructuredComponents,
and DeclareCommands for idiomatic C# style.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 00:47:03 +00:00
parent c7bc25aa17
commit 94bf42710a
17 changed files with 33 additions and 33 deletions

View file

@ -17,7 +17,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
{
McClient? client = CmdResult.currentHandler;
if (client != null)
if (client is not null)
{
var botList = client.GetLoadedChatBots();
foreach (var bot in botList)

View file

@ -18,10 +18,10 @@ namespace MinecraftClient.CommandHandler.ArgumentType
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
{
McClient? client = CmdResult.currentHandler;
if (client != null)
if (client is not null)
{
Inventory.Container? inventory = client.GetInventory(0);
if (inventory != null)
if (inventory is not null)
{
for (int i = 1; i <= 9; ++i)
{

View file

@ -18,7 +18,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
{
McClient? client = CmdResult.currentHandler;
if (client != null)
if (client is not null)
{
var invList = client.GetInventories();
foreach (var inv in invList)

View file

@ -19,7 +19,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
{
McClient? client = CmdResult.currentHandler;
if (client != null && context.Nodes.Count >= 2)
if (client is not null && context.Nodes.Count >= 2)
{
string invName = context.Nodes[1].Range.Get(builder.Input);
if (!int.TryParse(invName, out int invId))
@ -33,11 +33,11 @@ namespace MinecraftClient.CommandHandler.ArgumentType
};
Inventory.Container? inventory = client.GetInventory(invId);
if (inventory != null)
if (inventory is not null)
{
foreach ((int slot, Inventory.Item item) in inventory.Items)
{
if (item != null && item.Count > 0)
if (item is not null && item.Count > 0)
{
string slotStr = slot.ToString();
if (slotStr.StartsWith(builder.RemainingLowerCase, StringComparison.InvariantCultureIgnoreCase))

View file

@ -19,10 +19,10 @@ namespace MinecraftClient.CommandHandler.ArgumentType
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
{
McClient? client = CmdResult.currentHandler;
if (client != null)
if (client is not null)
{
var bot = (Map?)client.GetLoadedChatBots().Find(bot => bot.GetType().Name == "Map");
if (bot != null)
if (bot is not null)
{
var mapList = bot.cachedMaps;
foreach (var map in mapList)

View file

@ -19,7 +19,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
{
McClient? client = CmdResult.currentHandler;
if (client != null)
if (client is not null)
{
var entityList = client.GetEntities().Values.ToList();
foreach (var entity in entityList)