akon1248

Infect Function

Jul 5th, 2019
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.83 KB | None | 0 0
  1. import:
  2. java.util.Collections
  3. org.bukkit.Bukkit
  4. com.comphenix.protocol.wrappers.EnumWrappers
  5. com.comphenix.protocol.wrappers.EnumWrappers$NativeGameMode
  6. com.comphenix.protocol.wrappers.EnumWrappers$PlayerInfoAction
  7. com.comphenix.protocol.wrappers.PlayerInfoData
  8. com.comphenix.protocol.wrappers.WrappedChatComponent
  9. com.comphenix.protocol.wrappers.WrappedGameProfile
  10. com.comphenix.protocol.wrappers.WrappedSignedProperty
  11. option nmsver:
  12. get:
  13. set {_package} to Bukkit.getServer().getClass().getPackage().getName()
  14. set {_strlist::*} to split {_package} by "."
  15. return {_strlist::4}
  16. function infect(p: player):
  17. {_p} is online
  18. {_p} do not have scoreboard tag "zombie"
  19. add "zombie" to scoreboard tags of {_p}
  20. changeSkin({_p}, "eyJ0aW1lc3RhbXAiOjE1NDQ0NTk4Mzc4MjMsInByb2ZpbGVJZCI6IjQzYTgzNzNkNjQyOTQ1MTBhOWFhYjMwZjViM2NlYmIzIiwicHJvZmlsZU5hbWUiOiJTa3VsbENsaWVudFNraW42Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZDY3NTUzYjMxOGJhMmVlMmI2MjZlOWI5ZGVkM2UxNWExZDBkOGQ5ZjM3MGZmMDNjOThiMzIzZTc4NTczYjlhIn19fQ==", "yUVWH96rIrYzOO4fCeB30pPSsdyaMJHwP0jKPfd+cfp5Bk5uOd5g547ISckhU0bZMWAkKqEeXUY3R1hsW3GJl+OKdTQwkKVhSdWf6AEV0LaTPav8TCd5jF2JVWDlGeXgHTp+TdBZPJIdWT1uuLuY42YdTfMGsywFE0rGljRo97hpMvBhgRcakw6d4friHUfzJy9shVeXW4gF8xZg79DP+WZ32F/IrsgoRU5O2nxM9ZgmjyaLTyO9WKQoMEpcLJl8vAet2NjJ1YH6klOxnqZpjYPebQuyfFb/ZfTfJv+AevccDCqr1T7OEM2u3MTwttcov5KbnhawrHZnVIBio2sTQGFUmzcsmIJht04YWGkQlrvSzQ4+6/Qyzixl4PE3pfbwg3truuJgItstLLbnNKFqa3H/RQam18vKdM8u7lqOomP4fWP4VEhBcIElnfwohy0PRJ+KOA5586WupKD3bxiAViUN4ywj212gyG6ie8KDDfrtC+e3VOWi/Vja+bJEmy2oHUndesySAZhNNMhrRIOYAARrhpcR0Cl8TmTVCYC4ooaKTdowi8cELLBxCnCJElozKUv2jhoWrpL4ZCSAepz85NdiQk2NjSNqgUOKzxf/pLD4iPs9R0+bVipyN8eGTpSzDdAQ4xO8n2nPQbcqfzqlIfY5hPF0S0+gApK68VXBGkA=")
  21. loop all players:
  22. scoreboard team "zombie" in scoreboard scoreboard of loop-player is set
  23. scoreboard do not have entry "%{_p}%" in the team scoreboard team "zombie" in scoreboard scoreboard of loop-player
  24. scoreboard add entry "%{_p}%" to team scoreboard team "zombie" in scoreboard scoreboard of loop-player
  25. function cure(p: player):
  26. {_p} is online
  27. {_p} has scoreboard tag "zombie"
  28. remove "zombie" from scoreboard tags of {_p}
  29. loop all players:
  30. scoreboard team "zombie" in scoreboard scoreboard of loop-player is set
  31. scoreboard has entry "%{_p}%" in the team scoreboard team "zombie" in scoreboard scoreboard of loop-player
  32. scoreboard remove entry "%{_p}%" from team scoreboard team "zombie" in scoreboard scoreboard of loop-player
  33. resetSkin({_p})
  34. set {_uuid} to UUID of {_p}
  35. {datawatcher::%{_uuid}%} is set
  36. set {_packet::1} to new play_server_named_entity_spawn packet
  37. set int pnum 0 of {_packet::1} to id of {_p}
  38. set "UUID" pinfo 0 of {_packet::1} to {_uuid}
  39. set double pnum 0 of {_packet::1} to x-coordinate of {_p}
  40. set double pnum 1 of {_packet::1} to y-coordinate of {_p}
  41. set double pnum 2 of {_packet::1} to z-coordinate of {_p}
  42. set byte pnum 0 of {_packet::1} to floor(yaw of {_p}*256/360)
  43. set byte pnum 1 of {_packet::1} to floor(pitch of {_p}*256/360)
  44. set "DataWatcherModifier" pinfo 0 of {_packet::1} to {datawatcher::%{_uuid}%}
  45. set {_packet::2} to new play_server_entity_equipment packet
  46. set int pnum 0 of {_packet::2} to id of {_p}
  47. set "ItemSlots" penum 0 of {_packet::2} to "MAINHAND"
  48. if tool of {_p} is set:
  49. set {_mainhand} to tool of {_p}
  50. set "ItemModifier" pinfo 0 of {_packet::2} to {_mainhand}
  51. set {_packet::3} to new play_server_entity_equipment packet
  52. set int pnum 0 of {_packet::3} to id of {_p}
  53. set "ItemSlots" penum 0 of {_packet::3} to "OFFHAND"
  54. if offhand tool of {_p} is set:
  55. set {_offhand} to offhand tool of {_p}
  56. set "ItemModifier" pinfo 0 of {_packet::2} to {_offhand}
  57. set {_packet::4} to new play_server_entity_equipment packet
  58. set int pnum 0 of {_packet::4} to id of {_p}
  59. set "ItemSlots" penum 0 of {_packet::4} to "FEET"
  60. if boots of {_p} is set:
  61. set {_feet} to boots of {_p}
  62. set "ItemModifier" pinfo 0 of {_packet::4} to {_feet}
  63. set {_packet::5} to new play_server_entity_equipment packet
  64. set int pnum 0 of {_packet::5} to id of {_p}
  65. set "ItemSlots" penum 0 of {_packet::5} to "LEGS"
  66. if leggings of {_p} is set:
  67. set {_legs} to leggings of {_p}
  68. set "ItemModifier" pinfo 0 of {_packet::5} to {_legs}
  69. set {_packet::6} to new play_server_entity_equipment packet
  70. set int pnum 0 of {_packet::6} to id of {_p}
  71. set "ItemSlots" penum 0 of {_packet::6} to "CHEST"
  72. if chestplate of {_p} is set:
  73. set {_chest} to chestplate of {_p}
  74. set "ItemModifier" pinfo 0 of {_packet::6} to {_chest}
  75. set {_packet::7} to new play_server_entity_equipment packet
  76. set int pnum 0 of {_packet::7} to id of {_p}
  77. set "ItemSlots" penum 0 of {_packet::7} to "HEAD"
  78. if helmet of {_p} is set:
  79. set {_head} to helmet of {_p}
  80. set "ItemModifier" pinfo 0 of {_packet::7} to {_head}
  81. loop all players:
  82. loop-player is not {_p}
  83. loop 7 times:
  84. send loop-player packet {_packet::%loop-number%}
  85. function sendZombiePacket(p1: player, p2: player):
  86. {_p1} is not {_p2}
  87. set {_packet::1} to new play_server_spawn_entity_living packet
  88. set int pnum 0 of {_packet::1} to id of {_p2}
  89. set int pnum 1 of {_packet::1} to 54
  90. set double pnum 0 of {_packet::1} to x-coordinate of {_p2}
  91. set double pnum 1 of {_packet::1} to y-coordinate of {_p2}
  92. set double pnum 2 of {_packet::1} to z-coordinate of {_p2}
  93. set byte pnum 0 of {_packet::1} to floor(yaw of {_p2}*256/360)
  94. set byte pnum 1 of {_packet::1} to floor(pitch of {_p2}*256/360)
  95. set byte pnum 2 of {_packet::1} to floor(yaw of {_p2}*256/360)
  96. set int pnum 2 of {_packet::1} to x of velocity of {_p2}*8000
  97. set int pnum 3 of {_packet::1} to y of velocity of {_p2}*8000
  98. set int pnum 4 of {_packet::1} to z of velocity of {_p2}*8000
  99. set {_json::2} to "&2&l%{_p2}%"
  100. set {_json::3} to true
  101. set "DataWatcher" pjson 0 of {_packet::1} to json from listvar {_json::*}
  102. set {_packet::2} to new play_server_entity_equipment packet
  103. set int pnum 0 of {_packet::2} to id of {_p2}
  104. set "ItemSlots" penum 0 of {_packet::2} to "MAINHAND"
  105. if tool of {_p2} is set:
  106. set {_mainhand} to tool of {_p2}
  107. set "ItemModifier" pinfo 0 of {_packet::2} to {_mainhand}
  108. set {_packet::3} to new play_server_entity_equipment packet
  109. set int pnum 0 of {_packet::3} to id of {_p2}
  110. set "ItemSlots" penum 0 of {_packet::3} to "OFFHAND"
  111. if offhand tool of {_p2} is set:
  112. set {_offhand} to offhand tool of {_p2}
  113. set "ItemModifier" pinfo 0 of {_packet::2} to {_offhand}
  114. set {_packet::4} to new play_server_entity_equipment packet
  115. set int pnum 0 of {_packet::4} to id of {_p2}
  116. set "ItemSlots" penum 0 of {_packet::4} to "FEET"
  117. if boots of {_p2} is set:
  118. set {_feet} to boots of {_p2}
  119. set "ItemModifier" pinfo 0 of {_packet::4} to {_feet}
  120. set {_packet::5} to new play_server_entity_equipment packet
  121. set int pnum 0 of {_packet::5} to id of {_p2}
  122. set "ItemSlots" penum 0 of {_packet::5} to "LEGS"
  123. if leggings of {_p2} is set:
  124. set {_legs} to leggings of {_p2}
  125. set "ItemModifier" pinfo 0 of {_packet::5} to {_legs}
  126. set {_packet::6} to new play_server_entity_equipment packet
  127. set int pnum 0 of {_packet::6} to id of {_p2}
  128. set "ItemSlots" penum 0 of {_packet::6} to "CHEST"
  129. if chestplate of {_p2} is set:
  130. set {_chest} to chestplate of {_p2}
  131. set "ItemModifier" pinfo 0 of {_packet::6} to {_chest}
  132. set {_packet::7} to new play_server_entity_equipment packet
  133. set int pnum 0 of {_packet::7} to id of {_p2}
  134. set "ItemSlots" penum 0 of {_packet::7} to "HEAD"
  135. if helmet of {_p2} is set:
  136. set {_head} to helmet of {_p2}
  137. set "ItemModifier" pinfo 0 of {_packet::7} to {_head}
  138. loop 7 times:
  139. send {_p1} packet {_packet::%loop-number%}
  140. function resetSkin(p: player):
  141. set {_uuid} to UUID of {_p}
  142. changeSkin({_p}, {defaultskinvalue::%{_uuid}%}, {defaultskinsignature::%{_uuid}%})
  143. function changeSkin(p: player, value: string, signature: string):
  144. set {_gameprofile} to new WrappedGameProfile(UUID of {_p}, name of {_p})
  145. {_gameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", {_value}, {_signature}))
  146. {_p}.getProfile().getProperties().removeAll("textures")
  147. {_p}.getProfile().getProperties().putAll("textures", {_gameprofile}.getHandle().getProperties().get("textures"))
  148. updateGameProfile({_p})
  149. function updateGameProfile(p: player):
  150. loop all players:
  151. loop-player is not {_p}
  152. loop-player can see {_p}
  153. hide {_p} from loop-player
  154. reveal {_p} to loop-player
  155. if vehicle of {_p} is set:
  156. set {_vehicle} to vehicle of {_p}
  157. make {_p} dismount
  158. set {_playerinfodata} to new PlayerInfoData(WrappedGameProfile.fromPlayer({_p}), 0, NativeGameMode.fromBukkit(gamemode of {_p}), WrappedChatComponent.fromText(playerlist name of {_p}))
  159. set {_removeinfo} to new play_server_player_info packet
  160. {_removeinfo}.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER!)
  161. {_removeinfo}.getPlayerInfoDataLists().write(0, Collections.singletonList({_playerinfodata}))
  162. set {_addinfo} to new play_server_player_info packet
  163. {_addinfo}.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER!)
  164. {_addinfo}.getPlayerInfoDataLists().write(0, Collections.singletonList({_playerinfodata}))
  165. set {_respawn} to new play_server_respawn packet
  166. set int pnum 0 of {_respawn} to {_p}.getWorld().getEnvironment().getId()
  167. {_respawn}.getDifficulties().write(0, EnumWrappers.getDifficultyConverter().getSpecific(difficulty of {_p}'s world))
  168. {_respawn}.getGameModes().write(0, NativeGameMode.fromBukkit(gamemode of {_p}))
  169. {_respawn}.getWorldTypeModifier().write(0, {_p}.getWorld().getWorldType())
  170. set {_position} to new play_server_position packet
  171. set double pnum 0 of {_position} to x-loc of {_p}
  172. set double pnum 1 of {_position} to y-loc of {_p}
  173. set double pnum 2 of {_position} to z-loc of {_p}
  174. set float pnum 0 of {_position} to yaw of {_p}
  175. set float pnum 1 of {_position} to pitch of {_p}
  176. set {_op} to new play_server_entity_status packet
  177. set int pnum 0 of {_op} to id of {_p}
  178. set byte pnum 0 of {_op} to 24+(Bukkit.getServer().getHandle().getOPs().[net.minecraft.server.{@nmsver}.JsonList]d!.get(UUID of {_p}).a())
  179. send {_p} packet {_removeinfo}
  180. send {_p} packet {_addinfo}
  181. send {_p} packet {_respawn}
  182. send {_p} packet {_position}
  183. send {_p} packet {_op}
  184. {_p}.updateScaledHealth()
  185. set {_updatehealth} to new play_server_update_health packet
  186. set float pnum 0 of {_updatehealth} to health of {_p}*2
  187. set float pnum 1 of {_updatehealth} to {_p}.getSaturation()
  188. set int pnum 0 of {_updatehealth} to food of {_p}*2
  189. send {_p} packet {_updatehealth}
  190. {_p}.updateInventory()
  191. set selected hotbar slot of {_p} to selected hotbar slot of {_p}
  192. {_p}.setExp({_p}.getExp())
  193. {_p}.setTotalExperience({_p}.getTotalExperience())
  194. set {_p}'s tool to {_p}.getItemInHand()
  195. set {_p}'s offhand tool to (inventory of {_p}).getItemInOffHand()
  196. set {_p}'s walk speed to {_p}'s walk speed
  197. set {_p}'s fly speed to {_p}'s fly speed
  198. {_vehicle} is set
  199. wait 1 tick
  200. make {_p} ride {_vehicle}
  201. on packet event play_server_entity_equipment:
  202. player's world pentity 0 of event-packet is a player
  203. "ItemSlots" penum 0 of event-packet is "MAINHAND" or "OFFHAND"
  204. if "ItemSlots" penum 0 of event-packet is "MAINHAND":
  205. "ItemModifier" pinfo 0 of event-packet is not tool of player's world pentity 0 of event-packet
  206. set {_item} to tool of player's world pentity 0 of event-packet
  207. else if "ItemSlots" penum 0 of event-packet is "OFFHAND":
  208. "ItemModifier" pinfo 0 of event-packet is not offhand tool of player's world pentity 0 of event-packet
  209. set {_item} to offhand tool of player's world pentity 0 of event-packet
  210. {_item} is set
  211. set "ItemModifier" pinfo 0 of event-packet to {_item}
  212. on packet event play_server_named_entity_spawn:
  213. player's world pentity 0 of event-packet is a player
  214. set {datawatcher::%UUID of player's world pentity 0 of event-packet%} to "DataWatcherModifier" pinfo 0 of event-packet
  215. player's world pentity 0 of event-packet has scoreboard tag "zombie"
  216. cancel event
  217. wait 1 tick
  218. sendZombiePacket(player, player's world pentity 0 of event-packet)
  219. on packet event play_server_player_info:
  220. event-packet.getPlayerInfoAction().read(0) is PlayerInfoAction.ADD_PLAYER!
  221. set {_oldplayerinfodata} to event-packet.getPlayerInfoDataLists().read(0).get(0)
  222. set {_gameprofile} to {_oldplayerinfodata}.getProfile()
  223. set {_player} to player from uuid "%{_gameprofile}.getUUID()%"
  224. {_player} is set
  225. set {_value} to (try {_player}.getProfile().getProperties().get("textures").iterator().next()).getValue()
  226. set {_signature} to (try {_player}.getProfile().getProperties().get("textures").iterator().next()).getSignature()
  227. {_value} is set
  228. {_signature} is set
  229. {_gameprofile}.getProperties().removeAll("textures")
  230. {_gameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", {_value}, {_signature}))
  231. set {_playerinfodata} to new PlayerInfoData({_gameprofile}, {_oldplayerinfodata}.getLatency(), {_oldplayerinfodata}.getGameMode(), {_oldplayerinfodata}.getDisplayName())
  232. event-packet.getPlayerInfoDataLists().write(0, Collections.singletonList({_playerinfodata}))
  233. on join:
  234. set {defaultskinvalue::%UUID of player%} to (try player.getProfile().getProperties().get("textures").iterator().next()).getValue()
  235. set {defaultskinsignature::%UUID of player%} to (try player.getProfile().getProperties().get("textures").iterator().next()).getSignature()
  236. register new scoreboard team "zombie" in scoreboard scoreboard of player if scoreboard team "zombie" in scoreboard scoreboard of player is not set
  237. set {_team} to scoreboard team "zombie" in scoreboard scoreboard of player
  238. set scoreboard team prefix of {_team} to "&2&l"
  239. loop all players:
  240. loop-player has scoreboard tag "zombie"
  241. scoreboard do not have entry "%loop-player%" in the team scoreboard team "zombie" in scoreboard scoreboard of player
  242. scoreboard add entry "%loop-player%" to team scoreboard team "zombie" in scoreboard scoreboard of player
  243. player has scoreboard tag "zombie"
  244. changeSkin(player, "eyJ0aW1lc3RhbXAiOjE1NDQ0NTk4Mzc4MjMsInByb2ZpbGVJZCI6IjQzYTgzNzNkNjQyOTQ1MTBhOWFhYjMwZjViM2NlYmIzIiwicHJvZmlsZU5hbWUiOiJTa3VsbENsaWVudFNraW42Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZDY3NTUzYjMxOGJhMmVlMmI2MjZlOWI5ZGVkM2UxNWExZDBkOGQ5ZjM3MGZmMDNjOThiMzIzZTc4NTczYjlhIn19fQ==", "yUVWH96rIrYzOO4fCeB30pPSsdyaMJHwP0jKPfd+cfp5Bk5uOd5g547ISckhU0bZMWAkKqEeXUY3R1hsW3GJl+OKdTQwkKVhSdWf6AEV0LaTPav8TCd5jF2JVWDlGeXgHTp+TdBZPJIdWT1uuLuY42YdTfMGsywFE0rGljRo97hpMvBhgRcakw6d4friHUfzJy9shVeXW4gF8xZg79DP+WZ32F/IrsgoRU5O2nxM9ZgmjyaLTyO9WKQoMEpcLJl8vAet2NjJ1YH6klOxnqZpjYPebQuyfFb/ZfTfJv+AevccDCqr1T7OEM2u3MTwttcov5KbnhawrHZnVIBio2sTQGFUmzcsmIJht04YWGkQlrvSzQ4+6/Qyzixl4PE3pfbwg3truuJgItstLLbnNKFqa3H/RQam18vKdM8u7lqOomP4fWP4VEhBcIElnfwohy0PRJ+KOA5586WupKD3bxiAViUN4ywj212gyG6ie8KDDfrtC+e3VOWi/Vja+bJEmy2oHUndesySAZhNNMhrRIOYAARrhpcR0Cl8TmTVCYC4ooaKTdowi8cELLBxCnCJElozKUv2jhoWrpL4ZCSAepz85NdiQk2NjSNqgUOKzxf/pLD4iPs9R0+bVipyN8eGTpSzDdAQ4xO8n2nPQbcqfzqlIfY5hPF0S0+gApK68VXBGkA=")
Advertisement
Add Comment
Please, Sign In to add comment