akon1248

Zombie Skin Generator

Feb 3rd, 2020
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. function getZombieSkin(p: player) :: object:
  2. set {_zombiegameprofile} to new WrappedGameProfile(new uuid, name of {_p})
  3. {_zombiegameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", "eyJ0aW1lc3RhbXAiOjE1NDQ0NTk4Mzc4MjMsInByb2ZpbGVJZCI6IjQzYTgzNzNkNjQyOTQ1MTBhOWFhYjMwZjViM2NlYmIzIiwicHJvZmlsZU5hbWUiOiJTa3VsbENsaWVudFNraW42Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZDY3NTUzYjMxOGJhMmVlMmI2MjZlOWI5ZGVkM2UxNWExZDBkOGQ5ZjM3MGZmMDNjOThiMzIzZTc4NTczYjlhIn19fQ==", "yUVWH96rIrYzOO4fCeB30pPSsdyaMJHwP0jKPfd+cfp5Bk5uOd5g547ISckhU0bZMWAkKqEeXUY3R1hsW3GJl+OKdTQwkKVhSdWf6AEV0LaTPav8TCd5jF2JVWDlGeXgHTp+TdBZPJIdWT1uuLuY42YdTfMGsywFE0rGljRo97hpMvBhgRcakw6d4friHUfzJy9shVeXW4gF8xZg79DP+WZ32F/IrsgoRU5O2nxM9ZgmjyaLTyO9WKQoMEpcLJl8vAet2NjJ1YH6klOxnqZpjYPebQuyfFb/ZfTfJv+AevccDCqr1T7OEM2u3MTwttcov5KbnhawrHZnVIBio2sTQGFUmzcsmIJht04YWGkQlrvSzQ4+6/Qyzixl4PE3pfbwg3truuJgItstLLbnNKFqa3H/RQam18vKdM8u7lqOomP4fWP4VEhBcIElnfwohy0PRJ+KOA5586WupKD3bxiAViUN4ywj212gyG6ie8KDDfrtC+e3VOWi/Vja+bJEmy2oHUndesySAZhNNMhrRIOYAARrhpcR0Cl8TmTVCYC4ooaKTdowi8cELLBxCnCJElozKUv2jhoWrpL4ZCSAepz85NdiQk2NjSNqgUOKzxf/pLD4iPs9R0+bVipyN8eGTpSzDdAQ4xO8n2nPQbcqfzqlIfY5hPF0S0+gApK68VXBGkA="))
  4. set {_gameprofile} to WrappedGameProfile.fromPlayer({_p})
  5. set {_property} to try {_gameprofile}.getProperties().get("textures").iterator().next()
  6. if {_property} is set:
  7. set {_value} to {_property}.getValue()
  8. set {_json} to new String(Base64.getDecoder().decode({_value}.getBytes()), "UTF-8")
  9. put json {_json} parsed as jsonobject in listvar {_json::*}
  10. set {_model} to {_json::textures::SKIN::metadata::model}
  11. set {_url} to {_json::textures::SKIN::url}
  12. {_url} is set
  13. set {_skin} to ImageIO.read(new URL({_url}))
  14. set {_zombieparts} to ImageIO.read(new File("./plugins/ZombiePlayers/zombie_parts.png"))
  15. loop {_skin}.getWidth() times:
  16. loop {_skin}.getHeight() times:
  17. set {_color} to new Color({_skin}.getRGB((loop-number-1)-1, (loop-number-2)-1), true)
  18. set {_r} to floor({_color}.getRed()/256*118)
  19. set {_g} to floor({_color}.getGreen()/256*166)
  20. set {_b} to floor({_color}.getBlue()/256*90)
  21. set {_a} to {_color}.getAlpha()
  22. {_skin}.setRGB((loop-number-1)-1, (loop-number-2)-1, new Color({_r}/255, {_g}/255, {_b}/255, {_a}/255).getRGB())
  23. set {_graphics} to {_skin}.getGraphics()
  24. {_graphics}.drawImage({_zombieparts}, 0, 0, null)
  25. {_graphics}.dispose()
  26. set {_outputstream} to new ByteArrayOutputStream()
  27. ImageIO.write({_skin}, "png", {_outputstream})
  28. {_outputstream}.flush()
  29. set {_buffer} to {_outputstream}.toByteArray()
  30. set {_connection} to Jsoup.connect(uncolored "https://api.mineskin.org/generate/upload?name=&&rmodel=%check [{_model} is ""slim""] ? ""slim"" : ""steve""%&visibility=1").userAgent("ZombiePlayers").method(Method.POST!).data("file", "zombie_%name of {_p} in lower case%.png", new ByteArrayInputStream({_buffer})).ignoreContentType(true).ignoreHttpErrors(true).timeout(5000)
  31. set {_body} to try {_connection}.execute().body()
  32. put json {_body} parsed as jsonobject in listvar {_bodyjson::*}
  33. {_bodyjson::data::texture::value} and {_bodyjson::data::texture::signature} is set
  34. {_zombiegameprofile}.getProperties().removeAll("textures")
  35. {_zombiegameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", {_bodyjson::data::texture::value}, {_bodyjson::data::texture::signature}))
  36. return {_zombiegameprofile}
Advertisement
Add Comment
Please, Sign In to add comment