akon1248

Zombie Players

Feb 3rd, 2020
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.25 KB | None | 0 0
  1. import:
  2. com.comphenix.protocol.wrappers.EnumWrappers$NativeGameMode
  3. com.comphenix.protocol.wrappers.EnumWrappers$PlayerInfoAction
  4. com.comphenix.protocol.wrappers.PlayerInfoData
  5. com.comphenix.protocol.wrappers.WrappedChatComponent
  6. com.comphenix.protocol.wrappers.WrappedGameProfile
  7. com.comphenix.protocol.wrappers.WrappedSignedProperty
  8. java.awt.Color
  9. java.io.ByteArrayInputStream
  10. java.io.ByteArrayOutputStream
  11. java.io.File
  12. java.net.URL
  13. java.util.Base64
  14. java.util.Collections
  15. javax.imageio.ImageIO
  16. org.bukkit.Bukkit
  17. org.bukkit.inventory.MainHand
  18. org.jsoup.Connection$Method
  19. org.jsoup.Jsoup
  20. option nms:
  21. get:
  22. return index 3 of split Bukkit.getServer().getClass().getPackage().getName() by "."
  23. import:
  24. net.minecraft.server.{@nms}.EntityZombie
  25.  
  26. on join:
  27. $ thread
  28. set metadata value "ZombieGameProfile" of player to getZombieSkin(player)
  29. every tick:
  30. loop {zombieplayername::*}:
  31. entity from uuid loop-index is not set
  32. delete {zombieplayername::%loop-index%}
  33. delete {zombieplayervalue::%loop-index%}
  34. delete {zombieplayersignature::%loop-index%}
  35. delete {zombieplayeritems::%loop-index%::*}
  36. delete {zombieplayerexp::%loop-index%}
  37. on death of player:
  38. attacker is a zombie
  39. event.setKeepInventory(true)
  40. event.setKeepLevel(true)
  41. set {_zombie} to new EntityZombie(victim.getWorld().getHandle()).getBukkitEntity()
  42. {_zombie}.getHandle().setLocation(x-loc of victim, y-loc of victim, z-loc of victim, yaw of victim, pitch of victim)
  43. set {_uuid} to UUID of {_zombie}
  44. add "{CustomName:""%name of victim%"",Tags:[""zombie_player""],Attributes:[{Name:""generic.attackDamage"",Base:1.0d},{Name:""generic.movementSpeed"",Base:0.3d},{Name:""generic.armor"",Base:0.0d}],PersistenceRequired:1b,CanBreakDoors:1b,CanPickUpLoot:1b}" to nbt of {_zombie}
  45. if victim.getMainHand() is MainHand.LEFT!:
  46. add "lefthanded" to scoreboard tags of {_zombie}
  47. loop 36 times:
  48. set {_slot} to (loop-number)-1
  49. {_slot} is not selected hotbar slot of victim
  50. slot {_slot} of victim's inventory is not air
  51. set {zombieplayeritems::%{_uuid}%::%{_slot}%} to slot (loop-number)-1 of victim's inventory
  52. set {zombieplayerexp::%{_uuid}%} to victim.getTotalExperience()
  53. set level of victim to 0
  54. set level progress of victim to 0
  55. victim.setTotalExperience(0)
  56. set tool of {_zombie} to victim's tool
  57. set offhand tool of {_zombie} to victim's offhand tool
  58. set helmet of {_zombie} to victim's helmet
  59. set chestplate of {_zombie} to victim's chestplate
  60. set leggings of {_zombie} to victim's leggings
  61. set boots of {_zombie} to victim's boots
  62. clear victim's inventory
  63. set {_gameprofile} to metadata value "ZombieGameProfile" of victim
  64. set {zombieplayername::%{_uuid}%} to {_gameprofile}.getName()
  65. set {zombieplayervalue::%{_uuid}%} to {_gameprofile}.getProperties().get("textures").iterator().next().getValue()
  66. set {zombieplayersignature::%{_uuid}%} to {_gameprofile}.getProperties().get("textures").iterator().next().getSignature()
  67. victim.getWorld().getHandle().addEntity({_zombie}.getHandle())
  68. on packet event play_server_spawn_entity_living:
  69. set {_entity} to player's world pentity 0 of event-packet
  70. {_entity} is a zombie
  71. {_entity} has scoreboard tag "zombie_player"
  72. cancel event
  73. set {_uuid} to UUID of {_entity}
  74. set {_gameprofile} to new WrappedGameProfile({_uuid}, {zombieplayername::%{_uuid}%})
  75. {_gameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", {zombieplayervalue::%{_uuid}%}, {zombieplayersignature::%{_uuid}%}))
  76. set {_playerinfodata} to new PlayerInfoData({_gameprofile}, 0, NativeGameMode.SURVIVAL!, WrappedChatComponent.fromText(""))
  77. set {_addinfo} to new play_server_player_info packet
  78. {_addinfo}.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER!)
  79. {_addinfo}.getPlayerInfoDataLists().write(0, Collections.singletonList({_playerinfodata}))
  80. set {_spawnplayer} to new play_server_named_entity_spawn packet
  81. set int pnum 0 of {_spawnplayer} to int pnum 0 of event-packet
  82. set "UUID" pinfo 0 of {_spawnplayer} to {_uuid}
  83. set double pnum 0 of {_spawnplayer} to double pnum 0 of event-packet
  84. set double pnum 1 of {_spawnplayer} to double pnum 1 of event-packet
  85. set double pnum 2 of {_spawnplayer} to double pnum 2 of event-packet
  86. set byte pnum 0 of {_spawnplayer} to byte pnum 0 of event-packet
  87. set byte pnum 1 of {_spawnplayer} to byte pnum 1 of event-packet
  88. put json "DataWatcher" pjson 0 of event-packet in listvar {_json::*}
  89. delete {_json::11}
  90. delete {_json::12}
  91. set {_json::entity} to {_entity}
  92. set {_json::13} to 127.byteValue()
  93. set {_json::14} to check [{_entity} has scoreboard tag "lefthanded"] ? 0.byteValue() : 1.byteValue()
  94. set "DataWatcher" pjson 0 of {_spawnplayer} to json from listvar {_json::*}
  95. set {_removeinfo} to new play_server_player_info packet
  96. {_removeinfo}.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER!)
  97. {_removeinfo}.getPlayerInfoDataLists().write(0, Collections.singletonList({_playerinfodata}))
  98. send player packet {_addinfo}
  99. send player packet {_spawnplayer}
  100. wait 50 tick
  101. send player packet {_removeinfo}
  102. on packet event play_server_entity_metadata:
  103. set {_entity} to player's world pentity 0 of event-packet
  104. {_entity} is a zombie
  105. {_entity} has scoreboard tag "zombie_player"
  106. put json "WatchableCollection" pjson 0 of event-packet in listvar {_json::*}
  107. delete {_json::11}
  108. delete {_json::12}
  109. delete {_json::13}
  110. delete {_json::14}
  111. set "WatchableCollection" pjson 0 of event-packet to json from listvar {_json::*}
  112. on death of zombie:
  113. victim has scoreboard tag "zombie_player"
  114. clear drops
  115. event.setDroppedExp({zombieplayerexp::%UUID of victim%})
  116. loop {zombieplayeritems::%UUID of victim%::*}:
  117. add loop-value to drops
  118. add victim's tool to drops
  119. add victim's offhand tool to drops
  120. add victim's helmet to drops
  121. add victim's chestplate to drops
  122. add victim's leggings to drops
  123. add victim's boots to drops
  124. function getZombieSkin(p: player) :: object:
  125. set {_zombiegameprofile} to new WrappedGameProfile(new uuid, name of {_p})
  126. {_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="))
  127. set {_gameprofile} to WrappedGameProfile.fromPlayer({_p})
  128. set {_property} to try {_gameprofile}.getProperties().get("textures").iterator().next()
  129. if {_property} is set:
  130. set {_value} to {_property}.getValue()
  131. set {_json} to new String(Base64.getDecoder().decode({_value}.getBytes()), "UTF-8")
  132. put json {_json} parsed as jsonobject in listvar {_json::*}
  133. set {_model} to {_json::textures::SKIN::metadata::model}
  134. set {_url} to {_json::textures::SKIN::url}
  135. {_url} is set
  136. set {_skin} to ImageIO.read(new URL({_url}))
  137. set {_zombieparts} to ImageIO.read(new File("./plugins/ZombiePlayers/zombie_parts.png"))
  138. loop {_skin}.getWidth() times:
  139. loop {_skin}.getHeight() times:
  140. set {_color} to new Color({_skin}.getRGB((loop-number-1)-1, (loop-number-2)-1), true)
  141. set {_r} to floor({_color}.getRed()/128*59)
  142. set {_g} to floor({_color}.getGreen()/128*83)
  143. set {_b} to floor({_color}.getBlue()/128*45)
  144. set {_a} to {_color}.getAlpha()
  145. {_skin}.setRGB((loop-number-1)-1, (loop-number-2)-1, new Color({_r}/255, {_g}/255, {_b}/255, {_a}/255).getRGB())
  146. set {_graphics} to {_skin}.getGraphics()
  147. {_graphics}.drawImage({_zombieparts}, 0, 0, null)
  148. {_graphics}.dispose()
  149. set {_outputstream} to new ByteArrayOutputStream()
  150. ImageIO.write({_skin}, "png", {_outputstream})
  151. {_outputstream}.flush()
  152. set {_buffer} to {_outputstream}.toByteArray()
  153. 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)
  154. set {_body} to try {_connection}.execute().body()
  155. put json {_body} parsed as jsonobject in listvar {_bodyjson::*}
  156. {_bodyjson::data::texture::value} and {_bodyjson::data::texture::signature} is set
  157. {_zombiegameprofile}.getProperties().removeAll("textures")
  158. {_zombiegameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", {_bodyjson::data::texture::value}, {_bodyjson::data::texture::signature}))
  159. return {_zombiegameprofile}
Advertisement
Add Comment
Please, Sign In to add comment