Advertisement
minimite

uuid

Oct 26th, 2014
1,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. --Minecraft UUID Api for ComputerCraft, a minecraft mod, written in lua
  2. --By minimite
  3.  
  4.  
  5. function get(username)
  6. local html = http.get("https://api.mojang.com/users/profiles/minecraft/"..username.."")
  7. local read = html.readAll()
  8. local read = read:gsub("{","")
  9. local read = read:gsub("}","")
  10. local read = read:gsub('"',"")
  11. local read = read:gsub(",","\n")
  12. local read = read:gsub("id:","")
  13. local read = read:gsub("name:","name: ")
  14. local read = read:gsub("\nname: [^\n]*","")
  15. local read = read:gsub("\nlegacy:true[^\n]*","")
  16. if read == "" then
  17. return nil
  18. end
  19. return read
  20. end
  21.  
  22. function random(template)
  23. local random = math.random
  24. local template = template or "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx"
  25. return string.gsub(template, "[xy]", function (c)
  26. local v = (c == "x") and random(0, 0xf) or random (8, 0xb)
  27. return string.format("%x",v)
  28. end)
  29. end
  30.  
  31. function names(uuid)
  32. local web = http.get("https://api.mojang.com/user/profiles/"..uuid.."/names")
  33. local all = web.readAll()
  34.  
  35. if all == "" then
  36. return nil
  37. else
  38. return all
  39. end
  40.  
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement