mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Enhance server status display and player information handling
- Updated `ServerStatusDisplay` to use `ChatBot.GetVerbatim` for version name formatting. - Modified `ServerStatusPanelBuilder` to improve player name display with color parsing. - Changed translation for online player label to "Online Players:" for clarity. - Refactored protocol version checks to streamline logic in server status handling.
This commit is contained in:
parent
b25579a105
commit
90ea05b17d
3 changed files with 17 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using MinecraftClient.Protocol.Message;
|
||||
using MinecraftClient.Scripting;
|
||||
|
||||
namespace MinecraftClient.Protocol
|
||||
{
|
||||
|
|
@ -47,12 +48,12 @@ namespace MinecraftClient.Protocol
|
|||
sb.Append("§f");
|
||||
sb.Append(Translations.mcc_server_info_label_version);
|
||||
sb.Append(" §b");
|
||||
sb.Append(info.VersionName);
|
||||
sb.Append(ChatBot.GetVerbatim(info.VersionName));
|
||||
sb.Append(" §7(");
|
||||
sb.Append(string.Format(Translations.mcc_server_info_label_protocol, "§e" + info.ProtocolVersion + "§7"));
|
||||
sb.AppendLine(")");
|
||||
|
||||
if (info.ResolvedProtocol != 0 && info.ResolvedProtocol != info.ProtocolVersion)
|
||||
if (info.ResolvedProtocol != 0)
|
||||
{
|
||||
string resolvedMcVer = ProtocolHandler.ProtocolVersion2MCVer(info.ResolvedProtocol);
|
||||
sb.Append("§f");
|
||||
|
|
|
|||
|
|
@ -852,7 +852,7 @@ Add the ID of this chat to "Authorized_Chat_Ids" field in the configuration file
|
|||
<value>Connecting as:</value>
|
||||
</data>
|
||||
<data name="mcc.server_info.label_online" xml:space="preserve">
|
||||
<value>Online:</value>
|
||||
<value>Online Players:</value>
|
||||
</data>
|
||||
<data name="mcc.server_info.sample_more" xml:space="preserve">
|
||||
<value>... +{0}</value>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ namespace MinecraftClient.Tui
|
|||
if (info.FaviconBase64 is not null)
|
||||
{
|
||||
var iconGrid = BuildFaviconGrid(info.FaviconBase64, FaviconDisplaySize);
|
||||
iconGrid.VerticalAlignment = VerticalAlignment.Center;
|
||||
DockPanel.SetDock(iconGrid, Dock.Left);
|
||||
contentPanel.Children.Add(iconGrid);
|
||||
}
|
||||
|
|
@ -83,9 +84,10 @@ namespace MinecraftClient.Tui
|
|||
|
||||
private static void AddVersion(StackPanel panel, Protocol.ServerStatusInfo info)
|
||||
{
|
||||
string versionClean = Scripting.ChatBot.GetVerbatim(info.VersionName);
|
||||
var row = new TextBlock();
|
||||
row.Inlines!.Add(Label(Translations.mcc_server_info_label_version));
|
||||
row.Inlines.Add(Value(info.VersionName, McColors.Aqua));
|
||||
row.Inlines.Add(Value(versionClean, McColors.Aqua));
|
||||
row.Inlines.Add(new Run(" (") { Foreground = McColors.Gray });
|
||||
row.Inlines.Add(new Run(string.Format(Translations.mcc_server_info_label_protocol, info.ProtocolVersion))
|
||||
{ Foreground = McColors.Gray });
|
||||
|
|
@ -95,7 +97,7 @@ namespace MinecraftClient.Tui
|
|||
|
||||
private static void AddConnectingAs(StackPanel panel, Protocol.ServerStatusInfo info)
|
||||
{
|
||||
if (info.ResolvedProtocol == 0 || info.ResolvedProtocol == info.ProtocolVersion)
|
||||
if (info.ResolvedProtocol == 0)
|
||||
return;
|
||||
|
||||
string resolvedMcVer = Protocol.ProtocolHandler.ProtocolVersion2MCVer(info.ResolvedProtocol);
|
||||
|
|
@ -146,17 +148,20 @@ namespace MinecraftClient.Tui
|
|||
{
|
||||
Text = Translations.mcc_server_info_label_online,
|
||||
Foreground = McColors.Gray,
|
||||
Margin = new Thickness(0, 1, 0, 0),
|
||||
});
|
||||
|
||||
int shown = Math.Min(info.SamplePlayers.Count, MaxSamplePlayers);
|
||||
for (int i = 0; i < shown; i++)
|
||||
{
|
||||
panel.Children.Add(new TextBlock
|
||||
{
|
||||
Text = $" {info.SamplePlayers[i].Name}",
|
||||
Foreground = McColors.Green,
|
||||
});
|
||||
string name = info.SamplePlayers[i].Name;
|
||||
if (name.Contains('\u00a7'))
|
||||
panel.Children.Add(McColorParser.CreateColoredTextBlock($" {name}", TextWrapping.NoWrap));
|
||||
else
|
||||
panel.Children.Add(new TextBlock
|
||||
{
|
||||
Text = $" {name}",
|
||||
Foreground = McColors.Green,
|
||||
});
|
||||
}
|
||||
|
||||
if (info.SamplePlayers.Count > shown)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue