Tip
- **`%username%`, `%serverip%`, `%datetime%` are reserved variables**
+ **`%username%`, `%login%`, `%serverip%`, `%serverport%`, `%datetime%`, `%players%` are reserved read-only variables**
diff --git a/docs/guide/creating-text-script.md b/docs/guide/creating-text-script.md
index 7b5178be..9ae2a6fb 100644
--- a/docs/guide/creating-text-script.md
+++ b/docs/guide/creating-text-script.md
@@ -6,7 +6,7 @@ title: Creating Simple Script
A simple script is a text file with one command per line. See the [Internal Commands](usage.md#internal-commands) section, or type `/help` in the console to see the available commands. Any line beginning with `#` is ignored and treated as a comment.
-Application variables defined with the `set` command or in the `[AppVars]` config section can be used. The following read-only variables are also available: `%username%`, `%login%`, `%serverip%`, `%serverport%`, `%datetime%`.
+Application variables defined with the `set` command or in the `[AppVars]` config section can be used. The following read-only variables are also available: `%username%`, `%login%`, `%serverip%`, `%serverport%`, `%datetime%`, `%players%` (`%players%` expands to the current online player names separated by commas).
## Example
From c9f1f88e6257749d36437ff2d8427565672d90ad Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 24 Mar 2026 19:48:48 +0000
Subject: [PATCH 06/10] refine sample http client usage
Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/9bf31c0e-e47b-4654-be10-6ea50f27a581
---
MinecraftClient/config/sample-script-with-http-request.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/MinecraftClient/config/sample-script-with-http-request.cs b/MinecraftClient/config/sample-script-with-http-request.cs
index a281540b..60e6d27d 100644
--- a/MinecraftClient/config/sample-script-with-http-request.cs
+++ b/MinecraftClient/config/sample-script-with-http-request.cs
@@ -5,18 +5,18 @@ MCC.LogToConsole(mojangStatus);
//MCCScript Extensions
+private static readonly System.Net.Http.HttpClient s_httpClient = new();
+
string PerformHttpRequest(string uri)
{
- using var httpClient = new System.Net.Http.HttpClient();
- return httpClient.GetStringAsync(uri).GetAwaiter().GetResult();
+ return s_httpClient.GetStringAsync(uri).GetAwaiter().GetResult();
}
void SendHttpPostAsync(string uri, string text)
{
new Thread(() => {
- using var httpClient = new System.Net.Http.HttpClient();
using var content = new System.Net.Http.StringContent(text, System.Text.Encoding.UTF8, "text/plain");
- using var response = httpClient.PostAsync(uri, content).GetAwaiter().GetResult();
+ using var response = s_httpClient.PostAsync(uri, content).GetAwaiter().GetResult();
string responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
//LogToConsole(responseString);
}).Start();
From 461be9f36876d3d23534d057189de33ed7197b00 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 24 Mar 2026 19:51:46 +0000
Subject: [PATCH 07/10] docs: clarify players app var behavior
Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/c9f7aa87-50b7-4725-aa39-613eba1a07fd
---
MinecraftClient/Settings.cs | 4 ++--
docs/guide/creating-text-script.md | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs
index a956e1df..0c25adb8 100644
--- a/MinecraftClient/Settings.cs
+++ b/MinecraftClient/Settings.cs
@@ -1174,10 +1174,10 @@ namespace MinecraftClient
string varname = var_name.ToString();
string varname_lower = Settings.ToLowerIfNeed(varname);
i = i + varname.Length + 1;
-
+
if (TryGetReadOnlyVar(varname_lower, out object? readOnlyVar))
{
- result.Append(readOnlyVar?.ToString());
+ result.Append(readOnlyVar.ToString());
}
else if (localVars is not null && localVars.ContainsKey(varname_lower))
{
diff --git a/docs/guide/creating-text-script.md b/docs/guide/creating-text-script.md
index 9ae2a6fb..ff07b67d 100644
--- a/docs/guide/creating-text-script.md
+++ b/docs/guide/creating-text-script.md
@@ -6,7 +6,7 @@ title: Creating Simple Script
A simple script is a text file with one command per line. See the [Internal Commands](usage.md#internal-commands) section, or type `/help` in the console to see the available commands. Any line beginning with `#` is ignored and treated as a comment.
-Application variables defined with the `set` command or in the `[AppVars]` config section can be used. The following read-only variables are also available: `%username%`, `%login%`, `%serverip%`, `%serverport%`, `%datetime%`, `%players%` (`%players%` expands to the current online player names separated by commas).
+Application variables defined with the `set` command or in the `[AppVars]` config section can be used. The following read-only variables are also available: `%username%`, `%login%`, `%serverip%`, `%serverport%`, `%datetime%`, `%players%` (`%players%` expands to the current online player names separated by commas, or an empty string when not connected).
## Example
From 8ab9f8505fa3ca29f95f37820708ac3cbf678596 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 24 Mar 2026 19:58:58 +0000
Subject: [PATCH 08/10] Fix crash when scoreboard is updated on MC 1.20.4+
ChatParser.NbtToString crashed with InvalidCastException when a scoreboard
update was received. The switch expressions for extra/with NBT arrays only
handled int and string; everything else fell through to a hard cast to
Dictionary