Skip to content

fix: hydratation warnings - #109

Merged
Flash303 merged 4 commits into
mainfrom
dev
Oct 14, 2026
Merged

Flash303 merged 4 commits into
mainfrom
dev

Conversation

@Flash303

Copy link
Copy Markdown
Owner

This pull request introduces a more robust and reliable way to display Minecraft server versions by prioritizing the use of protocol numbers (which are trustworthy and not user-controlled) when the version string is missing or custom. It also ensures that only valid, displayable versions are shown in the UI, and never raw or potentially misleading custom version strings. Additionally, it adds a scheduled GitHub Action to keep the protocol mapping up to date automatically.

Key changes include:

Version resolution logic

  • Added a new resolveServerVersion utility in utils.ts that first tries to parse the declared version string, and if that fails (e.g., custom or missing version), falls back to resolving the version from the protocol number using a new mapping. This ensures that only valid, displayable versions are shown, and never arbitrary user-controlled strings. [1] [2]
  • Updated all UI components (ServerCard, ServerDetailHeader, ServersTab) to use resolveServerVersion instead of directly displaying the raw version string, ensuring consistent and safe version display across the app. [1] [2] [3] [4] [5] [6] [7] [8]

Protocol mapping and update automation

  • Added a new minecraft-protocols.ts file containing a vendored, auto-generated mapping from Java protocol numbers to displayable Minecraft versions, along with a utility to resolve protocol numbers to versions. This mapping is kept deterministic and avoids runtime network fetches.
  • Introduced a GitHub Actions workflow (update-protocols.yml) that automatically regenerates this protocol mapping from the upstream PrismarineJS data every week and opens a PR if there are changes, ensuring the mapping stays current.
  • Added a corresponding npm script update:protocols to facilitate local updates.

Testing and reliability

  • Added comprehensive tests for the new version resolution logic, covering edge cases like custom version names, protocol fallbacks, and Bedrock servers.

UI consistency and fidelity

  • Ensured that when a server is in maintenance or otherwise has a sentinel protocol number, the UI faithfully reproduces the Minecraft client’s behavior by displaying the raw server version string in the player count area, but never as a version badge. [1] [2]

These changes make the version display logic more robust, secure, and maintainable, while also automating protocol mapping updates to reduce manual maintenance.

@Flash303
Flash303 merged commit b2204c4 into main Oct 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant