use of net.aufdemrand.denizen.nms.impl.packets.PacketOutWindowItems_v1_8_R3 in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNetworkManager_v1_8_R3 method handle.
public void handle(Packet packet) {
// If the packet sending isn't cancelled, allow normal sending
if (packet instanceof PacketPlayOutChat) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutChat_v1_8_R3((PacketPlayOutChat) packet))) {
oldManager.handle(packet);
}
} else if (packet instanceof PacketPlayOutNamedEntitySpawn || packet instanceof PacketPlayOutSpawnEntity || packet instanceof PacketPlayOutSpawnEntityLiving || packet instanceof PacketPlayOutSpawnEntityPainting || packet instanceof PacketPlayOutSpawnEntityExperienceOrb) {
PacketOutSpawnEntity spawnEntity = new PacketOutSpawnEntity_v1_8_R3(player, packet);
final Entity entity = player.getWorld().a(spawnEntity.getEntityId());
if (entity == null) {
oldManager.handle(packet);
} else if (!NMSHandler.getInstance().getEntityHelper().isHidden(player.getBukkitEntity(), entity.getBukkitEntity())) {
if (entity instanceof EntityFakePlayer_v1_8_R3) {
final EntityFakePlayer_v1_8_R3 fakePlayer = (EntityFakePlayer_v1_8_R3) entity;
handle(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, fakePlayer));
Bukkit.getScheduler().runTaskLater(NMSHandler.getJavaPlugin(), new Runnable() {
@Override
public void run() {
handle(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, fakePlayer));
}
}, 5);
}
oldManager.handle(packet);
}
} else if (packet instanceof PacketPlayOutPlayerInfo) {
PacketPlayOutPlayerInfo playerInfo = (PacketPlayOutPlayerInfo) packet;
ProfileEditor_v1_8_R3.updatePlayerProfiles(playerInfo);
oldManager.handle(playerInfo);
} else if (packet instanceof PacketPlayOutEntityMetadata) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutEntityMetadata_v1_8_R3((PacketPlayOutEntityMetadata) packet))) {
oldManager.handle(packet);
}
} else if (packet instanceof PacketPlayOutSetSlot) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutSetSlot_v1_8_R3((PacketPlayOutSetSlot) packet))) {
oldManager.handle(packet);
}
} else if (packet instanceof PacketPlayOutWindowItems) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutWindowItems_v1_8_R3((PacketPlayOutWindowItems) packet))) {
oldManager.handle(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.c(20);
if (name != null && name.equals("MC|TrList")) {
if (!packetHandler.sendPacket(player.getBukkitEntity(), new PacketOutTradeList_v1_8_R3(payload, serializer))) {
oldManager.handle(packet);
}
} else {
oldManager.handle(packet);
}
} catch (Exception e) {
oldManager.handle(packet);
}
} else {
oldManager.handle(packet);
}
}
Aggregations