Theoretical scenario, how does Sponge behave (namechange related)

A question about what theoretically happens with sponge in a particular (though potentially extremely rare) series of events involving namechanges. Assume 4-character UUIDs in example:

In Feb and March, two players join the same server, and both are active members until April: “JohnDaBomb” (uuid=‘abcd’) and “JohnWussman” (uuid=‘f8f8’)

At the start of May, “abcd” changes his name on mojang to “LuckyStreaker7”, and does NOT return to the server after having changed his name.

In June, ‘f8f8’ sees that ‘JohnDaBomb’ is on the available list of names, and even though (or because, if he hopes to stir trouble) he remembers playing with that guy on the server before, he really wants that name. So now ‘f8f8’ is ‘JohnDaBomb’

In late June, ‘f8f8’ returns to the server to resume playing. Clearly everything still remains his since his uuid hasn’t changed, thats not a concern.

In this scenario, the gameserver has two player-uuid.dat files and info, ‘abcd’ and ‘f8f8’ , both which state that they are for a player named ‘JohnDaBomb’ as of last-login.

When searching the Sponge User store for “JohnDaBomb” to return a user profile ie UserStorageService#get(String lastKnownName) to get an online or offline player, what happens here?
Does Sponge find two ‘last known as’ “JohnDaBomb” names within these two uuid-files, and then in that case of more-than-one, look at the last login date to determine the ‘latest’ one for that name? Or would it totally crap out since more than one User would be returned, or does it return just the FIRST one that it encounters in the store, which may or may not be the active player? Does minecraft /sponge itself know internally to invalidate the name for ‘abcd’ and only associate it with ‘f8f8’ ??

The Sponge methods only return a single Optional {User}

Minecraft (and by extension, Sponge) has a file stored in the root directory usercache.json

This file stores a cache of UUID/Name lookups (can lookup either direction). Each entry has an expiresOn key which is a date that the entry must be invalidated by. It will call the Mojang API for unknown or expired names.

1 Like