[LIB] Converts from UUID to PlayerName and from PlayerName to UUID

Discussion in 'Resources' started by BananaBitchs, Aug 25, 2014.

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

    BananaBitchs

    Hello everyone I BananaBitchs, I'm here to teach you how to change from PlayerName to UUID and from UUID to PlayerName I have also some examples to you I hope this will be helpfuly for you guys

    Code:java
    1. import java.io.BufferedReader;
    2. import java.io.InputStreamReader;
    3. import java.net.URL;
    4. import java.util.UUID;
    5.  
    6. public class UUIDApi {
    7. public static String getName(String UUID) {
    8. try {
    9. URL url = new URL("[url]https://api.mojang.com/user/profiles/[/url]"+ UUID.replaceAll("-", "") + "/names");
    10. BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    11. String line = in.readLine();
    12. line = line.replace("[\"", "");
    13. line = line.replace("\"]", "");
    14. return line;
    15. } catch (Exception ex) {
    16. ex.printStackTrace();
    17. }
    18. return null;
    19. }
    20.  
    21. public static String getUUIDs(String player) {
    22. try {
    23. URL url = new URL("[url]https://api.mojang.com/users/profiles/minecraft/[/url]" + player);
    24. BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    25. while ((Line = in.readLine()) != null) {
    26. String uuid = Line.substring(7, 39);
    27. return uuid.substring(0, 8) + "-" + uuid.substring(8, 12) + "-"
    28. + uuid.substring(12, 16) + "-" + uuid.substring(16, 20)
    29. + "-" + uuid.substring(20, 32);
    30. }
    31. in.close();
    32. } catch (Exception ex) {
    33. ex.printStackTrace();
    34. }
    35. return null;
    36. }
    37. public static String getName(UUID uuid) {
    38. return getName(uuid.toString());
    39. }
    40. public static String getUUID(String player) {
    41. String strUUID = getUUIDs(player);
    42. return strUUID;
    43. }
    44.  
    45. }


    Its Convert the player name to UUID and from UUID to player name
    here is some examples:

    Code:java
    1. String UUID = UUIDApi.getUUID("BananaBitchs");
    2. player.sendMessage("UUID: "+ UUID);
    3.  
    4. String Name = UUIDApi.getName(UUID);
    5. player.sendMessage("Name - > "+Name);


    Enjoy!
    Do you need help?, Send me a Private Message with your Problem and ill try to help my best i can!
    :)
     
  2. Offline

    xTrollxDudex

    What makes this different from all the other ones
     
  3. Offline

    Onlineids

    xTrollxDudex likes this.
  4. Offline

    xTrollxDudex

    Blatantly obvious

    Onlineids xTrollxDudex
    Awesome username

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 5, 2022
Thread Status:
Not open for further replies.

Share This Page