mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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:
parent
c7bc25aa17
commit
94bf42710a
17 changed files with 33 additions and 33 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue