Skip to content

[Minecraft] Duplication of names in Minecraft #1288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
Mx772 opened this issue Feb 2, 2025 · 8 comments
Open
3 tasks done

[Minecraft] Duplication of names in Minecraft #1288

Mx772 opened this issue Feb 2, 2025 · 8 comments
Labels

Comments

@Mx772
Copy link

Mx772 commented Feb 2, 2025

Operating System

Debian 12

AMP Version and Build Date

2.6.0.10 - 30/01/2025

AMP Release Stream

Mainline

I confirm that

  • I have searched for an existing bug report for this issue.
  • I am using the latest available version of AMP.
  • my operating system is up-to-date.

Intended Action

Minecraft users are not duplicated.

Expected Behaviour

Minecraft usernames in analytics/online users are unique and should only include their actual minecraft username.

Actual Behaviour

Minecraft user's are duplicated in Analytics and online when using any type of nickname/name modifier such as ranks.

Image
Image

We can see that the user christrot here is being counted as his 'normal' username, as well as every rank they've ever been.

Reproduction

Spin up minecraft and use any type of nickname/name modifier such as FTBRanks, etc.

@Mx772 Mx772 added the bug label Feb 2, 2025
@IceOfWraith
Copy link
Collaborator

Can you share the log lines where the user joined and it was duplicated?

@Mx772
Copy link
Author

Mx772 commented Feb 2, 2025

Suggestion:

All minecraft servers should have a 'usernamecache.json' that has the format:

{
  "211435b0-xxxx-xxxx-xxxx-e463f7eb64b5": "Mx772",
  "b982df91-xxxx-xxxx-xxxx-33e8c71f4aa8": "christrot",
}

From this discord message:
https://discord.com/channels/266012086423912458/1334927858258411662/1334947803717177428

It's noted that the time starts from when a user joins. If we build upon that logic, we can use this to get their UUID, which will not change:

Sending Player Data to player literal{christrot} with UUID b982df91-xxxx-xxxx-xxxx-33e8c71f4aa8.

This will also use their minecraft username which is also unique. Either of these should be set as the source of truth, and build the analytics, online users list off of these.

Additionally, as suggested in the thread, adding a space between the rank and username just results in christrot: with an extra : at the end which is used so ingame there is some separation. Removing the : does workaround it though...

@Mx772
Copy link
Author

Mx772 commented Feb 2, 2025

Can you share the log lines where the user joined and it was duplicated?

Guessing it's this line here:

christrot[IPADDR]: logged in with entity id 1379 at (242.43342283359968, 84.875, -4762.803403989056)
christrot: joined the game  <----

Note: This is after adding the space, but still having the : character.

@IceOfWraith
Copy link
Collaborator

Right click the instance and View Logs and get the log file from there and share it here.

@Mx772
Copy link
Author

Mx772 commented Feb 2, 2025

Right click the instance and View Logs and get the log file from there and share it here.

[03:43:31] [User Authenticator #23/INFO]: UUID of player christrot is b982df91-xxxx-xxxx-xxxx-33e8c71f4aa8
[03:43:37] [Server thread/INFO]: christrot[/IP]: logged in with entity id 348185 at (243.87488773009312, 84.0, -4763.499441768881)
[03:43:37] [Server thread/INFO]: [Player]christrot: joined the game
[03:43:37] [Server thread/INFO]: Sending Player Data to player literal{christrot} with UUID b982df91-xxxx-xxxx-xxxx-33e8c71f4aa8.

So yeah, looks like it changes the joining message. It's strange that it's duplicating it though, as the console user list has:

Image

But also a secondary user:

Image

@IceOfWraith
Copy link
Collaborator

Ugh... that mod is messy. Okay, I can work around this. Thanks!

@Mx772
Copy link
Author

Mx772 commented Feb 2, 2025

No problem! Yeah, I know I had some issues when I was doing analytics prior to amp implementing it.

My logic was basically gather the logic from the username cache and when they joined. (Because while mc collects the stats in one of the files, it's tick-based and if the server isn't running a full 20tps then the time can be wildly inaccurate.)

I basically just used the timestamp of the User Authenticated log which has their UUID and username and then build my stats on that regardless of their IGN. UUID being the db key so even if they changed their username on minecraft.net it'd just overwrite it in the stats.

When a player left or the server no longer responded [via health check] (Since that was an edge case I didn't catch originally) I'd just log that as a session.

[18:29:46] [Server thread/INFO]: christrot lost connection: Server closed
[18:29:46] [Server thread/INFO]: christrot: left the game

If you use the 'lost connection' log to indicate a leaving action, it always uses their unique-minecraft name to match it all back up, the left uses their ign which can be different.

@Mx772
Copy link
Author

Mx772 commented Feb 12, 2025

Just as a heads up to anyone who hits the same issue and wants to fix it for an existing server's analytics - Open the instance's root dir ex: /home/amp/.ampdata/instances/INSTANCE_NAME then use something like vsCode's SQLite3 Editor to edit the db entries.

I ran:

DELETE FROM `UserSession` WHERE (`Username` like "%:%")

as all my 'extra' users had : in their username, so I targeted that.

Since it's in the AMP profile with read-only perms, you can do something like cp /home/amp/.ampdata/instances/INSTANCE_NAME/datastore.dat /home/$USER/; sudo chmod 755 datastore.dat then edit it as needed. Then do a cp datastore.dat /home/amp/.ampdata/instances/INSTANCE_NAME/datastore.dat which seems to automatically fix permissions.

note: You'll want to stop your instance before doing this to avoid data loss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants