Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
944
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.net.URL;
  7.  
  8. public class UUIDFetcher {
  9.    
  10.     /**
  11.     *  
  12.     * UUID Fetcher v.2.0 by Max_Plays (02/14/2016)
  13.     *
  14.     * You may:
  15.     * - Use this class in your project
  16.     * - Share it only with your friends
  17.     *
  18.     * You may not:
  19.     * - Re-upload it on the internet
  20.     * - Pretend it belongs to you
  21.     * - Delete this note
  22.     *
  23.     */
  24.    
  25.     public static String getUUID(String playerName){
  26.         String uuid = "";
  27.        
  28.         try{
  29.         URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName + "?");
  30.        
  31.         BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
  32.         String line = reader.readLine();
  33.        
  34.         String[] id = line.split(",");
  35.        
  36.         uuid = id[0];
  37.         uuid = uuid.substring(7, 39);
  38.        
  39.         }catch(IOException e){
  40.             e.printStackTrace();
  41.         }
  42.         return uuid;
  43.    
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement