From a2ff094369c8731ec4371065423691de3227f31d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:30:26 +0000 Subject: [PATCH 1/3] Initial plan From 802cc696d6097408267e8c14ca8fa2591600e66a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 19:44:05 +0000 Subject: [PATCH 2/3] fix sample http request script on latest runtime 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 --- .../Scripting/DynamicRun/Builder/Compiler.cs | 4 +++- .../config/sample-script-with-http-request.cs | 23 +++++-------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs b/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs index 2207bad8..2b201d0b 100644 --- a/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs +++ b/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs @@ -132,6 +132,8 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder // Facade assemblies needed for compiling scripts that reference netstandard libraries (e.g. Brigadier.NET) assemblyrefs.Add(new("netstandard")); assemblyrefs.Add(new("System.Runtime")); + assemblyrefs.Add(new("System.Private.Uri")); + assemblyrefs.Add(new("System.Net.Requests")); foreach (var refs in assemblyrefs) { Assembly? loadedAssembly; @@ -180,7 +182,7 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder // Add facade assemblies needed for Roslyn compilation when referencing // libraries that target netstandard (e.g. Brigadier.NET). var runtimeDir = Path.GetDirectoryName(SystemPrivateCoreLib)!; - foreach (var facadeName in new[] { "netstandard.dll", "System.Runtime.dll" }) + foreach (var facadeName in new[] { "netstandard.dll", "System.Runtime.dll", "System.Private.Uri.dll", "System.Net.Requests.dll" }) { var facadePath = Path.Combine(runtimeDir, facadeName); if (File.Exists(facadePath)) diff --git a/MinecraftClient/config/sample-script-with-http-request.cs b/MinecraftClient/config/sample-script-with-http-request.cs index 9b24fe34..a281540b 100644 --- a/MinecraftClient/config/sample-script-with-http-request.cs +++ b/MinecraftClient/config/sample-script-with-http-request.cs @@ -7,28 +7,17 @@ MCC.LogToConsole(mojangStatus); string PerformHttpRequest(string uri) { - var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); - var response = (System.Net.HttpWebResponse)request.GetResponse(); - string responseString; - using (var stream = response.GetResponseStream()) - using (var reader = new StreamReader(stream)) - responseString = reader.ReadToEnd(); - return responseString; + using var httpClient = new System.Net.Http.HttpClient(); + return httpClient.GetStringAsync(uri).GetAwaiter().GetResult(); } void SendHttpPostAsync(string uri, string text) { new Thread(() => { - var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); - request.ContentType = "text/plain"; - request.Method = "POST"; - using (var streamWriter = new StreamWriter(request.GetRequestStream())) - streamWriter.Write(text); - var response = (System.Net.HttpWebResponse)request.GetResponse(); - string responseString; - using (var stream = response.GetResponseStream()) - using (var reader = new StreamReader(stream)) - responseString = reader.ReadToEnd(); + 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(); + string responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); //LogToConsole(responseString); }).Start(); } 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 3/3] 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();