fix: reset nickname when player changes Minecraft account name by hudsonandres · Pull Request #6470 · EssentialsX/Essentials

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.