mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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:
parent
446c6e7739
commit
c7bc25aa17
31 changed files with 77 additions and 77 deletions
|
|
@ -276,7 +276,7 @@ namespace MinecraftClient.ChatBots
|
|||
/// <remarks>so that it can be used in crafting table</remarks>
|
||||
public static Recipe ConvertToCraftingTable(Recipe recipe)
|
||||
{
|
||||
if (recipe.CraftingAreaType == ContainerType.PlayerInventory && recipe.Materials != null)
|
||||
if (recipe.CraftingAreaType == ContainerType.PlayerInventory && recipe.Materials is not null)
|
||||
{
|
||||
if (recipe.Materials.ContainsKey(4))
|
||||
{
|
||||
|
|
@ -500,7 +500,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
}
|
||||
|
||||
if (recipe.Materials != null)
|
||||
if (recipe.Materials is not null)
|
||||
{
|
||||
foreach (KeyValuePair<int, ItemType> slot in recipe.Materials)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -284,13 +284,13 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
if (Config.Send_Rendered_To_Discord)
|
||||
{
|
||||
if (discordBridge == null || (discordBridge != null && !discordBridge.IsConnected))
|
||||
if (discordBridge is null || (discordBridge is not null && !discordBridge.IsConnected))
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.Send_Rendered_To_Telegram)
|
||||
{
|
||||
if (telegramBridge == null || (telegramBridge != null && !telegramBridge.IsConnected))
|
||||
if (telegramBridge is null || (telegramBridge is not null && !telegramBridge.IsConnected))
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (csharp) //C# compiled script
|
||||
{
|
||||
//Initialize thread on first update
|
||||
if (thread == null)
|
||||
if (thread is null)
|
||||
{
|
||||
thread = new Thread(() =>
|
||||
{
|
||||
|
|
@ -166,7 +166,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
string errorMessage = string.Format(Translations.bot_script_fail, file, e.ExceptionType);
|
||||
LogToConsole(errorMessage);
|
||||
if (owner != null)
|
||||
if (owner is not null)
|
||||
SendPrivateMessage(owner, errorMessage);
|
||||
LogToConsole(e.InnerException);
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
|
||||
//Unload bot once the thread has finished running
|
||||
if (thread != null && !thread.IsAlive)
|
||||
if (thread is not null && !thread.IsAlive)
|
||||
{
|
||||
UnloadBot();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
private void Disconnect()
|
||||
{
|
||||
if (botClient != null)
|
||||
if (botClient is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -238,7 +238,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
private bool CanSendMessages()
|
||||
{
|
||||
return botClient != null && !string.IsNullOrEmpty(Config.ChannelId.Trim()) && bridgeDirection != BridgeDirection.Minecraft;
|
||||
return botClient is not null && !string.IsNullOrEmpty(Config.ChannelId.Trim()) && bridgeDirection != BridgeDirection.Minecraft;
|
||||
}
|
||||
|
||||
async Task MainAsync()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue