Skip to content

fix: reset nickname when player changes Minecraft account name#6470

Open
hudsonandres wants to merge 1 commit intoEssentialsX:2.xfrom
hudsonandres:nickname
Open

fix: reset nickname when player changes Minecraft account name#6470
hudsonandres wants to merge 1 commit intoEssentialsX:2.xfrom
hudsonandres:nickname

Conversation

@hudsonandres
Copy link

Information

This PR fixes #6469.

Details

Proposed fix:

When a premium player changes their Minecraft username, any previously set nickname (including RGB-formatted ones) is now automatically cleared on their next login, equivalent to running /nick off.

Environments tested:

OS: Linux
Java version: OpenJDK 21.0.7

Bukkit Version - Purpur 1.21.11-R0.1-SNAPSHOT

Demonstration:

Before: No log to show
After: No log to show

- When a premium player changes their Minecraft username, any previously
set nickname (including RGB-formatted ones) is now automatically cleared
on their next login, equivalent to running /nick off.
@hudsonandres
Copy link
Author

How it works:

Every time a player joins, the code already compares lastAccountName (the name stored from their last login) with the current Minecraft account name.

If they differ, meaning the player changed their Minecraft username - and the player has a nickname set, setNickname(null) is called to remove it (equivalent to /nick off).

The subsequent user.setDisplayNick() call then updates their display name to the bare new account name.
This way, RGB-colored or any other nicknames tied to the old account name are automatically cleared when the player first joins after a name change.

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.

The nickname does not change or reset if the original account name is changed.

1 participant