Solved Get unused player UUIDs

Discussion in 'Plugin Development' started by Excel8392, Apr 7, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Excel8392

    Is there any way that I can retrieve a UUID which isn't in use? As in a UUID with no player attached to it.
    Is there any sort of range that isn't used? How are the minecraft UUIDs assigned?

    Broader explanation of my issue: I am creating a simple NPCs plugin, and currently each NPC was assigned a UUID which looks like this: 00000000-0000-0000-0000-000000000000. While testing using spigot, it works 100%. However, for the project I am working on we are going to be using paper, and paper has this odd thing where it will automatically remove any two EntityPlayers with an identical ID. So I am looking for a way to keep it so that they don't get assigned UUIDs that someone might actually use.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Excel8392 Don't think that you can besides using a random one.
     
  3. Offline

    Excel8392

    I guess I could choose a random one, then check with the minecraft API to see if it is in-use, if it is then choose another.
     
  4. Offline

    timtower Administrator Administrator Moderator

    Problem with that is that a player could buy the game and a new one gets handed out.
     
  5. Offline

    KarimAKL

    @Excel8392 To decrease the chance of it happening, i think you could loop the offline players, and then check if the UUID is used, then set a new random one. I'm not sure it's worth the performance downgrade though.
     
  6. Offline

    Excel8392

    That is true but I don't think I can avoid that easily, so found a solution good enough for me: I save all the UUIDs which I use to a config, and before saving make sure that they aren't in use, if they are then get a new one. Then on server startup I check again, I any of them are now in use then I swap them out.

    I'll mark this as solved, seeing as I have found a solution good enough for now.
     
Thread Status:
Not open for further replies.

Share This Page