Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import:
- com.comphenix.protocol.wrappers.EnumWrappers$NativeGameMode
- com.comphenix.protocol.wrappers.EnumWrappers$PlayerInfoAction
- com.comphenix.protocol.wrappers.PlayerInfoData
- com.comphenix.protocol.wrappers.WrappedChatComponent
- com.comphenix.protocol.wrappers.WrappedGameProfile
- com.comphenix.protocol.wrappers.WrappedSignedProperty
- java.awt.Color
- java.io.ByteArrayInputStream
- java.io.ByteArrayOutputStream
- java.io.File
- java.net.URL
- java.util.Base64
- java.util.Collections
- javax.imageio.ImageIO
- org.bukkit.Bukkit
- org.bukkit.inventory.MainHand
- org.jsoup.Connection$Method
- org.jsoup.Jsoup
- option nms:
- get:
- return index 3 of split Bukkit.getServer().getClass().getPackage().getName() by "."
- import:
- net.minecraft.server.{@nms}.EntityZombie
- on join:
- $ thread
- set metadata value "ZombieGameProfile" of player to getZombieSkin(player)
- every tick:
- loop {zombieplayername::*}:
- entity from uuid loop-index is not set
- delete {zombieplayername::%loop-index%}
- delete {zombieplayervalue::%loop-index%}
- delete {zombieplayersignature::%loop-index%}
- delete {zombieplayeritems::%loop-index%::*}
- delete {zombieplayerexp::%loop-index%}
- on death of player:
- attacker is a zombie
- event.setKeepInventory(true)
- event.setKeepLevel(true)
- set {_zombie} to new EntityZombie(victim.getWorld().getHandle()).getBukkitEntity()
- {_zombie}.getHandle().setLocation(x-loc of victim, y-loc of victim, z-loc of victim, yaw of victim, pitch of victim)
- set {_uuid} to UUID of {_zombie}
- 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}
- if victim.getMainHand() is MainHand.LEFT!:
- add "lefthanded" to scoreboard tags of {_zombie}
- loop 36 times:
- set {_slot} to (loop-number)-1
- {_slot} is not selected hotbar slot of victim
- slot {_slot} of victim's inventory is not air
- set {zombieplayeritems::%{_uuid}%::%{_slot}%} to slot (loop-number)-1 of victim's inventory
- set {zombieplayerexp::%{_uuid}%} to victim.getTotalExperience()
- set level of victim to 0
- set level progress of victim to 0
- victim.setTotalExperience(0)
- set tool of {_zombie} to victim's tool
- set offhand tool of {_zombie} to victim's offhand tool
- set helmet of {_zombie} to victim's helmet
- set chestplate of {_zombie} to victim's chestplate
- set leggings of {_zombie} to victim's leggings
- set boots of {_zombie} to victim's boots
- clear victim's inventory
- set {_gameprofile} to metadata value "ZombieGameProfile" of victim
- set {zombieplayername::%{_uuid}%} to {_gameprofile}.getName()
- set {zombieplayervalue::%{_uuid}%} to {_gameprofile}.getProperties().get("textures").iterator().next().getValue()
- set {zombieplayersignature::%{_uuid}%} to {_gameprofile}.getProperties().get("textures").iterator().next().getSignature()
- victim.getWorld().getHandle().addEntity({_zombie}.getHandle())
- on packet event play_server_spawn_entity_living:
- set {_entity} to player's world pentity 0 of event-packet
- {_entity} is a zombie
- {_entity} has scoreboard tag "zombie_player"
- cancel event
- set {_uuid} to UUID of {_entity}
- set {_gameprofile} to new WrappedGameProfile({_uuid}, {zombieplayername::%{_uuid}%})
- {_gameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", {zombieplayervalue::%{_uuid}%}, {zombieplayersignature::%{_uuid}%}))
- set {_playerinfodata} to new PlayerInfoData({_gameprofile}, 0, NativeGameMode.SURVIVAL!, WrappedChatComponent.fromText(""))
- set {_addinfo} to new play_server_player_info packet
- {_addinfo}.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER!)
- {_addinfo}.getPlayerInfoDataLists().write(0, Collections.singletonList({_playerinfodata}))
- set {_spawnplayer} to new play_server_named_entity_spawn packet
- set int pnum 0 of {_spawnplayer} to int pnum 0 of event-packet
- set "UUID" pinfo 0 of {_spawnplayer} to {_uuid}
- set double pnum 0 of {_spawnplayer} to double pnum 0 of event-packet
- set double pnum 1 of {_spawnplayer} to double pnum 1 of event-packet
- set double pnum 2 of {_spawnplayer} to double pnum 2 of event-packet
- set byte pnum 0 of {_spawnplayer} to byte pnum 0 of event-packet
- set byte pnum 1 of {_spawnplayer} to byte pnum 1 of event-packet
- put json "DataWatcher" pjson 0 of event-packet in listvar {_json::*}
- delete {_json::11}
- delete {_json::12}
- set {_json::entity} to {_entity}
- set {_json::13} to 127.byteValue()
- set {_json::14} to check [{_entity} has scoreboard tag "lefthanded"] ? 0.byteValue() : 1.byteValue()
- set "DataWatcher" pjson 0 of {_spawnplayer} to json from listvar {_json::*}
- set {_removeinfo} to new play_server_player_info packet
- {_removeinfo}.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER!)
- {_removeinfo}.getPlayerInfoDataLists().write(0, Collections.singletonList({_playerinfodata}))
- send player packet {_addinfo}
- send player packet {_spawnplayer}
- wait 50 tick
- send player packet {_removeinfo}
- on packet event play_server_entity_metadata:
- set {_entity} to player's world pentity 0 of event-packet
- {_entity} is a zombie
- {_entity} has scoreboard tag "zombie_player"
- put json "WatchableCollection" pjson 0 of event-packet in listvar {_json::*}
- delete {_json::11}
- delete {_json::12}
- delete {_json::13}
- delete {_json::14}
- set "WatchableCollection" pjson 0 of event-packet to json from listvar {_json::*}
- on death of zombie:
- victim has scoreboard tag "zombie_player"
- clear drops
- event.setDroppedExp({zombieplayerexp::%UUID of victim%})
- loop {zombieplayeritems::%UUID of victim%::*}:
- add loop-value to drops
- add victim's tool to drops
- add victim's offhand tool to drops
- add victim's helmet to drops
- add victim's chestplate to drops
- add victim's leggings to drops
- add victim's boots to drops
- function getZombieSkin(p: player) :: object:
- set {_zombiegameprofile} to new WrappedGameProfile(new uuid, name of {_p})
- {_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="))
- set {_gameprofile} to WrappedGameProfile.fromPlayer({_p})
- set {_property} to try {_gameprofile}.getProperties().get("textures").iterator().next()
- if {_property} is set:
- set {_value} to {_property}.getValue()
- set {_json} to new String(Base64.getDecoder().decode({_value}.getBytes()), "UTF-8")
- put json {_json} parsed as jsonobject in listvar {_json::*}
- set {_model} to {_json::textures::SKIN::metadata::model}
- set {_url} to {_json::textures::SKIN::url}
- {_url} is set
- set {_skin} to ImageIO.read(new URL({_url}))
- set {_zombieparts} to ImageIO.read(new File("./plugins/ZombiePlayers/zombie_parts.png"))
- loop {_skin}.getWidth() times:
- loop {_skin}.getHeight() times:
- set {_color} to new Color({_skin}.getRGB((loop-number-1)-1, (loop-number-2)-1), true)
- set {_r} to floor({_color}.getRed()/128*59)
- set {_g} to floor({_color}.getGreen()/128*83)
- set {_b} to floor({_color}.getBlue()/128*45)
- set {_a} to {_color}.getAlpha()
- {_skin}.setRGB((loop-number-1)-1, (loop-number-2)-1, new Color({_r}/255, {_g}/255, {_b}/255, {_a}/255).getRGB())
- set {_graphics} to {_skin}.getGraphics()
- {_graphics}.drawImage({_zombieparts}, 0, 0, null)
- {_graphics}.dispose()
- set {_outputstream} to new ByteArrayOutputStream()
- ImageIO.write({_skin}, "png", {_outputstream})
- {_outputstream}.flush()
- set {_buffer} to {_outputstream}.toByteArray()
- 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)
- set {_body} to try {_connection}.execute().body()
- put json {_body} parsed as jsonobject in listvar {_bodyjson::*}
- {_bodyjson::data::texture::value} and {_bodyjson::data::texture::signature} is set
- {_zombiegameprofile}.getProperties().removeAll("textures")
- {_zombiegameprofile}.getProperties().put("textures", new WrappedSignedProperty("textures", {_bodyjson::data::texture::value}, {_bodyjson::data::texture::signature}))
- return {_zombiegameprofile}
Advertisement
Add Comment
Please, Sign In to add comment