Convert switch statements to expressions and adopt collection expressions

- DirectionExtensions.cs: Convert GetOpposite() to switch expression,
  use file-scoped namespace, use collection expression for HORIZONTAL
- McClient.cs: Convert InteractType switch to expression, use collection
  expressions for array literals
- Protocol18.cs: Replace Array.Empty<byte>() with [], use collection
  expressions for byte/int array literals
- DataTypes.cs: Use collection expression for TAG_End byte array
- ChatBot.cs: Use collection expressions for string/char arrays
- Location.cs: Use collection expressions and modernize null check

Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
Agent-Logs-Url: https://github.com/milutinke/Minecraft-Console-Client/sessions/4e9bd25b-22c5-47c2-98f9-6025d927b1d6
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 00:34:00 +00:00
parent c5df6a49c6
commit 2ae31e269f
6 changed files with 66 additions and 92 deletions

View file

@ -785,7 +785,7 @@ namespace MinecraftClient.Scripting
string prefix = tmp[0];
string user = tmp[1];
string semicolon = tmp[2];
if (prefix.All(c => char.IsLetterOrDigit(c) || new char[] { '*', '<', '>', '_' }.Contains(c))
if (prefix.All(c => char.IsLetterOrDigit(c) || new[] { '*', '<', '>', '_' }.Contains(c))
&& semicolon == ":")
{
message = text[(prefix.Length + user.Length + 4)..];
@ -878,7 +878,7 @@ namespace MinecraftClient.Scripting
catch { return; /* Invalid file name or access denied */ }
}
File.AppendAllLines(logfile, new string[] { GetTimestamp() + ' ' + text });
File.AppendAllLines(logfile, [GetTimestamp() + ' ' + text]);
}
}
@ -898,7 +898,7 @@ namespace MinecraftClient.Scripting
catch { return; /* Invalid file name or access denied */ }
}
File.AppendAllLines(logfile, new string[] { GetTimestamp() + ' ' + text });
File.AppendAllLines(logfile, [GetTimestamp() + ' ' + text]);
}
}
@ -1218,7 +1218,7 @@ namespace MinecraftClient.Scripting
else
{
LogToConsole("File not found: " + Path.GetFullPath(file));
return Array.Empty<string>();
return [];
}
}