use of net.aufdemrand.denizen.nms.impl.packets.PacketOutSetSlot_v1_9_R2 in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNetworkManager_v1_9_R2 method sendPacket.
public void sendPacket(Packet packet) {
// If the packet sending isn't cancelled, allow normal sending
if (packet instanceof PacketPlayOutChat) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutChat_v1_9_R2((PacketPlayOutChat) packet))) {
oldManager.sendPacket(packet);
}
} else if (packet instanceof PacketPlayOutNamedEntitySpawn || packet instanceof PacketPlayOutSpawnEntity || packet instanceof PacketPlayOutSpawnEntityLiving || packet instanceof PacketPlayOutSpawnEntityPainting || packet instanceof PacketPlayOutSpawnEntityExperienceOrb) {
PacketOutSpawnEntity spawnEntity = new PacketOutSpawnEntity_v1_9_R2(player, packet);
final Entity entity = player.getWorld().getEntity(spawnEntity.getEntityId());
if (entity == null) {
oldManager.sendPacket(packet);
} else if (!NMSHandler.getInstance().getEntityHelper().isHidden(player.getBukkitEntity(), entity.getBukkitEntity())) {
if (entity instanceof EntityFakePlayer_v1_9_R2) {
final EntityFakePlayer_v1_9_R2 fakePlayer = (EntityFakePlayer_v1_9_R2) entity;
sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, fakePlayer));
Bukkit.getScheduler().runTaskLater(NMSHandler.getJavaPlugin(), new Runnable() {
@Override
public void run() {
sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, fakePlayer));
}
}, 5);
}
if (entity.isPassenger()) {
Bukkit.getScheduler().runTaskLater(NMSHandler.getJavaPlugin(), new Runnable() {
@Override
public void run() {
sendPacket(new PacketPlayOutMount(entity.getVehicle()));
}
}, 1);
}
oldManager.sendPacket(packet);
}
} else if (packet instanceof PacketPlayOutPlayerInfo) {
PacketPlayOutPlayerInfo playerInfo = (PacketPlayOutPlayerInfo) packet;
ProfileEditor_v1_9_R2.updatePlayerProfiles(playerInfo);
oldManager.sendPacket(playerInfo);
} else if (packet instanceof PacketPlayOutEntityMetadata) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutEntityMetadata_v1_9_R2((PacketPlayOutEntityMetadata) packet))) {
oldManager.sendPacket(packet);
}
} else if (packet instanceof PacketPlayOutSetSlot) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutSetSlot_v1_9_R2((PacketPlayOutSetSlot) packet))) {
oldManager.sendPacket(packet);
}
} else if (packet instanceof PacketPlayOutWindowItems) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutWindowItems_v1_9_R2((PacketPlayOutWindowItems) packet))) {
oldManager.sendPacket(packet);
}
} else if (packet instanceof PacketPlayOutCustomPayload) {
PacketPlayOutCustomPayload payload = (PacketPlayOutCustomPayload) packet;
PacketDataSerializer original = new PacketDataSerializer(Unpooled.buffer());
try {
payload.b(original);
// Copy the data without removing it from the original
PacketDataSerializer serializer = new PacketDataSerializer(original.getBytes(original.readerIndex(), new byte[original.readableBytes()]));
// Write the original back to avoid odd errors
payload.a(original);
String name = serializer.e(20);
if (name != null && name.equals("MC|TrList")) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutTradeList_v1_9_R2(payload, serializer))) {
oldManager.sendPacket(packet);
}
} else {
oldManager.sendPacket(packet);
}
} catch (Exception e) {
oldManager.sendPacket(packet);
}
} else {
oldManager.sendPacket(packet);
}
}
Aggregations