From 02686de79c85e5f9362ae2e910f51116ef662e97 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 00:13:03 +0000 Subject: [PATCH] Add granular privacy controls: ShowCoordinates, ShowHealth, ShowDimension, ShowGamemode Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com> Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/43388021-4264-47e6-8403-7a1bca66d86f --- MinecraftClient/ChatBots/DiscordRpc.cs | 90 ++++++++++++------- .../ConfigComments/ConfigComments.Designer.cs | 36 ++++++++ .../ConfigComments/ConfigComments.resx | 14 ++- 3 files changed, 106 insertions(+), 34 deletions(-) diff --git a/MinecraftClient/ChatBots/DiscordRpc.cs b/MinecraftClient/ChatBots/DiscordRpc.cs index 3daa3ef4..6e5c60cb 100644 --- a/MinecraftClient/ChatBots/DiscordRpc.cs +++ b/MinecraftClient/ChatBots/DiscordRpc.cs @@ -49,6 +49,18 @@ namespace MinecraftClient.ChatBots [TomlInlineComment("$ChatBot.DiscordRpc.ShowServerAddress$")] public bool ShowServerAddress = true; + [TomlInlineComment("$ChatBot.DiscordRpc.ShowCoordinates$")] + public bool ShowCoordinates = true; + + [TomlInlineComment("$ChatBot.DiscordRpc.ShowHealth$")] + public bool ShowHealth = true; + + [TomlInlineComment("$ChatBot.DiscordRpc.ShowDimension$")] + public bool ShowDimension = true; + + [TomlInlineComment("$ChatBot.DiscordRpc.ShowGamemode$")] + public bool ShowGamemode = true; + [TomlInlineComment("$ChatBot.DiscordRpc.ShowElapsedTime$")] public bool ShowElapsedTime = true; @@ -254,50 +266,62 @@ namespace MinecraftClient.ChatBots int gamemode = GetGamemode(); int protocolVersion = GetProtocolVersion(); - string dimensionName = "Unknown"; - try + string healthStr = Config.ShowHealth ? ((int)Math.Ceiling(health)).ToString() : "?"; + string maxHealthStr = Config.ShowHealth ? "20" : "?"; + string foodStr = Config.ShowHealth ? foodLevel.ToString() : "?"; + string xStr = Config.ShowCoordinates ? ((int)location.X).ToString() : "?"; + string yStr = Config.ShowCoordinates ? ((int)location.Y).ToString() : "?"; + string zStr = Config.ShowCoordinates ? ((int)location.Z).ToString() : "?"; + + string dimensionName = Config.ShowDimension ? "Unknown" : "Hidden"; + if (Config.ShowDimension) { - var dim = World.GetDimension(); - dimensionName = dim.Name ?? "Unknown"; - - // Clean up the dimension name for display - if (dimensionName.StartsWith("minecraft:")) - dimensionName = dimensionName["minecraft:".Length..]; - - dimensionName = dimensionName switch + try { - "overworld" => "Overworld", - "the_nether" => "The Nether", - "the_end" => "The End", - _ => dimensionName - }; - } - catch - { - // World may not be available + var dim = World.GetDimension(); + dimensionName = dim.Name ?? "Unknown"; + + // Clean up the dimension name for display + if (dimensionName.StartsWith("minecraft:")) + dimensionName = dimensionName["minecraft:".Length..]; + + dimensionName = dimensionName switch + { + "overworld" => "Overworld", + "the_nether" => "The Nether", + "the_end" => "The End", + _ => dimensionName + }; + } + catch + { + // World may not be available + } } - string gamemodeStr = gamemode switch - { - 0 => "Survival", - 1 => "Creative", - 2 => "Adventure", - 3 => "Spectator", - _ => "Unknown" - }; + string gamemodeStr = Config.ShowGamemode + ? gamemode switch + { + 0 => "Survival", + 1 => "Creative", + 2 => "Adventure", + 3 => "Spectator", + _ => "Unknown" + } + : "Hidden"; return template .Replace("{server_host}", serverHost) .Replace("{server_port}", serverPortStr) .Replace("{username}", username) - .Replace("{health}", ((int)Math.Ceiling(health)).ToString()) - .Replace("{max_health}", "20") - .Replace("{food}", foodLevel.ToString()) + .Replace("{health}", healthStr) + .Replace("{max_health}", maxHealthStr) + .Replace("{food}", foodStr) .Replace("{dimension}", dimensionName) .Replace("{gamemode}", gamemodeStr) - .Replace("{x}", ((int)location.X).ToString()) - .Replace("{y}", ((int)location.Y).ToString()) - .Replace("{z}", ((int)location.Z).ToString()) + .Replace("{x}", xStr) + .Replace("{y}", yStr) + .Replace("{z}", zStr) .Replace("{player_count}", onlinePlayers.Length.ToString()) .Replace("{protocol}", protocolVersion.ToString()); } diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs index 0caddf01..cd3a09a5 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs @@ -979,6 +979,42 @@ namespace MinecraftClient { } } + /// + /// Looks up a localized string similar to Show the player coordinates in the Discord presence.. + /// + internal static string ChatBot_DiscordRpc_ShowCoordinates { + get { + return ResourceManager.GetString("ChatBot.DiscordRpc.ShowCoordinates", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show health and food level in the Discord presence.. + /// + internal static string ChatBot_DiscordRpc_ShowHealth { + get { + return ResourceManager.GetString("ChatBot.DiscordRpc.ShowHealth", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show the current dimension in the Discord presence.. + /// + internal static string ChatBot_DiscordRpc_ShowDimension { + get { + return ResourceManager.GetString("ChatBot.DiscordRpc.ShowDimension", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show the current gamemode in the Discord presence.. + /// + internal static string ChatBot_DiscordRpc_ShowGamemode { + get { + return ResourceManager.GetString("ChatBot.DiscordRpc.ShowGamemode", resourceCulture); + } + } + /// /// Looks up a localized string similar to Show elapsed session time in the Discord presence.. /// diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx index 2039e499..b68844fa 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx @@ -853,7 +853,19 @@ If the connection to the Minecraft game server is blocked by the firewall, set E Tooltip text for the small image. Supports placeholders. - Show the server address (host and port) in the Discord presence. When disabled, {server_host} and {server_port} are masked for privacy. + Show the server address (host and port) in the Discord presence. When disabled, {server_host} and {server_port} are masked. + + + Show the player coordinates in the Discord presence. When disabled, {x}, {y}, {z} are masked. + + + Show health and food level in the Discord presence. When disabled, {health}, {max_health}, {food} are masked. + + + Show the current dimension in the Discord presence. When disabled, {dimension} is masked. + + + Show the current gamemode in the Discord presence. When disabled, {gamemode} is masked. Show elapsed session time in the Discord presence.