Search in sources :

Example 1 with PacketPlayOutEntityDestroy

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditor_v1_9_R2 method updatePlayer.

@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    final UUID uuid = player.getUniqueId();
    PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (!p.getUniqueId().equals(uuid)) {
            PacketHelper_v1_9_R2.sendPacket(p, destroyPacket);
        }
    }
    new BukkitRunnable() {

        @Override
        public void run() {
            PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
            PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                PacketHelper_v1_9_R2.sendPacket(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelper_v1_9_R2.sendPacket(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        boolean isFlying = player.isFlying();
                        PacketHelper_v1_9_R2.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
                        player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
                        player.setFlying(isFlying);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) PacketPlayOutNamedEntitySpawn(net.minecraft.server.v1_9_R2.PacketPlayOutNamedEntitySpawn) PacketPlayOutEntityDestroy(net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_9_R2.PacketPlayOutPlayerInfo) PacketPlayOutRespawn(net.minecraft.server.v1_9_R2.PacketPlayOutRespawn) UUID(java.util.UUID)

Example 2 with PacketPlayOutEntityDestroy

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditor_v1_11_R1 method updatePlayer.

@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    final UUID uuid = player.getUniqueId();
    PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (!p.getUniqueId().equals(uuid)) {
            PacketHelper_v1_11_R1.sendPacket(p, destroyPacket);
        }
    }
    new BukkitRunnable() {

        @Override
        public void run() {
            PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
            PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                PacketHelper_v1_11_R1.sendPacket(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelper_v1_11_R1.sendPacket(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        boolean isFlying = player.isFlying();
                        PacketHelper_v1_11_R1.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
                        player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
                        player.setFlying(isFlying);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) PacketPlayOutNamedEntitySpawn(net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn) PacketPlayOutEntityDestroy(net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy) EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo) PacketPlayOutRespawn(net.minecraft.server.v1_11_R1.PacketPlayOutRespawn) UUID(java.util.UUID)

Example 3 with PacketPlayOutEntityDestroy

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy in project Denizen-For-Bukkit by DenizenScript.

the class BossBar_v1_8_R3 method removeBossBar.

public static void removeBossBar(Player player) {
    if (hasHealthBar.containsKey(player.getName())) {
        PacketHelper_v1_8_R3.sendPacket(player, new PacketPlayOutEntityDestroy(wither.getId()));
        hasHealthBar.put(player.getName(), false);
        playersWithHealthBar.remove(player);
    }
}
Also used : PacketPlayOutEntityDestroy(net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy)

Example 4 with PacketPlayOutEntityDestroy

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditor_v1_8_R3 method updatePlayer.

@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    final UUID uuid = player.getUniqueId();
    PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (!p.getUniqueId().equals(uuid)) {
            PacketHelper_v1_8_R3.sendPacket(p, destroyPacket);
        }
    }
    new BukkitRunnable() {

        @Override
        public void run() {
            PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
            PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                PacketHelper_v1_8_R3.sendPacket(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelper_v1_8_R3.sendPacket(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        boolean isFlying = player.isFlying();
                        PacketHelper_v1_8_R3.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
                        player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
                        player.setFlying(isFlying);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) PacketPlayOutNamedEntitySpawn(net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn) PacketPlayOutEntityDestroy(net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo) PacketPlayOutRespawn(net.minecraft.server.v1_8_R3.PacketPlayOutRespawn) UUID(java.util.UUID)

Example 5 with PacketPlayOutEntityDestroy

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditor_v1_10_R1 method updatePlayer.

@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    final UUID uuid = player.getUniqueId();
    PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (!p.getUniqueId().equals(uuid)) {
            PacketHelper_v1_10_R1.sendPacket(p, destroyPacket);
        }
    }
    new BukkitRunnable() {

        @Override
        public void run() {
            PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
            PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                PacketHelper_v1_10_R1.sendPacket(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelper_v1_10_R1.sendPacket(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        boolean isFlying = player.isFlying();
                        PacketHelper_v1_10_R1.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
                        player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
                        player.setFlying(isFlying);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer) PacketPlayOutNamedEntitySpawn(net.minecraft.server.v1_10_R1.PacketPlayOutNamedEntitySpawn) PacketPlayOutEntityDestroy(net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy) EntityPlayer(net.minecraft.server.v1_10_R1.EntityPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo) PacketPlayOutRespawn(net.minecraft.server.v1_10_R1.PacketPlayOutRespawn) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)4 Player (org.bukkit.entity.Player)4 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)4 PacketPlayOutEntityDestroy (net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy)2 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)1 PacketPlayOutEntityDestroy (net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy)1 PacketPlayOutNamedEntitySpawn (net.minecraft.server.v1_10_R1.PacketPlayOutNamedEntitySpawn)1 PacketPlayOutPlayerInfo (net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo)1 PacketPlayOutRespawn (net.minecraft.server.v1_10_R1.PacketPlayOutRespawn)1 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)1 PacketPlayOutEntityDestroy (net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy)1 PacketPlayOutNamedEntitySpawn (net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn)1 PacketPlayOutPlayerInfo (net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo)1 PacketPlayOutRespawn (net.minecraft.server.v1_11_R1.PacketPlayOutRespawn)1 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)1 PacketPlayOutNamedEntitySpawn (net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn)1 PacketPlayOutPlayerInfo (net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo)1 PacketPlayOutRespawn (net.minecraft.server.v1_8_R3.PacketPlayOutRespawn)1 EntityPlayer (net.minecraft.server.v1_9_R2.EntityPlayer)1 PacketPlayOutEntityDestroy (net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy)1