Skip to content

Conversation

@ChernegaSergiy
Copy link
Contributor

This pull request fixes a critical crash that occurs when trying to view information about an offline player or a player whose session is not properly loaded. It also fixes the root cause of incorrect session creation from user input in forms.

The Problem

  1. Crash on Offline Player: The code would crash with a "Call to a member function getDisplayName() on null" error when trying to generate a nametag for an offline player, as the player object was null.
  2. Incorrect Session Creation: When entering a player's name in the user management form, a new, empty session was being created if the input string had trailing spaces or different capitalization. This also led to the same crash, even for online players.

The Solution

This PR introduces a multi-level fix:

  • TagManager.php: A safety check has been added to the display_name tag. It now verifies if the player object is null and falls back to the user's name, preventing any crashes.
  • UserManageForm.php: The user input for the nickname is now sanitized with trim() to remove any leading or trailing whitespace.
  • SessionManager.php: The session lookup logic has been improved to be case-insensitive. If an exact match for a session is not found, it performs a case-insensitive search before creating a new session.

These changes together make the player information forms more robust, prevent crashes, and ensure that the correct user session is always found.

@ChernegaSergiy ChernegaSergiy changed the title fix(session): fix crash when handling offline players and user input Fix crash when handling offline players and user input Aug 15, 2025
@IvanCraft623
Copy link
Owner

Hi, thanks for your contribution! However current RankSystem design is to be case sensitive and about display_name crash has been already handled upstream.

The actual solution to be able to handle offline request and a lot more other issues is changing player's identifiers from name to xuid/uuid. But this is really complicated to archive since will need a migration system and some map name => xuid/uuid

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.

2 participants