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
This commit is contained in:
copilot-swe-agent[bot] 2026-03-23 00:13:03 +00:00
parent 8743129e72
commit 02686de79c
3 changed files with 106 additions and 34 deletions

View file

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

View file

@ -979,6 +979,42 @@ namespace MinecraftClient {
}
}
/// <summary>
/// Looks up a localized string similar to Show the player coordinates in the Discord presence..
/// </summary>
internal static string ChatBot_DiscordRpc_ShowCoordinates {
get {
return ResourceManager.GetString("ChatBot.DiscordRpc.ShowCoordinates", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show health and food level in the Discord presence..
/// </summary>
internal static string ChatBot_DiscordRpc_ShowHealth {
get {
return ResourceManager.GetString("ChatBot.DiscordRpc.ShowHealth", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show the current dimension in the Discord presence..
/// </summary>
internal static string ChatBot_DiscordRpc_ShowDimension {
get {
return ResourceManager.GetString("ChatBot.DiscordRpc.ShowDimension", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show the current gamemode in the Discord presence..
/// </summary>
internal static string ChatBot_DiscordRpc_ShowGamemode {
get {
return ResourceManager.GetString("ChatBot.DiscordRpc.ShowGamemode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show elapsed session time in the Discord presence..
/// </summary>

View file

@ -853,7 +853,19 @@ If the connection to the Minecraft game server is blocked by the firewall, set E
<value>Tooltip text for the small image. Supports placeholders.</value>
</data>
<data name="ChatBot.DiscordRpc.ShowServerAddress" xml:space="preserve">
<value>Show the server address (host and port) in the Discord presence. When disabled, {server_host} and {server_port} are masked for privacy.</value>
<value>Show the server address (host and port) in the Discord presence. When disabled, {server_host} and {server_port} are masked.</value>
</data>
<data name="ChatBot.DiscordRpc.ShowCoordinates" xml:space="preserve">
<value>Show the player coordinates in the Discord presence. When disabled, {x}, {y}, {z} are masked.</value>
</data>
<data name="ChatBot.DiscordRpc.ShowHealth" xml:space="preserve">
<value>Show health and food level in the Discord presence. When disabled, {health}, {max_health}, {food} are masked.</value>
</data>
<data name="ChatBot.DiscordRpc.ShowDimension" xml:space="preserve">
<value>Show the current dimension in the Discord presence. When disabled, {dimension} is masked.</value>
</data>
<data name="ChatBot.DiscordRpc.ShowGamemode" xml:space="preserve">
<value>Show the current gamemode in the Discord presence. When disabled, {gamemode} is masked.</value>
</data>
<data name="ChatBot.DiscordRpc.ShowElapsedTime" xml:space="preserve">
<value>Show elapsed session time in the Discord presence.</value>