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

@ -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)
{

View file

@ -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;
}

View file

@ -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();
}

View file

@ -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()

View file

@ -51,7 +51,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType
string[] args = builder.Remaining.Split(' ', StringSplitOptions.TrimEntries);
if (args.Length == 0 || (args.Length == 1 && string.IsNullOrWhiteSpace(args[0])))
{
if (client != null)
if (client is not null)
{
Location current = client.GetCurrentLocation();
builder.Suggest(string.Format("{0:0.00}", current.X));
@ -68,7 +68,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType
else if (args.Length == 1 || (args.Length == 2 && string.IsNullOrWhiteSpace(args[1])))
{
string add = args.Length == 1 ? " " : string.Empty;
if (client != null)
if (client is not null)
{
Location current = client.GetCurrentLocation();
builder.Suggest(string.Format("{0}{2}{1:0.00}", builder.Remaining, current.Y, add));
@ -83,7 +83,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType
else if (args.Length == 2 || (args.Length == 3 && string.IsNullOrWhiteSpace(args[2])))
{
string add = args.Length == 2 ? " " : string.Empty;
if (client != null)
if (client is not null)
{
Location current = client.GetCurrentLocation();
builder.Suggest(string.Format("{0}{2}{1:0.00}", builder.Remaining, current.Z, add));

View file

@ -87,7 +87,7 @@ namespace MinecraftClient.CommandHandler
public override string ToString()
{
if (result != null)
if (result is not null)
return result;
else
return status.ToString();

View file

@ -84,7 +84,7 @@ namespace MinecraftClient.Commands
else
{
ChatBot? bot = handler.GetLoadedChatBots().Find(bot => bot.GetType().Name.ToLower() == botName.ToLower());
if (bot == null)
if (bot is null)
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_bots_notfound, botName));
else
{

View file

@ -92,7 +92,7 @@ namespace MinecraftClient.Commands
sb.Append('\n');
sb.AppendLine(string.Format(Translations.cmd_chunk_current, current, current.ChunkX, current.ChunkZ));
if (markedChunkPos != null)
if (markedChunkPos is not null)
{
sb.Append(Translations.cmd_chunk_marked);
if (pos.HasValue)
@ -120,7 +120,7 @@ namespace MinecraftClient.Commands
{
for (int x = startX; x <= endX; ++x)
{
if (world[x, z] != null)
if (world[x, z] is not null)
{
leftMost = Math.Min(leftMost, x);
rightMost = Math.Max(rightMost, x);
@ -184,7 +184,7 @@ namespace MinecraftClient.Commands
}
// Try to include the marker chunk
if (markedChunkPos != null &&
if (markedChunkPos is not null &&
(((Math.Max(bottomMost, markChunkZ) - Math.Min(topMost, markChunkZ) + 1) > consoleHeight) ||
((Math.Max(rightMost, markChunkX) - Math.Min(leftMost, markChunkX) + 1) > consoleWidth)))
sb.AppendLine(Translations.cmd_chunk_outside);
@ -212,7 +212,7 @@ namespace MinecraftClient.Commands
sb.Append("§§4"); // Marked chunk: background red
ChunkColumn? chunkColumn = world[x, z];
if (chunkColumn == null)
if (chunkColumn is null)
sb.Append(chunkStatusStr[0]);
else if (chunkColumn.FullyLoaded)
sb.Append(chunkStatusStr[2]);
@ -242,10 +242,10 @@ namespace MinecraftClient.Commands
handler.Log.Info(Translations.cmd_chunk_for_debug);
(int chunkX, int chunkZ) = markedChunkPos ?? new(pos!.Value.ChunkX, pos!.Value.ChunkZ);
ChunkColumn? chunkColumn = handler.GetWorld()[chunkX, chunkZ];
if (chunkColumn != null)
if (chunkColumn is not null)
chunkColumn.FullyLoaded = false;
if (chunkColumn == null)
if (chunkColumn is null)
return r.SetAndReturn(Status.Fail, "Fail: chunk dosen't exist!");
else
return r.SetAndReturn(Status.Done, string.Format("Successfully marked chunk ({0}, {1}) as loading.", chunkX, chunkZ));
@ -262,10 +262,10 @@ namespace MinecraftClient.Commands
handler.Log.Info(Translations.cmd_chunk_for_debug);
(int chunkX, int chunkZ) = markedChunkPos ?? new(pos!.Value.ChunkX, pos!.Value.ChunkZ);
ChunkColumn? chunkColumn = handler.GetWorld()[chunkX, chunkZ];
if (chunkColumn != null)
if (chunkColumn is not null)
chunkColumn.FullyLoaded = false;
if (chunkColumn == null)
if (chunkColumn is null)
return r.SetAndReturn(Status.Fail, "Fail: chunk dosen't exist!");
else
return r.SetAndReturn(Status.Done, string.Format("Successfully marked chunk ({0}, {1}) as loaded.", chunkX, chunkZ));

View file

@ -66,7 +66,7 @@ namespace MinecraftClient.Commands
}
}
if (enchantingTable == null)
if (enchantingTable is null)
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_enchant_enchanting_table_not_opened);
int[] emptySlots = enchantingTable.GetEmpytSlots();
@ -84,7 +84,7 @@ namespace MinecraftClient.Commands
EnchantmentData? enchantment = handler.GetLastEnchantments();
if (enchantment == null)
if (enchantment is null)
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_enchant_no_enchantments);
short requiredLevel = slotId switch

View file

@ -276,7 +276,7 @@ namespace MinecraftClient.Commands
}
Container? inventory = handler.GetInventory(inventoryId.Value);
if (inventory == null)
if (inventory is null)
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_not_exist, inventoryId));
if (handler.CloseInventory(inventoryId.Value))
@ -299,7 +299,7 @@ namespace MinecraftClient.Commands
}
Container? inventory = handler.GetInventory(inventoryId.Value);
if (inventory == null)
if (inventory is null)
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_not_exist, inventoryId));
StringBuilder response = new();
@ -307,7 +307,7 @@ namespace MinecraftClient.Commands
response.AppendLine(String.Format(" #{0} - {1}§8", inventoryId, inventory.Title));
string? asciiArt = inventory.Type.GetAsciiArt();
if (asciiArt != null && Settings.Config.Main.Advanced.ShowInventoryLayout)
if (asciiArt is not null && Settings.Config.Main.Advanced.ShowInventoryLayout)
response.AppendLine(asciiArt);
int selectedHotbar = handler.GetCurrentSlot() + 1;
@ -342,7 +342,7 @@ namespace MinecraftClient.Commands
}
Container? inventory = handler.GetInventory(inventoryId.Value);
if (inventory == null)
if (inventory is null)
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_not_exist, inventoryId));
string keyName = actionType switch
@ -373,7 +373,7 @@ namespace MinecraftClient.Commands
}
Container? inventory = handler.GetInventory(inventoryId.Value);
if (inventory == null)
if (inventory is null)
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_not_exist, inventoryId));
// check item exist

View file

@ -89,7 +89,7 @@ namespace MinecraftClient.Crypto
}
Span<byte> blockOutput = stackalloc byte[blockSize];
if (FastAes != null)
if (FastAes is not null)
FastAes.EncryptEcb(ReadStreamIV, blockOutput);
else
Aes!.EncryptEcb(ReadStreamIV, blockOutput, PaddingMode.None);
@ -122,7 +122,7 @@ namespace MinecraftClient.Crypto
}
int processEnd = readed + curRead;
if (FastAes != null)
if (FastAes is not null)
{
for (int idx = readed; idx < processEnd; idx++)
{
@ -161,7 +161,7 @@ namespace MinecraftClient.Crypto
{
Span<byte> blockOutput = stackalloc byte[blockSize];
if (FastAes != null)
if (FastAes is not null)
FastAes.EncryptEcb(WriteStreamIV, blockOutput);
else
Aes!.EncryptEcb(WriteStreamIV, blockOutput, PaddingMode.None);
@ -185,7 +185,7 @@ namespace MinecraftClient.Crypto
for (int wirtten = 0; wirtten < required; ++wirtten)
{
ReadOnlySpan<byte> blockInput = new(outputBuf, wirtten, blockSize);
if (FastAes != null)
if (FastAes is not null)
FastAes.EncryptEcb(blockInput, blockOutput);
else
Aes!.EncryptEcb(blockInput, blockOutput, PaddingMode.None);

View file

@ -59,9 +59,9 @@ namespace MinecraftClient
/// </summary>
public void Dispose()
{
if (monitor != null)
if (monitor is not null)
monitor.Item1.Dispose();
if (polling != null)
if (polling is not null)
polling.Item2.Cancel();
}

View file

@ -172,7 +172,7 @@ namespace MinecraftClient.Inventory
public int[] SearchItem(ItemType itemType)
{
List<int> result = new();
if (Items != null)
if (Items is not null)
{
foreach (var item in Items)
{

View file

@ -273,7 +273,7 @@ namespace MinecraftClient.Inventory
public static Enchantments GetEnchantmentByRegistryId1206(int id)
{
if (dynamicEnchantmentIdMap != null && dynamicEnchantmentIdMap.TryGetValue(id, out var dynValue))
if (dynamicEnchantmentIdMap is not null && dynamicEnchantmentIdMap.TryGetValue(id, out var dynValue))
return dynValue;
if (enchantmentMappings.TryGetValue((short)id, out var value))
return value;
@ -282,10 +282,10 @@ namespace MinecraftClient.Inventory
public static int GetRegistryId1206ByEnchantment(Enchantments enchantment)
{
if (reverseEnchantmentMappings == null)
if (reverseEnchantmentMappings is null)
{
reverseEnchantmentMappings = new();
if (dynamicEnchantmentIdMap != null)
if (dynamicEnchantmentIdMap is not null)
{
foreach (var kvp in dynamicEnchantmentIdMap)
reverseEnchantmentMappings[kvp.Value] = (short)kvp.Key;

View file

@ -31,7 +31,7 @@ namespace MinecraftClient.Logger
regexToUse = new(debug);
break;
}
if (regexToUse != null)
if (regexToUse is not null)
{
// IsMatch and white/blacklist result can be represented using XOR
// e.g. matched(true) ^ blacklist(true) => shouldn't log(false)

View file

@ -137,7 +137,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
File.WriteAllLines(outputPalettePath, outFile);
if (outputEnum != null)
if (outputEnum is not null)
{
outFile = new List<string>();
outFile.AddRange(new[] {

View file

@ -129,7 +129,7 @@ namespace MinecraftClient.Mapping
{
Name = name ?? throw new ArgumentNullException(nameof(name));
if (nbt == null)
if (nbt is null)
throw new ArgumentNullException(nameof(nbt));
if (nbt.ContainsKey("piglin_safe"))

View file

@ -29,9 +29,9 @@ namespace MinecraftClient.Mapping.EntityPalettes
Dictionary<int, EntityType> entityTypes = GetDict();
Dictionary<int, EntityType>? entityTypesNonLiving = GetDictNonLiving();
if (entityTypesNonLiving != null && !living)
if (entityTypesNonLiving is not null && !living)
{
//Pre-1.14 non-living entities have a different set of IDs (entityTypesNonLiving != null)
//Pre-1.14 non-living entities have a different set of IDs (entityTypesNonLiving is not null)
if (entityTypesNonLiving.ContainsKey(id))
return entityTypesNonLiving[id];
}

View file

@ -108,7 +108,7 @@ namespace MinecraftClient.Mapping
public static Location Parse(string x, string y, string z)
{
Location.TryParse(x, y, z, out Location? res);
if (res == null)
if (res is null)
throw new FormatException();
else
return (Location)res;
@ -308,7 +308,7 @@ namespace MinecraftClient.Mapping
/// <returns>TRUE if the locations are equals</returns>
public override bool Equals(object? obj)
{
if (obj == null)
if (obj is null)
return false;
if (obj is Location location)
{

View file

@ -39,7 +39,7 @@ namespace MinecraftClient.Physics
/// </summary>
public static Aabb[] GetShapes(int blockStateId)
{
if (stateToShape != null && stateToShape.TryGetValue(blockStateId, out var shapes))
if (stateToShape is not null && stateToShape.TryGetValue(blockStateId, out var shapes))
return shapes;
return FallbackShape(blockStateId);
}
@ -76,7 +76,7 @@ namespace MinecraftClient.Physics
{
var assembly = Assembly.GetExecutingAssembly();
using var stream = assembly.GetManifestResourceStream("BlockShapeData.json");
if (stream == null)
if (stream is null)
{
ConsoleInteractive.ConsoleWriter.WriteLineFormatted("§e[Physics] BlockShapeData.json not found as embedded resource");
return;
@ -138,12 +138,12 @@ namespace MinecraftClient.Physics
{
stateToShape = new Dictionary<int, Aabb[]>();
if (prismarineBlocks == null || prismarineShapes == null)
if (prismarineBlocks is null || prismarineShapes is null)
return;
var palette = Block.Palette;
var dict = GetPaletteDict(palette);
if (dict == null) return;
if (dict is null) return;
// Group consecutive state IDs by Material to find state ranges per block
var materialRanges = new Dictionary<Material, List<(int start, int end)>>();

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>

View file

@ -64,7 +64,7 @@ namespace MinecraftClient.Protocol.Message
public LastSeenMessageList.AcknowledgedMessage? ToLastSeenMessageEntry()
{
return signature != null ? new LastSeenMessageList.AcknowledgedMessage(senderUUID, signature, true) : null;
return signature is not null ? new LastSeenMessageList.AcknowledgedMessage(senderUUID, signature, true) : null;
}
public bool LacksSender()

View file

@ -107,7 +107,7 @@ namespace MinecraftClient.Protocol.Message
}
}
if (lastEntry != null && messageCount < acknowledgedMessages.Length)
if (lastEntry is not null && messageCount < acknowledgedMessages.Length)
acknowledgedMessages[messageCount++] = lastEntry;
LastSeenMessageList.AcknowledgedMessage[] msgList = new LastSeenMessageList.AcknowledgedMessage[messageCount];
@ -120,7 +120,7 @@ namespace MinecraftClient.Protocol.Message
{
// net.minecraft.network.message.LastSeenMessagesCollector#add(net.minecraft.network.message.MessageSignatureData, boolean)
// net.minecraft.network.message.LastSeenMessagesCollector#add(net.minecraft.network.message.AcknowledgedMessage)
if (lastEntry != null && entry.signature.SequenceEqual(lastEntry.signature))
if (lastEntry is not null && entry.signature.SequenceEqual(lastEntry.signature))
return false;
lastEntry = entry;
@ -143,7 +143,7 @@ namespace MinecraftClient.Protocol.Message
{
int k = (nextIndex + j) % acknowledgedMessages.Length;
AcknowledgedMessage? acknowledgedMessage = acknowledgedMessages[k];
if (acknowledgedMessage == null)
if (acknowledgedMessage is null)
continue;
bitset[j / 8] |= (byte)(1 << (j % 8)); // bitSet.set(j, true);
objectList.Add(acknowledgedMessage);

View file

@ -43,7 +43,7 @@ namespace MinecraftClient.Protocol.ProfileKey
}
catch (Exception e)
{
int code = response == null ? 0 : response.StatusCode;
int code = response is null ? 0 : response.StatusCode;
ConsoleIO.WriteLineFormatted("§cFetch authlib-injector metadata failed: HttpCode = " + code + ", Error = " + e.Message);
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
@ -93,12 +93,12 @@ namespace MinecraftClient.Protocol.ProfileKey
}
var json = Json.ParseJson(response.Body);
if (json?["keyPair"]?["publicKey"] == null
|| json["keyPair"]?["privateKey"] == null
|| json["publicKeySignature"] == null
|| json["publicKeySignatureV2"] == null
|| json["expiresAt"] == null
|| json["refreshedAfter"] == null)
if (json?["keyPair"]?["publicKey"] is null
|| json["keyPair"]?["privateKey"] is null
|| json["publicKeySignature"] is null
|| json["publicKeySignatureV2"] is null
|| json["expiresAt"] is null
|| json["refreshedAfter"] is null)
{
throw new InvalidOperationException("Certificate endpoint returned an unexpected payload.");
}
@ -115,7 +115,7 @@ namespace MinecraftClient.Protocol.ProfileKey
}
catch (Exception e)
{
int code = response == null ? 0 : response.StatusCode;
int code = response is null ? 0 : response.StatusCode;
ConsoleIO.WriteLineFormatted("§cFetch profile key failed: HttpCode = " + code + ", Error = " + e.Message);
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
@ -209,7 +209,7 @@ namespace MinecraftClient.Protocol.ProfileKey
{
List<byte> data = new();
if (precedingSignature != null)
if (precedingSignature is not null)
data.AddRange(precedingSignature);
data.AddRange(sender.ToBigEndianBytes());

View file

@ -73,11 +73,11 @@ namespace MinecraftClient.Protocol.ProfileKey
{
List<string> datas = new();
datas.Add(Convert.ToBase64String(PublicKey.Key));
if (PublicKey.Signature == null)
if (PublicKey.Signature is null)
datas.Add(string.Empty);
else
datas.Add(Convert.ToBase64String(PublicKey.Signature));
if (PublicKey.SignatureV2 == null)
if (PublicKey.SignatureV2 is null)
datas.Add(string.Empty);
else
datas.Add(Convert.ToBase64String(PublicKey.SignatureV2));

View file

@ -25,10 +25,10 @@ namespace MinecraftClient.Protocol.ProfileKey
if (!string.IsNullOrEmpty(sigV2))
SignatureV2 = Convert.FromBase64String(sigV2!);
if (SignatureV2 == null || SignatureV2.Length == 0)
if (SignatureV2 is null || SignatureV2.Length == 0)
SignatureV2 = Signature;
if (Signature == null || Signature.Length == 0)
if (Signature is null || Signature.Length == 0)
Signature = SignatureV2;
}

View file

@ -45,7 +45,7 @@ namespace MinecraftClient.Protocol.Session
public bool SessionPreCheck(LoginType type)
{
if (ID == string.Empty || PlayerID == String.Empty || ServerPublicKey == null)
if (ID == string.Empty || PlayerID == String.Empty || ServerPublicKey is null)
return false;
Crypto.CryptoHandler.ClientAESPrivateKey ??= Crypto.CryptoHandler.GenerateAESPrivateKey();
string serverHash = Crypto.CryptoHandler.GetServerHash(ServerIDhash, ServerPublicKey, Crypto.CryptoHandler.ClientAESPrivateKey);
@ -57,7 +57,7 @@ namespace MinecraftClient.Protocol.Session
public override string ToString()
{
return String.Join(",", ID, PlayerName, PlayerID, ClientID, RefreshToken, ServerIDhash,
(ServerPublicKey == null) ? String.Empty : Convert.ToBase64String(ServerPublicKey));
(ServerPublicKey is null) ? String.Empty : Convert.ToBase64String(ServerPublicKey));
}
public static SessionToken FromString(string tokenString)

View file

@ -142,7 +142,7 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
"[Script Error] Too many references to the same assembly. Assembly name: " + refs.Name);
}
if (reference == null) {
if (reference is null) {
throw new InvalidOperationException(
"[Script Error] The executable does not contain a referenced assembly. Assembly name: " + refs.Name);
}

View file

@ -1150,7 +1150,7 @@ namespace MinecraftClient
break;
default:
if (localVars != null && localVars.ContainsKey(varname_lower))
if (localVars is not null && localVars.ContainsKey(varname_lower))
result.Append(localVars[varname_lower].ToString());
else if (TryGetVar(varname_lower, out object? var_value))
result.Append(var_value.ToString());
@ -1979,7 +1979,7 @@ namespace MinecraftClient
public static string GetFullMessage(this Exception ex)
{
string msg = ex.Message.Replace("+", "->");
return ex.InnerException == null
return ex.InnerException is null
? msg
: msg + "\n --> " + ex.InnerException.GetFullMessage();
}