Get players uuid and get a player from the uuid

Discussion in 'Resources' started by xXMaTTHDXx, Apr 3, 2014.

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


    Hey, just in case others are having some problems with the new UUID changes I thought I would make a very simple resource, please do not hate it may not be the best but it is simple.

    1. // to get a players uuid use the player value you created and do as show below:
    3. String uuid = player.getUniqueId().toString(); //toString() just so we could log it if needed.
    5. // to get a players name from the uuid above do as shown:
    7. Player fromUUID = Bukkit.getServer().getPlayer(UUID.fromString(uuid));
    9. fromUUID.getName(); // just get there name

    This is not ment to be something you can copy paste, just a really quick reference.
    Dpasi314, JasonDL13 and ibJarrett like this.
  2. Offline


    Why store it as a String rather than a UUID, you can just do System.out.println(uuid); to log it and it will call the toString method for you, or if you really wanted to System.out.println(uuid.toString());
    CraftThatBlock likes this.
  3. Offline


    While I agree with your point, some portability and code standards frown upon the use of implicit #toString() invocations.

    That being said, you're right: processing power is wasted by using a string rather than UUID instance, String uses more RAM than a UUID and there's processing time being wasted by going from UUID to String and back again for literally no reason.
Thread Status:
Not open for further replies.

Share This Page