private void sendPacketsSelf(WrappedGameProfile gameProfile) {
PacketContainer removeInfo;
PacketContainer addInfo;
PacketContainer respawn;
PacketContainer teleport;
try {
NativeGameMode gamemode = NativeGameMode.fromBukkit(receiver.getGameMode());
WrappedChatComponent displayName = WrappedChatComponent.fromText(receiver.getPlayerListName());
PlayerInfoData playerInfoData = new PlayerInfoData(gameProfile, 0, gamemode, displayName);
removeInfo = new PacketContainer(PLAYER_INFO);
removeInfo.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
removeInfo.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
addInfo = removeInfo.deepClone();
addInfo.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
respawn = createRespawnPacket(gamemode);
teleport = createTeleportPacket(receiver.getLocation().clone());
} catch (ReflectiveOperationException reflectiveEx) {
plugin.getLog().error("Error occured preparing packets. Cancelling self update", reflectiveEx);
return;
}
sendPackets(removeInfo, addInfo, respawn, teleport);
}